Skip to content

fix(browser): transform maxResults to max_results for WebSearch API#284

Open
abdelhadi703 wants to merge 1 commit into
ollama:mainfrom
abdelhadi703:fix/websearch-maxresults-parameter
Open

fix(browser): transform maxResults to max_results for WebSearch API#284
abdelhadi703 wants to merge 1 commit into
ollama:mainfrom
abdelhadi703:fix/websearch-maxresults-parameter

Conversation

@abdelhadi703

Copy link
Copy Markdown

Summary

The WebSearchRequest interface uses camelCase (maxResults), but the Ollama /api/web_search endpoint expects snake_case (max_results). The spread operator was passing the wrong parameter name.

Problem

// Interface
export interface WebSearchRequest {
  query: string
  maxResults?: number  // camelCase
}

// API expects
POST /api/web_search { "query": "...", "max_results": 10 }  // snake_case

The previous code used { ...request } which sent maxResults instead of max_results.

Solution

Explicitly map the request parameters to the correct API parameter names:

const apiRequest: Record<string, unknown> = {
  query: request.query,
}
if (request.maxResults !== undefined) {
  apiRequest.max_results = request.maxResults
}

Fixes #283

The WebSearchRequest interface uses camelCase (maxResults), but the
Ollama API expects snake_case (max_results). The spread operator
was passing the wrong parameter name to the API.

This fix explicitly maps the request parameters to the correct API
parameter names, ensuring max_results is sent instead of maxResults.

Fixes ollama#283

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The maxResults parameter of WebSearchRequest does not match the actual request parameters

1 participant