Skip to content

Commit 8b2011a

Browse files
authored
Merge pull request #116 from fixie-ai/juberti/strict
Add strict mode for GPT and UV 0.3
2 parents 8c986fb + 5eaae65 commit 8b2011a

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

llm_benchmark.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
action="append",
4040
help="JSON file defining tools that can be used",
4141
)
42+
parser.add_argument(
43+
"--strict", action="store_true", help="Use strict mode when using tools"
44+
)
4245
parser.add_argument(
4346
"--model",
4447
"-m",

llm_benchmark_suite.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,9 @@ def _tools_models():
431431
_Llm(GPT_4O),
432432
_Llm(GPT_4O_MINI),
433433
_Llm(GPT_4_TURBO),
434+
_Llm(GPT_4O, GPT_4O + "-strict", strict=None),
435+
_Llm(GPT_4O_MINI, GPT_4O_MINI + "-strict", strict=None),
436+
_Llm(GPT_4_TURBO, GPT_4_TURBO + "-strict", strict=None),
434437
_Llm("claude-3-opus-20240229"),
435438
_Llm("claude-3-5-sonnet-20240620"),
436439
_Llm("claude-3-sonnet-20240229"),
@@ -476,7 +479,7 @@ def _audio_models():
476479
_Llm(GEMINI_1_5_PRO),
477480
_Llm(GEMINI_1_5_FLASH),
478481
_Llm(
479-
"fixie-ai/ultravox-v0.2",
482+
"fixie-ai/ultravox-v0.3",
480483
base_url="https://ultravox.api.fixie.ai/v1",
481484
api_key=os.getenv("ULTRAVOX_API_KEY"),
482485
),

llm_request.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class ApiContext:
8383
prompt: str
8484
files: List[InputFile]
8585
tools: List[Dict]
86+
strict: bool
8687
temperature: float
8788
max_tokens: int
8889
detail: Optional[str] = None
@@ -99,6 +100,7 @@ def __init__(self, session, index, name, func, args, prompt, files, tools):
99100
self.prompt = prompt
100101
self.files = files
101102
self.tools = tools
103+
self.strict = args.strict
102104
self.detail = args.detail
103105
self.temperature = args.temperature
104106
self.max_tokens = args.max_tokens
@@ -276,14 +278,19 @@ async def openai_chat(ctx: ApiContext, path: str = "/chat/completions") -> ApiRe
276278
url, headers = make_openai_url_and_headers(ctx, path)
277279
kwargs = {"messages": make_openai_messages(ctx)}
278280
if ctx.tools:
279-
kwargs["tools"] = ctx.tools
281+
tools = ctx.tools[:]
282+
if ctx.strict:
283+
for t in tools:
284+
t["function"]["strict"] = True
285+
t["function"]["parameters"]["additionalProperties"] = False
286+
kwargs["tools"] = tools
280287
kwargs["tool_choice"] = "required"
281288
if ctx.peft:
282289
kwargs["peft"] = ctx.peft
283290
# Some providers require opt-in for stream stats, but some providers don't like this opt-in.
284-
# Azure, ovh.net, and vLLM don't support stream stats at the moment.
291+
# Regardless of opt-in, Azure and ovh.net don't return stream stats at the moment.
285292
# See https://github.com/Azure/azure-rest-api-specs/issues/25062
286-
if not any(p in ctx.name for p in ["azure", "databricks", "fireworks", "ultravox"]):
293+
if not any(p in ctx.name for p in ["azure", "databricks", "fireworks"]):
287294
kwargs["stream_options"] = {"include_usage": True}
288295
data = make_openai_chat_body(ctx, **kwargs)
289296
return await post(ctx, url, headers, data, openai_chunk_gen)

media/tools/flights.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
},
1313
"date": {
1414
"type": "string",
15-
"format": "date",
1615
"description": "The date of the flight, e.g., 2024-06-17"
1716
}
1817
},

0 commit comments

Comments
 (0)