Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing a redundant use of vector and result variables and wrong types #272

Merged
merged 2 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions babyagi.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,28 +199,28 @@ def __init__(self):
embedding_function=embedding_function,
)

def add(self, task: Dict, result: str, result_id: str, vector: str):
def add(self, task: Dict, result: str, result_id: str):

# Break the function if LLM_MODEL starts with "human" (case-insensitive)
if LLM_MODEL.startswith("human"):
return
# Continue with the rest of the function

embeddings = llm_embed.embed(vector) if LLM_MODEL.startswith("llama") else None
embeddings = llm_embed.embed(result) if LLM_MODEL.startswith("llama") else None
if (
len(self.collection.get(ids=[result_id], include=[])["ids"]) > 0
): # Check if the result already exists
self.collection.update(
ids=result_id,
embeddings=embeddings,
documents=vector,
documents=result,
metadatas={"task": task["task_name"], "result": result},
)
else:
self.collection.add(
ids=result_id,
embeddings=embeddings,
documents=vector,
documents=result,
metadatas={"task": task["task_name"], "result": result},
)

Expand Down Expand Up @@ -537,11 +537,11 @@ def main():
}
# extract the actual result from the dictionary
# since we don't do enrichment currently
vector = enriched_result["data"]
# vector = enriched_result["data"]

result_id = f"result_{task['task_id']}"

results_storage.add(task, result, result_id, vector)
results_storage.add(task, result, result_id)

# Step 3: Create new tasks and re-prioritize task list
# only the main instance in cooperative mode does that
Expand Down
7 changes: 2 additions & 5 deletions extensions/pinecone_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ def __init__(self, openai_api_key: str, pinecone_api_key: str, pinecone_environm
index_stats_response = self.index.describe_index_stats()
assert dimension == index_stats_response['dimension'], "Dimension of the index does not match the dimension of the LLM embedding"

def add(self, task: Dict, result: Dict, result_id: str, vector: List):
enriched_result = {
"data": result
}
def add(self, task: Dict, result: str, result_id: int):
vector = self.get_embedding(
enriched_result["data"]
result
)
self.index.upsert(
[(result_id, vector, {"task": task["task_name"], "result": result})], namespace=self.namespace
Expand Down