ソースを参照

renamed websearch/webcrawl to camelcase (#248)

nicole pardal 4 日 前
コミット
495cef8628
2 ファイル変更12 行追加12 行削除
  1. 10 10
      examples/websearch/websearch-tools.ts
  2. 2 2
      src/browser.ts

+ 10 - 10
examples/websearch/websearch-tools.ts

@@ -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,
     })
     })

+ 2 - 2
src/browser.ts

@@ -331,7 +331,7 @@ async encodeImage(image: Uint8Array | string): Promise<string> {
    * @returns {Promise<SearchResponse>} - The search results
    * @returns {Promise<SearchResponse>} - The search results
    * @throws {Error} - If the request is invalid or the server returns an error
    * @throws {Error} - If the request is invalid or the server returns an error
    */
    */
-  async websearch(request: SearchRequest): Promise<SearchResponse> {
+  async webSearch(request: SearchRequest): Promise<SearchResponse> {
     if (!request.queries || request.queries.length === 0) {
     if (!request.queries || request.queries.length === 0) {
       throw new Error('At least one query is required')
       throw new Error('At least one query is required')
     }
     }
@@ -348,7 +348,7 @@ async encodeImage(image: Uint8Array | string): Promise<string> {
    * @returns {Promise<CrawlResponse>} - The crawl results
    * @returns {Promise<CrawlResponse>} - The crawl results
    * @throws {Error} - If the request is invalid or the server returns an error
    * @throws {Error} - If the request is invalid or the server returns an error
    */
    */
-  async webcrawl(request: CrawlRequest): Promise<CrawlResponse> {
+  async webCrawl(request: CrawlRequest): Promise<CrawlResponse> {
     if (!request.urls || request.urls.length === 0) {
     if (!request.urls || request.urls.length === 0) {
       throw new Error('At least one URL is required')
       throw new Error('At least one URL is required')
     }
     }