langchain/templates/anthropic-iterative-search/anthropic_iterative_search/agent_scratchpad.py

17 lines
452 B
Python
Raw Normal View History

def _format_docs(docs):
result = "\n".join(
[
f'<item index="{i+1}">\n<page_content>\n{r}\n</page_content>\n</item>'
for i, r in enumerate(docs)
]
)
return result
2023-10-29 22:50:09 +00:00
def format_agent_scratchpad(intermediate_steps):
thoughts = ""
for action, observation in intermediate_steps:
thoughts += action.log
2023-10-29 22:50:09 +00:00
thoughts += "</search_query>" + _format_docs(observation)
return thoughts