0

I have created a application which takes input question and converts it in SQL query using langchain, llm and nlp but sometimes it creating wrong query especially in the beginning following is the code which I have written for the application.

def rds_answer(question):
    """
    This function collects all necessary information to execute the sql_db_chain and get an answer generated, taking
    a natural language question in and returning an answer and generated SQL query.
    :param question: The question the user passes in from the frontend
    :return: The final answer in natural langauge along with the generated SQL query.
    """

    rds_uri = get_rds_uri()
    db = SQLDatabase.from_uri(rds_uri)
    examples = load_samples()
    sql_db_chain = load_few_shot_chain(llm, db, examples)

    print("sql_db_chain: ",sql_db_chain)
    answer = sql_db_chain(question)
    return answer["intermediate_steps"][1], answer["result"]

0