Skip to content

Commit

Permalink
agent: revert to json schemas (ts not ready for refs)
Browse files Browse the repository at this point in the history
  • Loading branch information
ochafik committed Apr 9, 2024
1 parent 084470f commit 38329c8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions examples/openai/prompting.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,8 @@ def __init__(self, args: ChatHandlerArgs, parallel_calls: bool):
content='\n'.join([
'You are a function calling AI model.',
'Here are the tools available:',
# _tools_schema_signatures(self.args.tools, indent=2),
_tools_typescript_signatures(self.args.tools),
_tools_schema_signatures(self.args.tools, indent=2),
# _tools_typescript_signatures(self.args.tools),
_please_respond_with_schema(
_make_bespoke_schema(
response_schema,
Expand Down Expand Up @@ -714,16 +714,16 @@ def get_chat_handler(args: ChatHandlerArgs, parallel_calls: bool, tool_style: Op

# os.environ.get('NO_TS')
def _please_respond_with_schema(schema: dict) -> str:
# sig = json.dumps(schema, indent=2)
_ts_converter = SchemaToTypeScriptConverter()
_ts_converter.resolve_refs(schema, 'schema')
sig = _ts_converter.visit(schema)
sig = json.dumps(schema, indent=2)
# _ts_converter = SchemaToTypeScriptConverter()
# # _ts_converter.resolve_refs(schema, 'schema')
# sig = _ts_converter.visit(schema)
return f'Please respond in JSON format with the following schema: {sig}'

def _tools_typescript_signatures(tools: list[Tool]) -> str:
_ts_converter = SchemaToTypeScriptConverter()
for tool in tools:
_ts_converter.resolve_refs(tool.function.parameters, tool.function.name)
# for tool in tools:
# _ts_converter.resolve_refs(tool.function.parameters, tool.function.name)

return 'namespace functions {\n' + '\n'.join(
'// ' + tool.function.description.replace('\n', '\n// ') + '\n' + ''
Expand Down

0 comments on commit 38329c8

Please sign in to comment.