Spaces:
Runtime error
Runtime error
| from langchain_core.prompts import PromptTemplate | |
| from langchain import hub | |
| # react prompt | |
| react_prompt = hub.pull("hwchase17/react") | |
| # prompt to generate sql queries | |
| sql_query_prompt = PromptTemplate.from_template( | |
| """ | |
| You are a SQL Query Agent who has access to a database with the schema: | |
| {db_schema}, | |
| For the given input: {input}, | |
| Generate SQL queries by analyzing the schema and the input. Make sure to answer all the questions in the input. | |
| Generate more number of queries so that a detailed analysis can be done. Make sure the queries are valid and safe. | |
| If there is no relevant query to generate, just generate a query to view the schema of the tables. | |
| """ | |
| ) | |
| # prompt to summarize the SQL query results | |
| sql_query_summary_prompt = PromptTemplate.from_template( | |
| """ | |
| You are a Political Expert who is analyzing the results of the SQL queries executed on the election database. | |
| The initial query: {query}, | |
| You are provided with the sql queries and their results. Analyze the results and summarize the key insights and answer the initial query. | |
| If there are any errors in the execution of queries, analyze the errors and provide insights on the issues. | |
| {results} | |
| """ | |
| ) | |
| sql_query_visualization_prompt = PromptTemplate.from_template( | |
| """ | |
| You are a Data Scientist who is visualizing the results of the SQL queries executed on the election database. | |
| The initial query: {query}, | |
| You are provided with the sql queries and their results. Visualize the results and provide insights on the data using appropriate visualizations and formatting. | |
| If there are any errors in the execution of queries, analyze the errors and provide insights on the issues. | |
| {results} | |
| """ | |
| ) |