Created
September 19, 2025 11:45
-
-
Save remorses/9255e4f120cf47497173fc21a06a9263 to your computer and use it in GitHub Desktop.
Google web search for opencode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { tool } from "@opencode-ai/plugin"; | |
| import { createGoogleGenerativeAI } from "@ai-sdk/google"; | |
| import { generateText } from "ai"; | |
| const google = createGoogleGenerativeAI({ | |
| apiKey: process.env.GEMINI_API_KEY!, | |
| }); | |
| export default tool({ | |
| description: "Search for something in the internet", | |
| args: { | |
| query: tool.schema.string().describe("Keyword or phrase to search for"), | |
| }, | |
| async execute(args) { | |
| const { text } = await generateText({ | |
| model: google("gemini-2.5-flash"), | |
| tools: { | |
| google_search: google.tools.googleSearch({}), | |
| }, | |
| prompt: `Search the web for "${args.query}". Summarize in concise bullets points. Include code snippets. The search results will be used by a coding agent, so provide example usage implementation for code.`, | |
| }); | |
| return text; | |
| }, | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment