Skip to content

Commit

Permalink
Added ollama embedder
Browse files Browse the repository at this point in the history
Added some documentation
  • Loading branch information
vodkar committed Nov 18, 2024
1 parent 819a829 commit db7ba85
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions cookbook/providers/ollama_tools/knowledge.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
"""Run `pip install duckduckgo-search sqlalchemy pgvector pypdf openai ollama` to install dependencies."""
"""
Run `pip install duckduckgo-search sqlalchemy pgvector pypdf openai ollama` to install dependencies.
Run Ollama Server: `ollama serve`
Pull required models:
`ollama pull openhermes`
`ollama pull llama3.1:8b`
If you haven't deployed database yet, run:
`docker run --rm -it -e POSTGRES_PASSWORD=ai -e POSTGRES_USER=ai -e POSTGRES_DB=ai -p 5532:5432 --name postgres pgvector/pgvector:pg17`
to deploy a PostgreSQL database.
"""

from phi.agent import Agent
from phi.model.ollama import OllamaTools
from phi.embedder.ollama import OllamaEmbedder
from phi.knowledge.pdf import PDFUrlKnowledgeBase
from phi.model.ollama import OllamaTools
from phi.vectordb.pgvector import PgVector

db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"

knowledge_base = PDFUrlKnowledgeBase(
urls=["https://phi-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"],
vector_db=PgVector(table_name="recipes", db_url=db_url),
vector_db=PgVector(
table_name="recipes",
db_url=db_url,
embedder=OllamaEmbedder(host="http://localhost:11434"),
),
)
knowledge_base.load(recreate=False) # Comment out after first run

Expand Down

0 comments on commit db7ba85

Please sign in to comment.