Skip to content

Commit

Permalink
doc: add example function calling requests
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelDeimos committed Jan 24, 2025
1 parent aae18e6 commit db9597a
Showing 1 changed file with 77 additions and 1 deletion.
78 changes: 77 additions & 1 deletion src/backend/src/modules/puterai/doc/requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,80 @@ URL.createObjectURL(await (await fetch("http://api.puter.localhost:4100/drivers/
}),
"method": "POST",
})).blob());
```
```

### Tool Use

```javascript
await puter.ai.chat('What\'s the weather like in Vancouver?', {
tools: [
{
type: 'function',
'function': {
name: 'get_weather',
description: 'A string describing the weather',
parameters: {
type: 'object',
properties: {
location: {
type: 'string',
description: 'city',
},
},
required: ['location'],
additionalProperties: false,
},
strict: true
},
}
]
})
```

```javascript
await puter.ai.chat([
{ content: `What's the weather like in Vancouver?` },
{
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_vcfEOmDczXq7KGMirPGGiNEe",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"location\":\"Vancouver\"}"
}
}
],
"refusal": null
},
{
role: 'tool',
tool_call_id: 'call_vcfEOmDczXq7KGMirPGGiNEe',
content: 'Sunny with a chance of rain'
},
], {
tools: [
{
type: 'function',
'function': {
name: 'get_weather',
description: 'A string describing the weather',
parameters: {
type: 'object',
properties: {
location: {
type: 'string',
description: 'city',
},
},
required: ['location'],
additionalProperties: false,
},
strict: true
},
}
]
})
```

0 comments on commit db9597a

Please sign in to comment.