mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
fix(docs): add missing default values to OpenAPI spec
Added explicit default values for parameters that have defined defaults in proxy implementation. Improves API clarity and DX. No runtime behavior changes.
This commit is contained in:
parent
58120537af
commit
e30a3abf3a
2 changed files with 82 additions and 6 deletions
|
|
@ -70,19 +70,23 @@
|
|||
},
|
||||
"temperature": {
|
||||
"type": "number",
|
||||
"description": "The sampling temperature to be used"
|
||||
"description": "The sampling temperature to be used",
|
||||
"default": 1
|
||||
},
|
||||
"top_p": {
|
||||
"type": "number",
|
||||
"description": "An alternative to sampling with temperature"
|
||||
"description": "An alternative to sampling with temperature",
|
||||
"default": 1
|
||||
},
|
||||
"n": {
|
||||
"type": "integer",
|
||||
"description": "The number of chat completion choices to generate for each input message"
|
||||
"description": "The number of chat completion choices to generate for each input message",
|
||||
"default": 1
|
||||
},
|
||||
"stream": {
|
||||
"type": "boolean",
|
||||
"description": "If set to true, it sends partial message deltas"
|
||||
"description": "If set to true, it sends partial message deltas",
|
||||
"default": false
|
||||
},
|
||||
"stop": {
|
||||
"type": "array",
|
||||
|
|
@ -97,11 +101,13 @@
|
|||
},
|
||||
"presence_penalty": {
|
||||
"type": "number",
|
||||
"description": "It is used to penalize new tokens based on their existence in the text so far"
|
||||
"description": "It is used to penalize new tokens based on their existence in the text so far",
|
||||
"default": 0
|
||||
},
|
||||
"frequency_penalty": {
|
||||
"type": "number",
|
||||
"description": "It is used to penalize new tokens based on their frequency in the text so far"
|
||||
"description": "It is used to penalize new tokens based on their frequency in the text so far",
|
||||
"default": 0
|
||||
},
|
||||
"logit_bias": {
|
||||
"type": "object",
|
||||
|
|
|
|||
|
|
@ -140,3 +140,73 @@ class TestCredentialEndpointsOpenAPISchema:
|
|||
assert "credential_name" in sig.parameters, (
|
||||
"get_credential_by_name must have a credential_name parameter"
|
||||
)
|
||||
|
||||
|
||||
class TestOpenAPISpecDefaultValues:
|
||||
"""Test that the static openapi.json has correct default values for chat completion parameters."""
|
||||
|
||||
@pytest.fixture
|
||||
def openapi_spec(self):
|
||||
"""Load the static openapi.json spec."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
spec_path = (
|
||||
Path(__file__).parents[3] / "litellm" / "proxy" / "openapi.json"
|
||||
)
|
||||
with open(spec_path) as f:
|
||||
return json.load(f)
|
||||
|
||||
def test_temperature_has_default(self, openapi_spec):
|
||||
"""temperature should have default value 1."""
|
||||
props = (
|
||||
openapi_spec["paths"]["/chat/completions"]["post"]["requestBody"]
|
||||
["content"]["application/json"]["schema"]["properties"]
|
||||
)
|
||||
assert "default" in props["temperature"]
|
||||
assert props["temperature"]["default"] == 1
|
||||
|
||||
def test_top_p_has_default(self, openapi_spec):
|
||||
"""top_p should have default value 1."""
|
||||
props = (
|
||||
openapi_spec["paths"]["/chat/completions"]["post"]["requestBody"]
|
||||
["content"]["application/json"]["schema"]["properties"]
|
||||
)
|
||||
assert "default" in props["top_p"]
|
||||
assert props["top_p"]["default"] == 1
|
||||
|
||||
def test_n_has_default(self, openapi_spec):
|
||||
"""n should have default value 1."""
|
||||
props = (
|
||||
openapi_spec["paths"]["/chat/completions"]["post"]["requestBody"]
|
||||
["content"]["application/json"]["schema"]["properties"]
|
||||
)
|
||||
assert "default" in props["n"]
|
||||
assert props["n"]["default"] == 1
|
||||
|
||||
def test_stream_has_default(self, openapi_spec):
|
||||
"""stream should have default value false."""
|
||||
props = (
|
||||
openapi_spec["paths"]["/chat/completions"]["post"]["requestBody"]
|
||||
["content"]["application/json"]["schema"]["properties"]
|
||||
)
|
||||
assert "default" in props["stream"]
|
||||
assert props["stream"]["default"] is False
|
||||
|
||||
def test_presence_penalty_has_default(self, openapi_spec):
|
||||
"""presence_penalty should have default value 0."""
|
||||
props = (
|
||||
openapi_spec["paths"]["/chat/completions"]["post"]["requestBody"]
|
||||
["content"]["application/json"]["schema"]["properties"]
|
||||
)
|
||||
assert "default" in props["presence_penalty"]
|
||||
assert props["presence_penalty"]["default"] == 0
|
||||
|
||||
def test_frequency_penalty_has_default(self, openapi_spec):
|
||||
"""frequency_penalty should have default value 0."""
|
||||
props = (
|
||||
openapi_spec["paths"]["/chat/completions"]["post"]["requestBody"]
|
||||
["content"]["application/json"]["schema"]["properties"]
|
||||
)
|
||||
assert "default" in props["frequency_penalty"]
|
||||
assert props["frequency_penalty"]["default"] == 0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue