Skip to content

Instantly share code, notes, and snippets.

@Dhravya
Created July 1, 2024 18:20
Show Gist options
  • Save Dhravya/38d1f86fcd0e2165eb7daa6424353ed8 to your computer and use it in GitHub Desktop.
Save Dhravya/38d1f86fcd0e2165eb7daa6424353ed8 to your computer and use it in GitHub Desktop.
await runWithTools(env.AI, "@hf/nousresearch/hermes-2-pro-mistral-7b", {
messages: [
{ role: "system", content: "Put user given values in KV" },
{ role: "user", content: prompt },
],
tools: [
{
name: "KV update",
description: "Update a key-value pair in the database",
parameters: {
type: "object",
properties: {
key: {
type: "string",
description: "The key to update",
},
value: {
type: "string",
description: "The value to update",
},
},
required: ["key", "value"],
},
async function({ key, value }) {
const response = await env.KV.put(key, value);
return `Successfully updated key-value pair in database: ${response}`;
},
},
],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment