Skip to content

Instantly share code, notes, and snippets.

@therealkenc
Last active January 1, 2025 08:29
Show Gist options
  • Save therealkenc/b19ad90285eb38eb596ec4869941abb2 to your computer and use it in GitHub Desktop.
Save therealkenc/b19ad90285eb38eb596ec4869941abb2 to your computer and use it in GitHub Desktop.
> [email protected] debug:tools
> ts-node -r tsconfig-paths/register examples/tool-call-helpers.ts
Starting main function...
(node:219045) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
OUTGOING REQUEST: POST https://generativelanguage.googleapis.com/v1beta/openai/chat/completions
Request body: {
"model": "gemini-2.0-flash-exp",
"tools": [
{
"type": "function",
"function": {
"name": "time",
"parameters": {
"type": "object",
"properties": {
"timezone": {
"type": "string",
"description": "The IANA timezone identifier, eg: America/New_York"
}
}
},
"description": "function to return the for a given timezone"
}
}
],
"messages": [
{
"role": "system",
"content": "Use the time() function when asked the time"
},
{
"role": "user",
"content": "What time is it in New York?"
}
],
"tool_choice": "auto",
"stream": true
}
INCOMING RESPONSE (raw): 200
Response body: data: {"choices":[{"delta":{"role":"assistant","toolCalls":[{"function":{"arguments":"{\"timezone\":\"America/New_York\"}","name":"time"},"id":"0","type":"function"}]},"index":0}],"created":1735719993,"model":"gemini-2.0-flash-exp","object":"chat.completion.chunk"}
data: {"choices":[{"delta":{"role":"assistant"},"finishReason":"stop","index":0}],"created":1735719993,"model":"gemini-2.0-flash-exp","object":"chat.completion.chunk"}
data: [DONE]
Received message: {
"role": "assistant",
"content": null,
"refusal": null,
"tool_calls": [
{
"id": "0",
"type": "function",
"function": {
"name": "time",
"arguments": "{\"timezone\":\"America/New_York\"}"
}
}
],
"parsed": null
}
functionCall { name: 'time', arguments: '{"timezone":"America/New_York"}' }
Received message: {
"role": "tool",
"tool_call_id": "0",
"content": "{\"time\":\"1/1/2025, 3:26:33 AM\"}"
}
functionCallResult {"time":"1/1/2025, 3:26:33 AM"}
OUTGOING REQUEST: POST https://generativelanguage.googleapis.com/v1beta/openai/chat/completions
Request body: {
"model": "gemini-2.0-flash-exp",
"tools": [
{
"type": "function",
"function": {
"name": "time",
"parameters": {
"type": "object",
"properties": {
"timezone": {
"type": "string",
"description": "The IANA timezone identifier, eg: America/New_York"
}
}
},
"description": "function to return the for a given timezone"
}
}
],
"messages": [
{
"role": "system",
"content": "Use the time() function when asked the time"
},
{
"role": "user",
"content": "What time is it in New York?"
},
{
"role": "assistant",
"content": null,
"refusal": null,
"tool_calls": [
{
"id": "0",
"type": "function",
"function": {
"name": "time",
"arguments": "{\"timezone\":\"America/New_York\"}"
}
}
],
"parsed": null
},
{
"role": "tool",
"tool_call_id": "0",
"content": "{\"time\":\"1/1/2025, 3:26:33 AM\"}"
}
],
"tool_choice": "auto",
"stream": true
}
INCOMING RESPONSE: 400
Response body: [
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
]
/home/ken/Devel/openai-node/src/error.ts:72
return new BadRequestError(status, error, message, headers);
^
BadRequestError: 400 status code (no body)
at Function.generate (/home/ken/Devel/openai-node/src/error.ts:72:14)
at OpenAI.makeStatusError (/home/ken/Devel/openai-node/src/core.ts:435:21)
at OpenAI.makeRequest (/home/ken/Devel/openai-node/src/core.ts:499:24)
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at async ChatCompletionStreamingRunner._createChatCompletion (/home/ken/Devel/openai-node/src/lib/ChatCompletionStream.ts:383:20)
at async ChatCompletionStreamingRunner._runTools (/home/ken/Devel/openai-node/src/lib/AbstractChatCompletionRunner.ts:418:46) {
status: 400,
headers: {
'alt-svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000',
connection: 'close',
'content-encoding': 'gzip',
'content-type': 'application/json; charset=UTF-8',
date: 'Wed, 01 Jan 2025 08:26:34 GMT',
server: 'scaffolding on HTTPServer2',
'server-timing': 'gfet4t7; dur=37',
'transfer-encoding': 'chunked',
vary: 'Origin, X-Origin, Referer',
'x-content-type-options': 'nosniff',
'x-frame-options': 'SAMEORIGIN',
'x-xss-protection': '0'
},
request_id: undefined,
error: undefined,
code: undefined,
param: undefined,
type: undefined
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment