From f370670db1ab8cf0d2ad87c4615ea8e13c0e1d69 Mon Sep 17 00:00:00 2001 From: lenaxia Date: Wed, 22 May 2024 19:05:34 -0700 Subject: [PATCH] =?UTF-8?q?feat(JSON=20Response):=20Enable=20JSON=20Respon?= =?UTF-8?q?se=20format=20for=20all=20Openai=20Calls=E2=80=A6=20(#1401)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lenaxia Co-authored-by: Lenaxia --- memgpt/llm_api/llm_api_tools.py | 3 +++ memgpt/utils.py | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/memgpt/llm_api/llm_api_tools.py b/memgpt/llm_api/llm_api_tools.py index 59abc09e..fcea4ce2 100644 --- a/memgpt/llm_api/llm_api_tools.py +++ b/memgpt/llm_api/llm_api_tools.py @@ -159,6 +159,7 @@ def create( printd(f"Using model {llm_config.model_endpoint_type}, endpoint: {llm_config.model_endpoint}") # TODO eventually refactor so that credentials are passed through + credentials = MemGPTCredentials.load() if function_call and not functions: @@ -178,6 +179,7 @@ def create( tools=[{"type": "function", "function": f} for f in functions] if functions else None, tool_choice=function_call, user=str(user_id), + response_format={"type": "json_object"}, ) else: data = ChatCompletionRequest( @@ -186,6 +188,7 @@ def create( functions=functions, function_call=function_call, user=str(user_id), + response_format={"type": "json_object"}, ) if stream: diff --git a/memgpt/utils.py b/memgpt/utils.py index c7d84232..2b763295 100644 --- a/memgpt/utils.py +++ b/memgpt/utils.py @@ -36,9 +36,11 @@ from memgpt.constants import ( from memgpt.models.chat_completion_response import ChatCompletionResponse from memgpt.openai_backcompat.openai_object import OpenAIObject -# TODO: what is this? -# DEBUG = True DEBUG = False +if "LOG_LEVEL" in os.environ: + if os.environ["LOG_LEVEL"] == "DEBUG": + DEBUG = True + ADJECTIVE_BANK = [ "beautiful",