From 82ba3dc9ab8d649bf2732e36547b0120b7ea84a5 Mon Sep 17 00:00:00 2001 From: yashbonde Date: Tue, 10 Oct 2023 19:43:53 +0530 Subject: [PATCH] [chore] convert response to JSON not string --- cf_internal | 2 +- server/chainfury_server/api/prompts.py | 7 +++---- server/chainfury_server/engines/fury.py | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cf_internal b/cf_internal index a38f5c15..f653bdf3 160000 --- a/cf_internal +++ b/cf_internal @@ -1 +1 @@ -Subproject commit a38f5c150e1a8da8642092bbbd692675ecfe7b8a +Subproject commit f653bdf3c9d636f8911f19e668c433dc4d5134ec diff --git a/server/chainfury_server/api/prompts.py b/server/chainfury_server/api/prompts.py index 139a650e..aabb069b 100644 --- a/server/chainfury_server/api/prompts.py +++ b/server/chainfury_server/api/prompts.py @@ -8,7 +8,7 @@ from typing import Annotated, Any, Tuple, Dict from pydantic import BaseModel from sqlalchemy.orm import Session -from dataclasses import dataclass +from dataclasses import dataclass, asdict from chainfury_server.schemas.prompt_schema import PromptBody from chainfury_server.commons.utils import get_user_from_jwt, verify_user @@ -101,9 +101,8 @@ def _get_streaming_response(result): content=_get_streaming_response(result), ) else: - out = result.__dict__ - out.pop("prompt") - return out + # out = result.__dict__ + return result.to_dict() class InternalFeedbackModel(BaseModel): diff --git a/server/chainfury_server/engines/fury.py b/server/chainfury_server/engines/fury.py index 023082ab..4d282d1d 100644 --- a/server/chainfury_server/engines/fury.py +++ b/server/chainfury_server/engines/fury.py @@ -1,4 +1,5 @@ import time +import json import traceback from pprint import pprint, pformat from functools import partial @@ -34,7 +35,7 @@ def run(self, chatbot: ChatBot, prompt: PromptBody, db: Session, start: float) - callback = FuryThoughts(db, prompt_row.id) mainline_out, full_ir = chain(prompt.new_message, thoughts_callback=callback, print_thoughts=False) result = CFPromptResult( - result=str(mainline_out), + result=json.dumps(mainline_out), thought=[{"engine": "fury", "ir_steps": callback.count, "thoughts": list(full_ir.keys())}], num_tokens=1, prompt=prompt_row,