mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
1 line
3.5 KiB
JavaScript
1 line
3.5 KiB
JavaScript
"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[1033],{1512:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>i,default:()=>h,frontMatter:()=>s,metadata:()=>l,toc:()=>d});var r=t(4848),o=t(8453);const s={sidebar_label:"memory",title:"monologue_agent.utils.memory"},i=void 0,l={id:"python/monologue_agent/utils/memory",title:"monologue_agent.utils.memory",description:"LongTermMemory Objects",source:"@site/docs/python/monologue_agent/utils/memory.md",sourceDirName:"python/monologue_agent/utils",slug:"/python/monologue_agent/utils/memory",permalink:"/OpenDevin/docs/python/monologue_agent/utils/memory",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{sidebar_label:"memory",title:"monologue_agent.utils.memory"}},c={},d=[{value:"LongTermMemory Objects",id:"longtermmemory-objects",level:2},{value:"__init__",id:"__init__",level:4},{value:"add_event",id:"add_event",level:4},{value:"search",id:"search",level:4}];function a(e){const n={code:"code",h2:"h2",h4:"h4",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,o.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.h2,{id:"longtermmemory-objects",children:"LongTermMemory Objects"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"class LongTermMemory()\n"})}),"\n",(0,r.jsx)(n.p,{children:"Responsible for storing information that the agent can call on later for better insights and context.\nUses chromadb to store and search through memories."}),"\n",(0,r.jsx)(n.h4,{id:"__init__",children:"__init__"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"def __init__()\n"})}),"\n",(0,r.jsx)(n.p,{children:"Initialize the chromadb and set up ChromaVectorStore for later use."}),"\n",(0,r.jsx)(n.h4,{id:"add_event",children:"add_event"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"def add_event(event: dict)\n"})}),"\n",(0,r.jsx)(n.p,{children:"Adds a new event to the long term memory with a unique id."}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"Arguments"}),":"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"event (dict): The new event to be added to memory"}),"\n"]}),"\n",(0,r.jsx)(n.h4,{id:"search",children:"search"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"def search(query: str, k: int = 10)\n"})}),"\n",(0,r.jsx)(n.p,{children:"Searches through the current memory using VectorIndexRetriever"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"Arguments"}),":"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"query (str): A query to match search results to"}),"\n",(0,r.jsx)(n.li,{children:"k (int): Number of top results to return"}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"Returns"}),":"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"List[str]: List of top k results found in current memory"}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>l});var r=t(6540);const o={},s=r.createContext(o);function i(e){const n=r.useContext(s);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:i(e.components),r.createElement(s.Provider,{value:n},e.children)}}}]); |