-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question]: How do I access a raptor pack variable that I created later on? #13540
Comments
Hey there, @sohilbhatia! Fancy seeing you here again. 😄 Looks like you've got another intriguing puzzle for us. Let me dive into the depths of |
Assuming you already created the index once, you can do raptor_pack = RaptorPack(
[],
embed_model=OpenAIEmbedding(
model="text-embedding-3-small"
), # used for embedding clusters
llm=OpenAI(model="gpt-3.5-turbo", temperature=0.1), # used for generating summaries
vector_store=vector_store, # used for storage
similarity_top_k=8, # top k for each layer, or overall top-k for collapsed
mode="collapsed", # sets default mode
transformations=[
SentenceSplitter(chunk_size=400, chunk_overlap=50)
], # transformations applied for ingestion
)
query_engine = RetrieverQueryEngine.from_args(raptor_pack.retriever, llm=OpenAI(model="gpt-3.5-turbo",
temperature=0.1)) Notice an empty list was passed in for documents. This should basically end up being a no-op, so its fine to run this whenever needed If you wanted, you can also import and use the from llama_index.packs.raptor import RaptorRetriever
retriever = RaptorRetriever(
[],
embed_model=embed_model,
llm=llm,
similarity_top_k=similarity_top_k,
vector_store=vector_store,
mode=mode,
verbose=verbose,
transformations=transformations,
) |
To access and utilize the
from flask import Flask
from llama_index.packs.raptor import RaptorPack
app = Flask(__name__)
with app.app_context():
app.raptor_pack = RaptorPack()
from flask import current_app
@app.route('/use_raptor')
def use_raptor():
raptor_pack = current_app.raptor_pack
# Now you can use raptor_pack here
return "Raptor Pack Accessed" This approach leverages Flask's For more detailed guidance, refer to the Flask documentation on application contexts. If you're considering using
|
Question Validation
Question
How do I access the raptor_pack variable later on. I am using this in a flask application but I want to call the query engine by using
raptor_pack.retriever
as we noticed that produced better results. Trying to figure out a way to do this without creating a retriever and passing that into the arguments of RetrieverQueryEngine, and without cookies/global vars etc.The text was updated successfully, but these errors were encountered: