You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched both the documentation and discord for an answer.
Question
Hey, I want to use multi modal for llama index query. How can I pass in the images into my query to get a response. I checked the documentation, but couldn't find a clear a answer.
Hey @AyushParikh, I'm here to help you with any bugs, questions, or contributions while you wait for a human maintainer. Let's tackle this challenge together!
To pass images into the Llama Index query engine for multi-modal functionality and get a response, you can use the image_query method. Here's a basic example of how you can achieve this:
fromllama_index.multi_modal_llms.openaiimportOpenAIMultiModalfromllama_index.coreimportPromptTemplate# Define the prompt templateqa_tmpl_str= (
"Given the images provided, ""answer the query.\n""Query: {query_str}\n""Answer: "
)
qa_tmpl=PromptTemplate(qa_tmpl_str)
# Initialize the OpenAI multi-modal modelopenai_mm_llm=OpenAIMultiModal(
model="gpt-4o", api_key=OPENAI_API_KEY, max_new_tokens=1500
)
# Create the query enginequery_engine=index.as_query_engine(
llm=openai_mm_llm, image_qa_template=qa_tmpl
)
# Define the query stringquery_str="Tell me more about the relationship between those paintings."# Perform the image queryresponse=query_engine.image_query("./mixed_wiki/2.jpg", query_str)
# Print the responseprint(response)
This setup allows you to provide an image path and a prompt string to query the engine. Make sure to replace "./mixed_wiki/2.jpg" with the path to your image and adjust the query_str as needed for your specific query [1].
Question Validation
Question
Hey, I want to use multi modal for llama index query. How can I pass in the images into my query to get a response. I checked the documentation, but couldn't find a clear a answer.
The text was updated successfully, but these errors were encountered: