Python-LLM - Session 3 - LangChain - Multi Agent - Supervisor - Agent - Query Mutual Funds Data
ฝัง
- เผยแพร่เมื่อ 25 ส.ค. 2024
- Use Case
Use LangChain Multi Agent: Supervisor Agent (JSON & Pandas Agents) to Query Mutual Funds Data
Session 3
- LangChain - Multi Agent - Retrieval Augmented Generation
- JSON Agent and Pandas Agent Integration
- Supervisor - Agent set up
- Sample Queries
Documentation Link: docs.sravz.com...
Source Code: gist.github.co...
Video Explanation: • Python-LLM - Session 3...
Sravz LLC Analytics & Tech Series:
Documentation - Source code:
Analytics: docs.sravz.com...
Tech: docs.sravz.com...
Follow Us:
TH-cam: / @sravzllc
Facebook: / sravz-ltd-105045281812833
Instagram: / sravz_llc
Twitter: / sravz46106283
LinkedIn: www.linkedin.c...
Medium: / sravzllc
Reddit: / sravzllc
GitHub: github.com/sra...
Gitter: gitter.im/srav...
Discord: / discord
#cpp #c++ #cors #boost #beast #http #cmake #make #python #langchain #llm #openai
Can you do this on Ollama or Groq inference engines plz?
Hi @JeomonGeroge, thanks for your comments.
I have to check for an hosted llama/groq provider with OpenAI API compatible service so I can point the langchain code to llama/groq.
If you are interested in llamacpp implementation here is a sample: github.com/sravzpublic/ragai/blob/main/src/llama2.py#L74
The sample switches the LLM between chat gpt and llamacpp. github.com/ggerganov/llama.cpp
@@sravzllc I have made the multi agent hierarchial langraph with groq which is similar to yours but it keep on looping it's not going to Finish
@@JeomonGeorge Yes, I'm facing the same issue too, that is holding me from deploying this to Prod. Have you tried to connect the code with langsmith and check the graph: smith.langchain.com/. I noticed this issue: When the supervisor asks the LLM (ChatGPT) which agent next or FInish, ChatGPT seems to give incorrect agent name. So it ends up looping. I'm planning to check the code and see if there is a callback which can be called after an agent + tool run and the supervisor begins the call to LLM for next/FINISH. In that call back (if there is one), update the user message such that when the supervisor asks LLM for the next/FINISH the prompt is updated to just what work is left (do not send the complete initial prompt. I'll investigate further and let you know, in case you find some solution please let me know?
Hi @JeomonGeorge, I updated the system prompt for the supervisor to include description of each agent. Earlier we listed just the agent names, now I added agent descriptions: gist.github.com/sravzpublic/80ce4e6ad8168e9271195a1a5a433c09/revisions#diff-e45c715fe36cbe44080f21c4acf60588992492e52799d94a83bd9f588c77f31aR50. members_description = ["json_agent can handle json input and creates an updated json output", "python_repl_agent can run safe python code"] I also update the user prompt to make it more clear: run_workflow(QueryData(key = "Top_Holdings", query=f"""Using the json_agent get the json key Top_Holdings for the given JSONs
then get the top 5 holdings complete JSON object with name, weights etc for each JSON,
then flatten the list of list of JSON objects into a single list called flattned_list.
Generate safe python code to load the flattned_list to pandas dataframe and save the dataframe to a html file at {output_file_name}.
Run the generated python code so the output file {output_file_name} is created""")) In my last 10 tries I did not see a loop. Please check if this works for you and let me know your thoughts?