mirror of
https://github.com/OMGeeky/gpt-pilot.git
synced 2026-02-23 15:49:50 +01:00
anthropic/claude-2 returns JSON
gpt-3_5 returns technologies such as "Backend: Node.js with Mongo database (Mongoose)" codellama throws an error due to missing `choices`
This commit is contained in:
@@ -19,7 +19,7 @@ def add_function_calls_to_request(gpt_data, function_calls: FunctionCallSet | No
|
||||
return
|
||||
|
||||
model: str = gpt_data['model']
|
||||
is_llama = 'llama' in model
|
||||
is_llama = 'llama' in model or 'anthropic' in model
|
||||
|
||||
# if model == 'gpt-4':
|
||||
# gpt_data['functions'] = function_calls['definitions']
|
||||
@@ -93,7 +93,7 @@ class JsonPrompter:
|
||||
(empty if the function doesn't exist or has no description)
|
||||
"""
|
||||
return [
|
||||
"Function description: " + function["description"]
|
||||
function["description"]
|
||||
for function in functions
|
||||
if function["name"] == function_to_call and "description" in function
|
||||
]
|
||||
@@ -131,8 +131,8 @@ class JsonPrompter:
|
||||
return "\n".join(
|
||||
self.function_descriptions(functions, function_to_call)
|
||||
+ [
|
||||
"Function parameters should follow this schema:",
|
||||
"```jsonschema",
|
||||
"The response should be a JSON object matching this schema:",
|
||||
"```json",
|
||||
self.function_parameters(functions, function_to_call),
|
||||
"```",
|
||||
]
|
||||
@@ -187,7 +187,8 @@ class JsonPrompter:
|
||||
if function_to_call is None
|
||||
else f"Define the arguments for {function_to_call} to answer the user's question."
|
||||
# ) + "\nYou must return a JSON object without notes or commentary."
|
||||
) + " \nIn your response you must only use JSON output and provide no explanation or commentary."
|
||||
# ) + " \nIn your response you must only use JSON output and provide no explanation or commentary."
|
||||
) + " \nThe response should contain only the JSON object, with no additional text or explanation."
|
||||
|
||||
data = (
|
||||
self.function_data(functions, function_to_call)
|
||||
|
||||
@@ -61,11 +61,11 @@ class TestLlmConnection:
|
||||
@pytest.mark.parametrize("endpoint, model", [
|
||||
("OPENAI", "gpt-4"), # role: system
|
||||
("OPENROUTER", "openai/gpt-3.5-turbo"), # role: user
|
||||
("OPENROUTER", "meta-llama/codellama-34b-instruct"), # rule: user, is_llama
|
||||
("OPENROUTER", "meta-llama/codellama-34b-instruct"), # rule: user, is_llama missed "choices"
|
||||
("OPENROUTER", "google/palm-2-chat-bison"), # role: user/system
|
||||
|
||||
# See https://github.com/1rgs/jsonformer-claude/blob/main/jsonformer_claude/main.py
|
||||
# ("OPENROUTER", "anthropic/claude-2"), # role: user, prompt 2
|
||||
("OPENROUTER", "anthropic/claude-2"), # role: user, prompt 2 - sometimes JSON, sometimes Python to generate JSON
|
||||
# ("OPENROUTER", "google/palm-2-codechat-bison"), # not working
|
||||
])
|
||||
def test_chat_completion_Architect(self, endpoint, model, monkeypatch):
|
||||
|
||||
Reference in New Issue
Block a user