yoheinakajima / babyagi

MIT License
19.73k stars 2.58k forks source link

Redundant use of `vector` and `result` variables and wrong types #266

Closed peterbanda closed 1 year ago

peterbanda commented 1 year ago

Hi there,

I've been playing with BabyAGI lately, trying to provide strong types, and found out the following redundancy/inconsistency problem.

The vector variable in the main function is defined as:

  enriched_result = {
    "data": result
  }

  vector = enriched_result["data"]  

and its only use is to be passed to the storage's add function as

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

It's evident that result == vector, which I've tested also by a simple assert in the code. Hence either result or vector should be removed.

Furthermore, Chroma's impl of add function uses exclusively a param vector, whereas Pinecone uses result (it's actually storing the vector embedding to a vector variable but that's not passed anywhere). Hence the add function should be simplified to just add(task, result, result_id).

Last, since result is always of type str the signature of add function in DefaultResultsStorage as well as PineconeResultsStorage should be then: def add(self, task: Dict, result: str, result_id: int)

peterbanda commented 1 year ago

As mentioned in #267 the result_id type should actually be str