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

Don't try to store an empty result #53

Merged
merged 1 commit into from
Apr 23, 2023

Conversation

eraviart
Copy link
Contributor

When an agent fails (for example: llama_generate: error: prompt is too long (2215 tokens, max 1996)), it returns no result. This PR ensures that a call to store_result doesn't raise an exception when result is empty.

So, it fixes the exception below (but doesn't fix the "prompt too long" error that occurs before):

llama_generate: error: prompt is too long (2215 tokens, max 1996)
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "~/agent-llm/AgentLLM.py", line 282, in run_task
    task = self.execute_next_task()
  File "~/agent-llm/AgentLLM.py", line 254, in execute_next_task
    self.response = self.execution_agent(self.primary_objective, this_task_name, this_task_id)
  File "~/agent-llm/AgentLLM.py", line 221, in execution_agent
    self.response = self.run(prompt)
  File "~/agent-llm/AgentLLM.py", line 73, in run
    self.store_result(task, self.response)
  File "~/agent-llm/AgentLLM.py", line 110, in store_result
    self.collection.add(ids=result_id, documents=result, metadatas={"task": task_name, "result": result})
  File "~/agent-llm/.venv/lib/python3.9/site-packages/chromadb/api/models/Collection.py", line 89, in add
    raise ValueError("You must provide either embeddings or documents, or both")
ValueError: You must provide either embeddings or documents, or both

@Josh-XT Josh-XT merged commit 975726a into Josh-XT:main Apr 23, 2023
2 checks passed
@Josh-XT
Copy link
Owner

Josh-XT commented Apr 23, 2023

Thanks again for the contributions!

@eraviart eraviart deleted the dont_store_empty_result branch April 23, 2023 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants