-
Checked other resources
Commit to Help
Example Codeagent = create_pandas_dataframe_agent(
llm,
df,
agent_type=AgentType.OPENAI_FUNCTIONS,
verbose=True,
return_intermediate_steps=True,
allow_dangerous_code=True,
allow_dangerous_requests=True,
)
agent.invoke({"input": query_str})
---------------------------------------
def create_question_rewriter(model):
"""
Creates a question rewriter chain that rewrites a given question to improve its clarity and relevance.
Returns:
A callable function that takes a question as input and returns the rewritten question as a string.
"""
re_write_prompt = hub.pull("efriis/self-rag-question-rewriter")
question_rewriter = re_write_prompt | self.model | StrOutputParser()
return question_rewriter DescriptionI have two requests:
Link for the query generator topic: https://github.com/langchain-ai/langchain/blob/master/cookbook/rag_fusion.ipynb?ref=blog.langchain.dev System InfoName: langchain |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
To incorporate the
This code demonstrates how to set up the |
Beta Was this translation helpful? Give feedback.
-
@dosu. Both scenarios are working!!! I have one last question. When it comes to the create_question_rewriter function, what model should I use as the base? Is 'self-rag-question-rewriter' the best option, or are there other models you’d recommend? Also, is it possible to build custom templates or give the model clear insights about my data before it rewrites the questions? If so, could you provide some sample code on how to add custom templates and give the model insights about my data? Thanks a lot! |
Beta Was this translation helpful? Give feedback.
-
@dosu I mean how I customize |
Beta Was this translation helpful? Give feedback.
To incorporate the
create_question_rewriter
function with thepandas_dataframe_agent
and build a query generator, you can follow these steps:Incorporate
create_question_rewriter
Function:Modify the agent's invocation to include the rewritten question as input. Here is a sample code: