import { runWithTools } from '@cloudflare/ai-utils';
router.get('/ai', async (req, env) => {
const fruit = ({fruit}) => {
console.log(fruit);
switch(fruit) {
case 'orange': return '*******';
}
};
return await runWithTools(
env.AI,
'@hf/nousresearch/hermes-2-pro-mistral-7b',
{
messages: [
{
role: 'user',
content: 'Discern the following fruit: shares its name with a colour, is juicy, and is citrus.',
},
],
tools: [
{
name: 'fruit',
description: `Output the user's favourite fruit`,
parameters: {
type: 'object',
properties: {
fruit: { type: 'fruit', description: `the user's favourite fruit` },
},
required: ['fruit'],
},
function: fruit,
},
],
}
);
});
import { runWithTools } from '@cloudflare/ai-utils';
router.get('/ai', async (req, env) => {
const fruit = ({fruit}) => {
console.log(fruit);
switch(fruit) {
case 'orange': return '*******';
}
};
return await runWithTools(
env.AI,
'@hf/nousresearch/hermes-2-pro-mistral-7b',
{
messages: [
{
role: 'user',
content: 'Discern the following fruit: shares its name with a colour, is juicy, and is citrus.',
},
],
tools: [
{
name: 'fruit',
description: `Output the user's favourite fruit`,
parameters: {
type: 'object',
properties: {
fruit: { type: 'fruit', description: `the user's favourite fruit` },
},
required: ['fruit'],
},
function: fruit,
},
],
}
);
});