Closed svjack closed 5 months ago
@svjack Hi, I think your code should look something like this:
summary_chain = AgentChainElement("out_0",
system_prompt="You are an advanced AI agent for summarizing articles",
prompt="Summarize this article into bullet points:\n{item}")
translate_chain = AgentChainElement("out_1",
system_prompt="You are an advanced AI agent for translate articles",
prompt="translate the content into French:\n{out_0}")
combine_chain = AgentChainElement("out_2",
system_prompt="You are an advanced AI agent that summarizes text",
prompt="Please combine the French bullet points of different summaries below, into one summary as French bullet points:\n{map_output}")
map_chain = MapChain(agent, [summary_chain, translate_chain], [combine_chain])
map_chain.run_map_chain(items_to_map=article_list)
You basically pipe the output from the first element in the second as out_0
and then use the outputs of the first chain in the second with map_output
The elment summary_chain
will forward its output to translate_chain
. The two elements build the first map chain, which will be invoked on every input element ìtems_to_map
and then the results of all these runs will be put into one prompt for the combine_chain
under map_output
.
@svjack I added a full example like yours here: https://github.com/Maximilian-Winter/llama-cpp-agent/blob/master/examples/08_Chains/map_chain_summary_translate.py
In the example of https://llama-cpp-agent.readthedocs.io/en/latest/map_chain/ If I want to add a AgentChainElement to it as
the translate_chain seems not take summary_chain's output as its input. Is it necessary add additional_fields (run_map_chain) to AgentChainElement Or I should call run_map_chain In sequence manually ?