add gpt/chat api prefix (#33)

* add gpt/chat api prefix

* add chatgpt backend url
This commit is contained in:
Dmitry Afanasyev
2023-10-11 14:21:50 +03:00
committed by GitHub
parent 7cd0f30c55
commit 9e3fac0b94
14 changed files with 142 additions and 110 deletions

View File

@@ -45,7 +45,7 @@ async def about_bot(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
async def website(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
if not update.effective_message:
return None
website = urljoin(settings.DOMAIN, f"{settings.URL_PREFIX}/chat/")
website = urljoin(settings.DOMAIN, f"{settings.chat_prefix}/")
await update.effective_message.reply_text(f"Веб версия: {website}")

View File

@@ -9,7 +9,7 @@ from loguru import logger
from sqlalchemy import delete, desc, select, update
from sqlalchemy.dialects.sqlite import insert
from constants import CHATGPT_BASE_URI, INVALID_GPT_REQUEST_MESSAGES
from constants import INVALID_GPT_REQUEST_MESSAGES
from core.bot.models.chat_gpt import ChatGpt
from infra.database.db_adapter import Database
from settings.config import AppSettings
@@ -86,7 +86,7 @@ class ChatGPTRepository:
transport = AsyncHTTPTransport(retries=3)
async with AsyncClient(base_url=self.settings.GPT_BASE_HOST, transport=transport, timeout=50) as client:
return await client.post(CHATGPT_BASE_URI, json=data, timeout=50)
return await client.post(self.settings.chatgpt_backend_url, json=data, timeout=50)
@staticmethod
def _build_request_data(*, question: str, chatgpt_model: str) -> dict[str, Any]: