I am Currently doing a POC on chatbot that uses SQLs for user response. Seeking your guidance regarding a scenario involving create_react_agent. My intent is to use 2 LLMs, a currently advanced LLM like 'GPT 4 32k' for SQL generation and some cost-effective LLM for user response construction. So far I am not successful in breaking the create_react_agent flow(right after SQL Execution). Following is the concerned code block.
def get_response(state: gr.State, user_input: str, history: list)->any:
toolkit = SQLDatabaseToolkit(db=DB, llm=LLM)
tools = toolkit.get_tools()
system_message = SystemMessage(content=SQL_PREFIX)
agent_executor = create_react_agent(LLM, tools, messages_modifier=system_message)
for s in agent_executor.stream(
{"messages": [HumanMessage(content=user_input)]}, stream_mode="values"
):
message = s["messages"][-1]
if isinstance(message, tuple):
print(message)
response = message.content
else:
message.pretty_print()
response = message.content
history.append((user_input, response))
return ["", history]
create_react_agent has a parameter "Interrupt_after". Although I am quite unsure of its usage / implementation.
Please share your ideas on how to proceed here.