mirror of
https://github.com/StanGirard/quivr.git
synced 2024-09-11 13:15:41 +03:00
fix: RAG service bug assertion error (#2796)
# Description Fixes assertion error on brains of brain type integration. !/!: temporary fix casts user_id to string for the assertion
This commit is contained in:
parent
757bceeb95
commit
1fa79de859
@ -3,6 +3,7 @@ from uuid import UUID
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, Request
|
||||
from fastapi.responses import StreamingResponse
|
||||
|
||||
from quivr_api.logger import get_logger
|
||||
from quivr_api.middlewares.auth import AuthBearer, get_current_user
|
||||
from quivr_api.models.settings import get_embedding_client, get_supabase_client
|
||||
@ -253,21 +254,31 @@ async def create_stream_question_handler(
|
||||
f"Creating question for chat {chat_id} with brain {brain_id} of type {type(brain_id)}"
|
||||
)
|
||||
|
||||
rag_service = RAGService(
|
||||
current_user,
|
||||
brain_id,
|
||||
chat_id,
|
||||
brain_service,
|
||||
prompt_service,
|
||||
chat_service,
|
||||
knowledge_service,
|
||||
)
|
||||
maybe_send_telemetry("question_asked", {"streaming": True}, request)
|
||||
try:
|
||||
rag_service = RAGService(
|
||||
current_user,
|
||||
brain_id,
|
||||
chat_id,
|
||||
brain_service,
|
||||
prompt_service,
|
||||
chat_service,
|
||||
knowledge_service,
|
||||
)
|
||||
maybe_send_telemetry("question_asked", {"streaming": True}, request)
|
||||
|
||||
return StreamingResponse(
|
||||
rag_service.generate_answer_stream(chat_question.question),
|
||||
media_type="text/event-stream",
|
||||
)
|
||||
return StreamingResponse(
|
||||
rag_service.generate_answer_stream(chat_question.question),
|
||||
media_type="text/event-stream",
|
||||
)
|
||||
|
||||
except AssertionError:
|
||||
logger.error(f"assertion error request: {request}")
|
||||
raise HTTPException(
|
||||
status_code=422,
|
||||
detail="inprocessable entity",
|
||||
)
|
||||
except HTTPException as e:
|
||||
raise e
|
||||
|
||||
|
||||
# get chat history
|
||||
|
@ -2,6 +2,7 @@ import datetime
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
from langchain_community.chat_models import ChatLiteLLM
|
||||
|
||||
from quivr_api.logger import get_logger
|
||||
from quivr_api.models.settings import (
|
||||
get_embedding_client,
|
||||
@ -94,7 +95,8 @@ class RAGService:
|
||||
assert brain
|
||||
|
||||
if brain.integration:
|
||||
assert brain.integration.user_id == user_id
|
||||
# TODO: entity should be UUID
|
||||
assert brain.integration.user_id == str(user_id)
|
||||
return brain
|
||||
|
||||
def check_and_update_user_usage(self, user: UserIdentity, brain: BrainEntity):
|
||||
|
Loading…
Reference in New Issue
Block a user