From 33da359c6d22678223a61da74841544be6ada2c7 Mon Sep 17 00:00:00 2001 From: HardAndHeavy Date: Sun, 1 Dec 2024 01:10:27 +0300 Subject: [PATCH 1/2] Remove back quotes when receiving a function response --- blueprints/function_calling_blueprint.py | 1 + 1 file changed, 1 insertion(+) diff --git a/blueprints/function_calling_blueprint.py b/blueprints/function_calling_blueprint.py index f4739b06..0390ed56 100644 --- a/blueprints/function_calling_blueprint.py +++ b/blueprints/function_calling_blueprint.py @@ -168,6 +168,7 @@ def run_completion(self, system_prompt: str, content: str) -> dict: response = r.json() content = response["choices"][0]["message"]["content"] + content = content[content.find('{'):content.rfind('}') + 1] # Parse the function response if content != "": From 3af8b1310f239be17be63f4fa35ec71aa78d1c13 Mon Sep 17 00:00:00 2001 From: HardAndHeavy Date: Mon, 2 Dec 2024 01:24:43 +0300 Subject: [PATCH 2/2] Add getting a TEMPLATE from an environment variable --- blueprints/function_calling_blueprint.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blueprints/function_calling_blueprint.py b/blueprints/function_calling_blueprint.py index 0390ed56..ae20b13d 100644 --- a/blueprints/function_calling_blueprint.py +++ b/blueprints/function_calling_blueprint.py @@ -62,7 +62,7 @@ def __init__(self, prompt: str | None = None) -> None: ), "OPENAI_API_KEY": os.getenv("OPENAI_API_KEY", "YOUR_OPENAI_API_KEY"), "TASK_MODEL": os.getenv("TASK_MODEL", "gpt-3.5-turbo"), - "TEMPLATE": """Use the following context as your learned knowledge, inside XML tags. + "TEMPLATE": os.getenv("TEMPLATE", """Use the following context as your learned knowledge, inside XML tags. {{CONTEXT}} @@ -71,7 +71,7 @@ def __init__(self, prompt: str | None = None) -> None: - If you don't know, just say that you don't know. - If you don't know when you are not sure, ask for clarification. Avoid mentioning that you obtained the information from the context. -And answer according to the language of the user's question.""", +And answer according to the language of the user's question."""), } )