@cloudflare/ai package has been deprecated in favor of running AI requests directly via the workers bindings as described in https://developers.cloudflare.com/workers-ai/configuration/bindings/
getFormatInstructions when i'm home.{) would only work with the raw completions API, not the chat completions API.Tensor error: Unknown internal error: failed to decode u8
BAAI/bge-m3 ... but I'm not super picky...

runWithTools calls env.AI.run multiple times, and tool calls + tool responses are added to a temporary copy of the message history. The final response is (re)generated by calling env.AI.run one last time without passing any tools array. runWithTools or write your own to get the behavior you want. The implementation is (IMHO) kinda difficult to follow, though. I've written a tiny version (https://gist.github.com/Raylight-PWL/7487b4210e593e00fffcab4f7abe0189#file-3_runwithtoolsx-js) that might be easier, since the part about "embedded" is written as a separate usable component ("runEmbedded") and sounds close to what you want.import { StructuredOutputParser } from "@langchain/core/output_parsers";
const parser = StructuredOutputParser.fromZodSchema(generateFixSchema); Use the following analysis information to generate precise, non-redundant fixes:
Generate fixes following these guidelines:
1. ..........
2. ..........
3. ..........
4. ..........
addAttribute: This method is used to add an attribute to the element or override the existing attribute.
injectCss: This method is used to add style values to the element.
${parser.getFormatInstructions()}image one of
0 array
An array of integers that represent the image data constrained to 8-bit unsigned integer values
items number
A value between 0 and 255
1 string
Binary string representing the image contents.router.get('/fruitInfo2', async (req, env) => {
return runWithTools(env.AI, model, {
messages: [{
role: 'system',
content: `
The user message is a cryptic clue about a fruit.
Extract the name and shape of the fruit.
`
}, {
role: 'user',
content: 'garden of eden'
}],
tools: [{
name: 'fruitInfo',
description: 'Extract the fruit name and shape.',
parameters: {
type: 'object',
properties: {
name: {type: 'string', description: 'The name of the fruit'},
shape: {type: 'string', description: 'The shape of the fruit'}
},
required: ['name', 'shape']
},
function: ({name, shape}) => `Fruit is ${name} and shape is ${shape}`
}]
});
})runWithToolsrunWithToolsenv.AI.runenv.AI.run