custom prompt template for SQLAutoVectorQueryEngine sql query #10695
Replies: 1 comment
-
🤖 Hey there, @lalitbyteiq! Fancy seeing you back here. Hope you're ready to dive into some more fun with SQLAutoVectorQueryEngine! 🚀😄 Sure, I can guide you on how to add extra information to the prompt template for generating SQL queries in the SQLAutoVectorQueryEngine of the LlamaIndex data framework. To add extra information to the prompt template, you can modify the Here's an example of how you can add a new piece of information, "extra_info", to the DEFAULT_SQL_JOIN_SYNTHESIS_PROMPT_TMPL = """
The original question is given below.
This question has been translated into a SQL query. Both the SQL query and \
the response are given below.
Given the SQL response, the question has also been transformed into a more \
detailed query,
and executed against another query engine.
The transformed query and query engine response are also given below.
Given SQL query, SQL response, transformed query, and query engine response, \
please synthesize a response to the original question.
Original question: {query_str}
SQL query: {sql_query_str}
SQL response: {sql_response_str}
Transformed query: {query_engine_query_str}
Query engine response: {query_engine_response_str}
Extra Info: {extra_info}
Response:
"""
DEFAULT_SQL_JOIN_SYNTHESIS_PROMPT = PromptTemplate(
DEFAULT_SQL_JOIN_SYNTHESIS_PROMPT_TMPL
) Then, when you call the response_str = self._service_context.llm.predict(
self._sql_join_synthesis_prompt,
query_str=query_bundle.query_str,
sql_query_str=sql_query,
sql_response_str=str(sql_response),
query_engine_query_str=new_query.query_str,
query_engine_response_str=str(other_response),
extra_info="your extra information here",
) This will add the "extra_info" to the prompt that is used to generate the SQL query. You can find more details in the llama_index/query_engine/sql_join_query_engine.py file. Also, there are similar solved issues in the LlamaIndex repository that might be helpful for you. Here are a few of them:
I hope this helps! If you have any other questions, feel free to ask. Sources
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
i want to add some extra info on the prompt for generating query how can i add this on SQLAutoVectorQueryEngine
Beta Was this translation helpful? Give feedback.
All reactions