diff --git a/daras_ai_v2/bot_integration_widgets.py b/daras_ai_v2/bot_integration_widgets.py index 4b87d70f0..2782c2eab 100644 --- a/daras_ai_v2/bot_integration_widgets.py +++ b/daras_ai_v2/bot_integration_widgets.py @@ -1,12 +1,13 @@ +import json from itertools import zip_longest from textwrap import dedent +import gooey_gui as gui from django.core.exceptions import ValidationError from django.db import transaction from django.utils.text import slugify from furl import furl -import gooey_gui as gui from app_users.models import AppUser from bots.models import BotIntegration, BotIntegrationAnalysisRun, Platform from daras_ai_v2 import settings, icons @@ -311,7 +312,7 @@ def get_bot_test_link(bi: BotIntegration) -> str | None: return None -def get_web_widget_embed_code(bi: BotIntegration) -> str: +def get_web_widget_embed_code(bi: BotIntegration, *, config: dict = None) -> str: lib_src = get_app_route_url( chat_lib_route, path_params=dict( @@ -319,11 +320,19 @@ def get_web_widget_embed_code(bi: BotIntegration) -> str: integration_name=slugify(bi.name) or "untitled", ), ).rstrip("/") + if config is None: + config = {} return dedent( - f""" + """
- + + """ + % dict(config_json=json.dumps(config), lib_src=lib_src) ).strip() diff --git a/routers/root.py b/routers/root.py index d353bddd4..62c0125ca 100644 --- a/routers/root.py +++ b/routers/root.py @@ -503,6 +503,7 @@ def chat_route( request: Request, integration_id: str = None, integration_name: str = None ): from routers.bots_api import api_hashids + from daras_ai_v2.bot_integration_widgets import get_web_widget_embed_code try: bi = BotIntegration.objects.get(id=api_hashids.decode(integration_id)[0]) @@ -514,6 +515,7 @@ def chat_route( { "request": request, "bi": bi, + "embed_code": get_web_widget_embed_code(bi, config=dict(mode="fullscreen")), "meta": raw_build_meta_tags( url=get_og_url_path(request), title=f"Chat with {bi.name}", diff --git a/templates/chat_fullscreen.html b/templates/chat_fullscreen.html index c96074da5..339f738fd 100644 --- a/templates/chat_fullscreen.html +++ b/templates/chat_fullscreen.html @@ -12,10 +12,6 @@ {% endfor %} - - - +{{ embed_code | safe }}