Skip to content

Commit

Permalink
dev: janitor commit
Browse files Browse the repository at this point in the history
  • Loading branch information
plowsai committed Apr 24, 2024
1 parent 62e55ca commit 274783a
Show file tree
Hide file tree
Showing 2,001 changed files with 82 additions and 347,627 deletions.
164 changes: 0 additions & 164 deletions .gitignore

This file was deleted.

9 changes: 0 additions & 9 deletions Citation.cff

This file was deleted.

1 change: 1 addition & 0 deletions agents/main/control_center/rewind/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## This is a script to be able to rewind anything I am looking at on my computer and view it again.
58 changes: 58 additions & 0 deletions agents/main/control_center/rewind/rewind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import pickle
import time

# AI Component
def process_command(command):
if command == "rewind to 10 minutes ago":
return "rewind_to_10_minutes_ago"
elif command == "restore to last snapshot":
return "restore_to_last_snapshot"
else:
return "unknown_command"

# Vector Database Simulation
class VectorDatabase:
def __init__(self):
self.db = {}

def add_snapshot(self, timestamp, snapshot):
self.db[timestamp] = snapshot

def get_snapshot(self, timestamp):
return self.db.get(timestamp)

# Snapshotting
def capture_snapshot():
snapshot = {"files": ["file1.txt", "file2.txt"], "processes": ["process1", "process2"]}
return pickle.dumps(snapshot)

# Restoring
def restore_snapshot(snapshot_data):
snapshot = pickle.loads(snapshot_data)
print("Restoring snapshot:", snapshot)

# Main Function
def main():
db = VectorDatabase()

while True:
command = input("Enter command: ")
action = process_command(command)

if action == "rewind_to_10_minutes_ago":
snapshot = capture_snapshot()
timestamp = time.time() - 600 # 10 minutes ago
db.add_snapshot(timestamp, snapshot)
print("Snapshot taken and stored.")

elif action == "restore_to_last_snapshot":
last_timestamp = max(db.db.keys())
snapshot_data = db.get_snapshot(last_timestamp)
restore_snapshot(snapshot_data)
print("Restored to last snapshot.")

else:
print("Unknown command.")

if __name__ == "__main__":
main()
23 changes: 23 additions & 0 deletions agents/memory/chroma.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## This is just a placeholder for now

import chromadb
# setup Chroma in-memory, for easy prototyping. Can add persistence easily!
client = chromadb.Client()

# Create collection. get_collection, get_or_create_collection, delete_collection also available!
collection = client.create_collection("all-my-documents")

# Add docs to the collection. Can also update and delete. Row-based API coming soon!
collection.add(
documents=["This is document1", "This is document2"], # we handle tokenization, embedding, and indexing automatically. You can skip that and add your own embeddings as well
metadatas=[{"source": "notion"}, {"source": "google-docs"}], # filter on these!
ids=["doc1", "doc2"], # unique for each doc
)

# Query/search 2 most similar results. You can also .get by id
results = collection.query(
query_texts=["This is a query document"],
n_results=2,
# where={"metadata_field": "is_equal_to_this"}, # optional filter
# where_document={"$contains":"search_string"} # optional filter
)
Loading

1 comment on commit 274783a

@vercel
Copy link

@vercel vercel bot commented on 274783a Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.