Abobaker khaled
Abobaker khaled

Reputation: 43

integrating llama index and pgvector

I am trying to integrate OpenAI's language model and embedding capabilities into a Django-based project. It connects to a PostgreSQL database (configured with vector extensions).

# Configuration Variables
LLM_MODEL = config("LLM_MODEL", default="gpt-4o")  
EMEDDING_LENGTH = config("EMEDDING_LENGTH_OPENAI", default=1536, cast=int)  
EMEDDING_MODEL = config("EMEDDING_MODEL_OPENAI", default="text-embedding-3-small")  
OPENAI_API_KEY = config("OPENAI_API_KEY")

llm = OpenAI(model=LLM_MODEL, api_key=OPENAI_API_KEY)
embed_model = OpenAIEmbedding(model=EMEDDING_MODEL, api_key=OPENAI_API_KEY)
from llama_index.core import Settings

Settings.llm = llm
Settings.embed_model = embed_model
from llama_index.core import VectorStoreIndex, StorageContext

storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex.from_vector_store(vector_store, storage_context=storage_context)
query_engine = index.as_query_engine()

and when trying to make a query

query_engine.query("My query")

it gives me this error Retrying llama_index.embeddings.openai.base.get_embedding in 0.07374163030877656 seconds as it raised RateLimitError: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}}.

I am trying to search for a way to make the calling and the requests to the OpenAI API key sufficient but I can't do that!

Upvotes: 0

Views: 95

Answers (0)

Related Questions