see i got this error - Error code: 404 - {‘error’: {‘message’: ‘The model gpt-4o
does not exist or you do not have access to it.’, ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: ‘model_not_found’}}
Even if i am selecting to use gemini embeddings , but still my code is selecting gpt-4 ??
import typer
from typing import Optional, List
from phi.assistant import Assistant
from phi.storage.assistant.postgres import PgAssistantStorage
from phi.knowledge.pdf import PDFUrlKnowledgeBase
from phi.vectordb.pgvector import PgVector2
from phi.embedder.google import GeminiEmbedder # Import GeminiEmbedder
from phi.model.google import Gemini
import os
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
# Set the necessary API key for Gemini
os.environ["GOOGLE_API_KEY"] = os.getenv("GOOGLE_API_KEY")
# Database connection URL
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
# Initialize the Gemini embedder
gemini_embedder = GeminiEmbedder(
api_key=os.getenv("GOOGLE_API_KEY"), # Pass the API key explicitly
model="models/text-embedding-004", # Default model
dimensions=768 # Default dimensions
)
# Configure the knowledge base to use the Gemini embedder
knowledge_base = PDFUrlKnowledgeBase(
urls=["https://phi-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"],
vector_db=PgVector2(
collection="recipes",
db_url=db_url,
embedder=gemini_embedder # Use GeminiEmbedder for embeddings
)
)
# Load the knowledge base
knowledge_base.load()
# Initialize storage for the assistant
storage = PgAssistantStorage(table_name="pdf_assistant", db_url=db_url)
def pdf_assistant(new: bool = False, user: str = "user"):
run_id: Optional[str] = None
if not new:
existing_run_ids: List[str] = storage.get_all_run_ids(user)
if len(existing_run_ids) > 0:
run_id = existing_run_ids[0]
# Create the Assistant instance
assistant = Assistant(
run_id=run_id,
user_id=user,
knowledge_base=knowledge_base,
storage=storage,
# Show tool calls in the response
show_tool_calls=True,
# Enable the assistant to search the knowledge base
search_knowledge=True,
# Enable the assistant to read the chat history
read_chat_history=True,
model="models/text-embedding-004"
)
if run_id is None:
run_id = assistant.run_id
print(f"Started Run: {run_id}\n")
else:
print(f"Continuing Run: {run_id}\n")
assistant.cli_app(markdown=True)
if __name__ == "__main__":
typer.run(pdf_assistant)