ollama - 💡(How to fix) Fix WebSearch as a CLI? [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#14801Fetched 2026-04-08 00:43:19
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1
RAW_BUFFERClick to expand / collapse

Can we add websearch as a CLI command? I'm thinking agents like OpenCode can use it out of the box without any MCP setup.

extent analysis

Fix Plan

To add a websearch CLI command, we can create a new function that handles the search query and returns the results.

Implementation Steps

  • Create a new Python file websearch.py with the following code:
import argparse
import webbrowser

def websearch(query):
    url = f"https://www.google.com/search?q={query}"
    webbrowser.open(url)

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Web search CLI command")
    parser.add_argument("query", help="Search query")
    args = parser.parse_args()
    websearch(args.query)
  • Add the websearch command to the CLI interface:
import subprocess

def cli_websearch(query):
    subprocess.run(["python", "websearch.py", query])
  • Integrate the cli_websearch function with the existing CLI framework.

Verification

To verify the fix, run the websearch command with a test query:

$ websearch "example search query"

This should open a web browser with the search results.

Extra Tips

  • Consider adding error handling for cases where the search query is empty or invalid.
  • You can also add support for other search engines by modifying the websearch function to accept a --engine option.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

ollama - 💡(How to fix) Fix WebSearch as a CLI? [1 participants]