Skip to content

Instantly share code, notes, and snippets.

@Sumanth077
Created September 26, 2025 20:57
Show Gist options
  • Save Sumanth077/b4fc8fde4676058add235535cc92d232 to your computer and use it in GitHub Desktop.
Save Sumanth077/b4fc8fde4676058add235535cc92d232 to your computer and use it in GitHub Desktop.
Agent with a knowledge base.
from agno.knowledge.embedder.openai import OpenAIEmbedder
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.lancedb import LanceDb, SearchType
import nest_asyncio; nest_asyncio.apply()
embedder = OpenAIEmbedder(
id="openai/embed/models/text-embedding-ada-002",
api_key=os.environ["CLARIFAI_PAT"],
base_url="https://api.clarifai.com/v2/ext/openai/v1"
)
vector_db = LanceDb(
uri="tmp/lancedb",
table_name="thai_recipes",
search_type=SearchType.hybrid,
embedder=embedder,
)
knowledge_base = Knowledge(vector_db=vector_db)
knowledge_base.add_content(
url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"
)
agent = Agent(
model=OpenAILike(
id="openai/chat-completion/models/gpt-oss-120b",
api_key=os.environ["CLARIFAI_PAT"],
base_url="https://api.clarifai.com/v2/ext/openai/v1",
max_tokens=4096,
),
description="Thai cuisine expert powered by GPT-OSS 120B.",
instructions=[
"Search the knowledge base for Thai recipes first.",
"Use web search only if needed.",
],
knowledge=knowledge_base,
tools=[DuckDuckGoTools()],
markdown=True,
)
agent.print_response(
"How do I make chicken and galangal in coconut milk soup?",
markdown=True,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment