feat: add api brain steps log (backend) (#1705)

Issue https://github.com/StanGirard/quivr/issues/1697
This commit is contained in:
Mamadou DICKO 2023-11-24 14:58:33 +01:00 committed by GitHub
parent 65a4057272
commit 65e656f04e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 7 deletions

View File

@ -52,6 +52,8 @@ class APIBrainQA(
functions,
brain_id: UUID,
):
yield "🧠<Deciding what to do>🧠"
response = completion(
model=self.model,
temperature=self.temperature,
@ -87,12 +89,19 @@ class APIBrainQA(
arguments = json.loads(function_call["arguments"])
except Exception:
arguments = {}
yield f"🧠<Calling API with arguments {arguments} and brain id {brain_id}>🧠"
try:
api_call_response = call_brain_api(
brain_id=brain_id,
user_id=self.user_id,
arguments=arguments,
)
except Exception as e:
raise HTTPException(
status_code=400,
detail=f"Error while calling API: {e}",
)
messages.append(
{
@ -182,7 +191,11 @@ class APIBrainQA(
streamed_chat_history.assistant = value
response_tokens.append(value)
yield f"data: {json.dumps(streamed_chat_history.dict())}"
response_tokens = [
token
for token in response_tokens
if not token.startswith("🧠<") and not token.endswith(">🧠")
]
update_message_by_id(
message_id=str(streamed_chat_history.message_id),
user_message=question.question,

View File

@ -72,7 +72,7 @@ export const KnowledgeToFeed = ({
<KnowledgeToFeedInput feedBrain={() => void feedBrain()} />
)}
{Boolean(currentBrainId) && (
<Link href={`brains-management/${currentBrainId ?? ""}`}>
<Link href={`/brains-management/${currentBrainId ?? ""}`}>
<Button variant={"tertiary"}>
{t("manage_brain", { ns: "brain" })}
</Button>