mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-14 17:03:29 +03:00
feat: add api brain steps log (backend) (#1705)
Issue https://github.com/StanGirard/quivr/issues/1697
This commit is contained in:
parent
65a4057272
commit
65e656f04e
@ -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}>🧠"
|
||||
|
||||
api_call_response = call_brain_api(
|
||||
brain_id=brain_id,
|
||||
user_id=self.user_id,
|
||||
arguments=arguments,
|
||||
)
|
||||
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,
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user