|
@@ -3,17 +3,17 @@ import type { Message } from 'ollama'
|
|
|
|
|
|
async function main() {
|
|
async function main() {
|
|
|
|
|
|
- if (!process.env.OLLAMA_API_KEY) throw new Error('Set OLLAMA_API_KEY to use websearch tools')
|
|
|
|
|
|
+ if (!process.env.OLLAMA_API_KEY) throw new Error('Set OLLAMA_API_KEY to use web search tools')
|
|
|
|
|
|
const client = new Ollama({
|
|
const client = new Ollama({
|
|
headers: { Authorization: `Bearer ${process.env.OLLAMA_API_KEY}` },
|
|
headers: { Authorization: `Bearer ${process.env.OLLAMA_API_KEY}` },
|
|
})
|
|
})
|
|
|
|
|
|
// Tool schemas
|
|
// Tool schemas
|
|
- const websearchTool = {
|
|
|
|
|
|
+ const webSearchTool = {
|
|
type: 'function',
|
|
type: 'function',
|
|
function: {
|
|
function: {
|
|
- name: 'websearch',
|
|
|
|
|
|
+ name: 'webSearch',
|
|
description: 'Performs a web search for the given queries.',
|
|
description: 'Performs a web search for the given queries.',
|
|
parameters: {
|
|
parameters: {
|
|
type: 'object',
|
|
type: 'object',
|
|
@@ -33,10 +33,10 @@ async function main() {
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
|
|
- const webcrawlTool = {
|
|
|
|
|
|
+ const webCrawlTool = {
|
|
type: 'function',
|
|
type: 'function',
|
|
function: {
|
|
function: {
|
|
- name: 'webcrawl',
|
|
|
|
|
|
+ name: 'webCrawl',
|
|
description: 'Performs a web crawl for the given URLs.',
|
|
description: 'Performs a web crawl for the given URLs.',
|
|
parameters: {
|
|
parameters: {
|
|
type: 'object',
|
|
type: 'object',
|
|
@@ -53,11 +53,11 @@ async function main() {
|
|
}
|
|
}
|
|
|
|
|
|
const availableTools = {
|
|
const availableTools = {
|
|
- websearch: async (args: { queries: string[]; max_results?: number }) => {
|
|
|
|
- return await client.websearch(args)
|
|
|
|
|
|
+ webSearch: async (args: { queries: string[]; max_results?: number }) => {
|
|
|
|
+ return await client.webSearch(args)
|
|
},
|
|
},
|
|
- webcrawl: async (args: { urls: string[] }) => {
|
|
|
|
- return await client.webcrawl(args)
|
|
|
|
|
|
+ webCrawl: async (args: { urls: string[] }) => {
|
|
|
|
+ return await client.webCrawl(args)
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
|
|
@@ -74,7 +74,7 @@ async function main() {
|
|
const response = await client.chat({
|
|
const response = await client.chat({
|
|
model: 'gpt-oss',
|
|
model: 'gpt-oss',
|
|
messages: messages,
|
|
messages: messages,
|
|
- tools: [websearchTool, webcrawlTool],
|
|
|
|
|
|
+ tools: [webSearchTool, webCrawlTool],
|
|
stream: true,
|
|
stream: true,
|
|
think: true,
|
|
think: true,
|
|
})
|
|
})
|