Skip to content

Commit 19fa3fe

Browse files
author
ochafik
committed
openai tools: TS signatures work well too at a fraction of the eval cost
1 parent 588dc89 commit 19fa3fe

File tree

2 files changed

+159
-633
lines changed

2 files changed

+159
-633
lines changed

examples/openai/prompting.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,8 @@ def __init__(self, args: ChatHandlerArgs, parallel_calls: bool):
608608
content='\n'.join([
609609
'You are a function calling AI model.',
610610
'Here are the tools available:',
611-
_tools_schema_signatures(self.args.tools, indent=2),
611+
# _tools_schema_signatures(self.args.tools, indent=2),
612+
_tools_typescript_signatures(self.args.tools),
612613
_please_respond_with_schema(
613614
_make_bespoke_schema(
614615
response_schema,
@@ -713,9 +714,10 @@ def get_chat_handler(args: ChatHandlerArgs, parallel_calls: bool, tool_style: Op
713714

714715
_ts_converter = SchemaToTypeScriptConverter()
715716

717+
# os.environ.get('NO_TS')
716718
def _please_respond_with_schema(schema: dict) -> str:
717-
sig = json.dumps(schema, indent=2)
718-
# sig = _ts_converter.visit(schema)
719+
# sig = json.dumps(schema, indent=2)
720+
sig = _ts_converter.visit(schema)
719721
return f'Please respond in JSON format with the following schema: {sig}'
720722

721723
def _tools_typescript_signatures(tools: list[Tool]) -> str:

0 commit comments

Comments
 (0)