Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #6797 Fireworks AI structured outputs #6802

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions litellm/llms/fireworks_ai/chat/fireworks_ai_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ def map_openai_params(
else:
# pass through the value of tool choice
optional_params["tool_choice"] = value
elif param == "response_format" and value.get("type", None) == "json_schema":
optional_params["response_format"] = {
"type": "json_object",
"schema": value['json_schema']['schema'],
}
elif param == "max_completion_tokens":
optional_params["max_tokens"] = value
elif param in supported_openai_params:
Expand Down
38 changes: 38 additions & 0 deletions tests/llm_translation/test_fireworks_ai_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,41 @@ def test_map_openai_params_tool_choice():
# Test case 4: tool_choice is None
result = fireworks.map_openai_params({"tool_choice": None}, {}, "some_model")
assert result == {"tool_choice": None}


def test_map_response_format():
response_format = {
'type': 'json_schema',
'json_schema': {
'schema': {
'properties': {
'result': {
'type': 'boolean'
}
},
'required': [
'result'
],
'type': 'object',
},
'name': 'BooleanResponse',
'strict': True
}
}
result = fireworks.map_openai_params({"response_format":response_format}, {}, "some_model")
assert result == {
"response_format" : {
'type': 'json_object',
'schema': {
'properties': {
'result': {
'type': 'boolean'
}
},
'required': [
'result'
],
'type': 'object',
},
}
}