mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
use threading to insert docs into the db (#1191)
This commit is contained in:
parent
74c9b58d1b
commit
6b0408d47c
@ -1,3 +1,5 @@
|
||||
from threading import Thread
|
||||
|
||||
import chromadb
|
||||
from llama_index.core import Document
|
||||
from llama_index.core.retrievers import VectorIndexRetriever
|
||||
@ -85,6 +87,10 @@ class LongTermMemory:
|
||||
)
|
||||
self.thought_idx += 1
|
||||
logger.debug('Adding %s event to memory: %d', t, self.thought_idx)
|
||||
thread = Thread(target=self._add_doc, args=(doc,))
|
||||
thread.start() # We add the doc concurrently so we don't have to wait ~500ms for the insert
|
||||
|
||||
def _add_doc(self, doc):
|
||||
self.index.insert(doc)
|
||||
|
||||
def search(self, query: str, k: int = 10):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user