Skip to content

Commit 81dcbe4

Browse files
improve
1 parent 99968ce commit 81dcbe4

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

services/web/server/src/simcore_service_webserver/chatbot/_client.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
wait_exponential,
2020
)
2121

22-
from .settings import get_plugin_settings
22+
from .settings import ChatbotSettings, get_plugin_settings
2323

2424
_logger = logging.getLogger(__name__)
2525

@@ -61,9 +61,10 @@ def _chatbot_retry():
6161

6262

6363
class ChatbotRestClient:
64-
def __init__(self, base_url: str) -> None:
64+
def __init__(self, base_url: str, chatbot_settings: ChatbotSettings) -> None:
6565
self._client = httpx.AsyncClient()
6666
self._base_url = base_url
67+
self._chatbot_settings = chatbot_settings
6768

6869
async def get_settings(self) -> dict[str, Any]:
6970
"""Fetches chatbot settings"""
@@ -94,8 +95,8 @@ async def _request() -> httpx.Response:
9495
url,
9596
json={
9697
"question": question,
97-
"llm": "gpt-3.5-turbo",
98-
"embedding_model": "openai/text-embedding-3-large",
98+
"llm": self._chatbot_settings.CHATBOT_LLM_MODEL,
99+
"embedding_model": self._chatbot_settings.CHATBOT_EMBEDDING_MODEL,
99100
},
100101
headers={
101102
"Content-Type": _JSON_CONTENT_TYPE,
@@ -129,7 +130,10 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
129130
async def setup_chatbot_rest_client(app: web.Application) -> None:
130131
chatbot_settings = get_plugin_settings(app)
131132

132-
client = ChatbotRestClient(base_url=chatbot_settings.base_url)
133+
client = ChatbotRestClient(
134+
base_url=chatbot_settings.base_url,
135+
chatbot_settings=chatbot_settings,
136+
)
133137

134138
app[_APPKEY] = client
135139

services/web/server/src/simcore_service_webserver/chatbot/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
class ChatbotSettings(BaseCustomSettings, MixinServiceSettings):
1111
CHATBOT_HOST: str
1212
CHATBOT_PORT: int
13+
CHATBOT_LLM_MODEL: str = "gpt-3.5-turbo"
14+
CHATBOT_EMBEDDING_MODEL: str = "openai/text-embedding-3-large"
1315

1416
@cached_property
1517
def base_url(self) -> str:

0 commit comments

Comments
 (0)