Created
November 12, 2025 13:40
-
-
Save davidmezzetti/dbd31ae86e9cd0080164180c5564ae87 to your computer and use it in GitHub Desktop.
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
| from smolagents import WebSearchTool | |
| from txtai import LLM | |
| def webrag(query): | |
| prompt = f""" | |
| Answer the following question using ONLY the context below. | |
| Query: {query} | |
| Context: {search(query)} | |
| """ | |
| return llm(prompt, maxlength=8192, defaultrole="user", stripthink=True) | |
| search = WebSearchTool() | |
| llm = LLM("unsloth/gpt-oss-20b-GGUF/gpt-oss-20b-Q4_K_M.gguf", n_ctx=20000) | |
| webrag("Tell me about TxtAI") | |
| # '**TxtAI** is an open‑source, all‑in‑one AI framework designed for semantic search.... | |
| webrag("Who won the Patriots Bucs game? Show a reference link") | |
| # The New England Patriots defeated the Tampa Bay Buccaneers. | |
| # Reference: [ESPN box score – Patriots 28, Buccaneers 23 (Nov 9, 2025)](https://www.espn.com/nfl/boxscore/_/gameId/401772772) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment