Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,203 changes: 671 additions & 532 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.10,<3.13"
azure-ai-inference = "^1.0.0b8"
azure-core = "^1.32.0"
backoff = "^2.2.1"
ecologits = "^0.5.2"
fastapi = "^0.115.8"
huggingface-hub = "^0.29.1"
langdetect = "^1.0.9"
litellm = "^1.61.15"
mistralai = "^1.2.2"
openai = "^1.60.2"
psycopg2-binary = "^2.9.10"
pydantic = "^2.1.1"
pydantic-settings = "^2.0.3"
Expand Down
10 changes: 7 additions & 3 deletions rag-metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)

from src.app.api.dependencies import get_settings
from src.app.services.abst_chat import ChatFactory
from src.app.services.abst_chat import AbstractChat

logger = logging.getLogger(__name__)

Expand All @@ -41,9 +41,13 @@
# init chat client
settings = get_settings()

chat = ChatFactory().create_chat("openai")
chat = AbstractChat(
model="azure/gpt-4o-mini",
API_KEY=settings.AZURE_API_KEY,
API_BASE=settings.AZURE_API_BASE,
API_VERSION=settings.AZURE_API_VERSION,
)

chat.init_client()

# init test chat client
model = "gpt-4o-mini"
Expand Down
15 changes: 12 additions & 3 deletions src/app/api/api_v1/endpoints/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
from fastapi import APIRouter, Depends, HTTPException, status
from fastapi.responses import StreamingResponse
from openai import RateLimitError
from pydantic import BaseModel

from src.app.api.dependencies import get_settings
from src.app.models import chat as models
from src.app.services.abst_chat import AbstractChat, ChatFactory
from src.app.services.abst_chat import AbstractChat
from src.app.services.constants import subjects as subjectsDict
from src.app.services.exceptions import (
EmptyQueryError,
Expand All @@ -23,8 +24,12 @@

settings = get_settings()

chatfactory: AbstractChat = ChatFactory().create_chat("openai")
chatfactory.init_client()
chatfactory = AbstractChat(
model="azure/gpt-4o-mini",
API_KEY=settings.AZURE_API_KEY,
API_BASE=settings.AZURE_API_BASE,
API_VERSION=settings.AZURE_API_VERSION,
)


def get_params(body: models.Context) -> models.ContextOut:
Expand All @@ -42,6 +47,10 @@ def get_params(body: models.Context) -> models.ContextOut:
)


class Response(BaseModel):
greeting: str


@router.post(
"/reformulate/query",
summary="Reformulate User Query",
Expand Down
20 changes: 15 additions & 5 deletions src/app/api/api_v1/endpoints/tutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from src.app.api.dependencies import get_settings
from src.app.models.search import EnhancedSearchQuery
from src.app.services.abst_chat import AbstractChat, ChatFactory
from src.app.services.abst_chat import AbstractChat
from src.app.services.exceptions import NoResultsError
from src.app.services.search import SearchService
from src.app.services.search_helpers import search_multi_inputs
Expand All @@ -23,8 +23,13 @@

settings = get_settings()

chatfactory: AbstractChat = ChatFactory().create_chat("openai", model="gpt-4o")
chatfactory.init_client()

chatfactory = AbstractChat(
model="azure/gpt-4o",
API_KEY=settings.AZURE_GPT_4O_API_KEY,
API_BASE=settings.AZURE_GPT_4O_API_BASE,
API_VERSION=settings.AZURE_GPT_4O_API_VERSION,
)

sp = SearchService()

Expand Down Expand Up @@ -69,9 +74,14 @@ async def tutor_search(
]

try:
themes_extracted = await chatfactory.chat_schema(
model="gpt-4o", messages=messages, response_format=ExtractorOuputList # type: ignore
themes_extracted = await chatfactory.chat_client.completion(
messages=messages, response_format=ExtractorOuputList
)

assert isinstance(themes_extracted, dict)

themes_extracted = ExtractorOuputList(**themes_extracted)

except Exception as e:
logger.error(f"Error in chat schema: {e}")
# todo: handle error
Expand Down
Loading