You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! Thanks for your great work. I'm wondering whether you could add an example or documentation for integrating RAG into Data Interpreter. It seems that there are only examples for RAG Retrieval and Rerank, but I have no idea how to utilize this ability into the current Data Interpreter Machine learning modeling procedure. Thanks!
The text was updated successfully, but these errors were encountered:
When the Data Interpreter object's rc.memory content is too large, you can use the RAG approach to retrieve this memory, which reduces the cost of a single interaction and avoids exceeding the maximum token limit of the LLM.
For example, using RAG to override the self.get_memories() function used in metagpt/roles/di/data_interpreter.py:
asyncdef_think(self) ->bool:
"""Useful in 'react' mode. Use LLM to decide whether and what to do next."""user_requirement=self.get_memories()[0].contentcontext=self.working_memory.get()
ifnotcontext:
# just started the run, we need action certainlyself.working_memory.add(self.get_memories()[0]) # add user requirement to working memoryself._set_state(0)
returnTrueprompt=REACT_THINK_PROMPT.format(user_requirement=user_requirement, context=context)
rsp=awaitself.llm.aask(prompt)
rsp_dict=json.loads(CodeParser.parse_code(block=None, text=rsp))
self.working_memory.add(Message(content=rsp_dict["thoughts"], role="assistant"))
need_action=rsp_dict["state"]
self._set_state(0) ifneed_actionelseself._set_state(-1)
returnneed_action
The original definition of the get_memories function in metagpt/roles/role.py is as follows:
defget_memories(self, k=0) ->list[Message]:
"""A wrapper to return the most recent k memories of this role, return all when k=0"""returnself.rc.memory.get(k=k)
Hi! Thanks for your great work. I'm wondering whether you could add an example or documentation for integrating RAG into Data Interpreter. It seems that there are only examples for RAG Retrieval and Rerank, but I have no idea how to utilize this ability into the current Data Interpreter Machine learning modeling procedure. Thanks!
The text was updated successfully, but these errors were encountered: