mirror of
https://github.com/arc53/DocsGPT.git
synced 2026-02-22 12:21:39 +00:00
Artifacts-backed persistence for Agent “Self” tools (Notes / Todo) + streaming artifact_id support (#2267)
* (feat:memory) use fs/storage for files
* (feat:todo) artifact_id via sse
* (feat:notes) artifact id return
* (feat:artifact) add get endpoint, store todos with conv id
* (feat: artifacts) fe integration
* feat(artifacts): ui enhancements, notes as mkdwn
* chore(artifacts) updated artifact tests
* (feat:todo_tool) return all todo items
* (feat:tools) use specific tool names in bubble
* feat: add conversationId prop to artifact components in Conversation
* Revert "(feat:memory) use fs/storage for files"
This reverts commit d1ce3bea31.
* (fix:fe) build fail
This commit is contained in:
@@ -24,14 +24,21 @@ class FakeCursor(list):
|
||||
class FakeCollection:
|
||||
def __init__(self):
|
||||
self.docs = {}
|
||||
self._id_counter = 0
|
||||
|
||||
def _generate_id(self):
|
||||
self._id_counter += 1
|
||||
return f"fake_id_{self._id_counter}"
|
||||
|
||||
def create_index(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def insert_one(self, doc):
|
||||
key = (doc["user_id"], doc["tool_id"], doc["todo_id"])
|
||||
if "_id" not in doc:
|
||||
doc["_id"] = self._generate_id()
|
||||
self.docs[key] = doc
|
||||
return type("res", (), {"inserted_id": key})
|
||||
return type("res", (), {"inserted_id": doc["_id"]})
|
||||
|
||||
def find_one(self, query):
|
||||
key = (query.get("user_id"), query.get("tool_id"), query.get("todo_id"))
|
||||
@@ -52,12 +59,25 @@ class FakeCollection:
|
||||
self.docs[key].update(update.get("$set", {}))
|
||||
return type("res", (), {"matched_count": 1})
|
||||
elif upsert:
|
||||
new_doc = {**query, **update.get("$set", {})}
|
||||
new_doc = {**query, **update.get("$set", {}), "_id": self._generate_id()}
|
||||
self.docs[key] = new_doc
|
||||
return type("res", (), {"matched_count": 1})
|
||||
else:
|
||||
return type("res", (), {"matched_count": 0})
|
||||
|
||||
def find_one_and_update(self, query, update):
|
||||
key = (query.get("user_id"), query.get("tool_id"), query.get("todo_id"))
|
||||
if key in self.docs:
|
||||
self.docs[key].update(update.get("$set", {}))
|
||||
return self.docs[key]
|
||||
return None
|
||||
|
||||
def find_one_and_delete(self, query):
|
||||
key = (query.get("user_id"), query.get("tool_id"), query.get("todo_id"))
|
||||
if key in self.docs:
|
||||
return self.docs.pop(key)
|
||||
return None
|
||||
|
||||
def delete_one(self, query):
|
||||
key = (query.get("user_id"), query.get("tool_id"), query.get("todo_id"))
|
||||
if key in self.docs:
|
||||
|
||||
Reference in New Issue
Block a user