griptape
griptape copied to clipboard
VectorQueryEngine issue with loading artifacts from query
- [x] I have read and agree to the contributing guidelines.
Describe the bug Using this example and Redis I'm getting error: Response: error querying vector store: string indices must be integers, not 'str'
[05/14/24 13:22:38] INFO Subtask 14c519c5ea9747a381ef8aa97f4aa055
Response: error querying vector store: string indices must be integers, not 'str'
[05/14/24 13:22:53] INFO Subtask f787fb764f1e4e9ea70d684662820fb3
Thought: The error message indicates a persistent issue with the JSON structure, and my previous
corrections have not resolved it. I need to re-evaluate the JSON object I am submitting to ensure it
adheres to the schema. I will carefully review the JSON schema for the griptape_tool action and make
sure that the structure of my action request is correct.
Actions: [{"tag": "griptape_info_search_corrected", "name": "griptape_tool", "path": "search",
"input": {"values": {"query": "What is Griptape?"}}}]
I don't have any other Vector DB so not sure if same thing happens with other drivers, looking at source code it should behave same as for Redis.
Tracked it down to this line: https://github.com/griptape-ai/griptape/blob/a899f5af59c6b624d8fca8461bc26c745c8ecb4d/griptape/engines/query/vector_query_engine.py#L36
It assumes that meta is dict, but in fact query returns string from DB.
Possible solutions
- Fix it in one place, in
VectorQueryEngine
(only a quick fix to make example code work with Redis):
[...]
import json
[...]
artifacts = [
artifact
for artifact in [BaseArtifact.from_json((r.meta["artifact"] if isinstance(r.meta, dict) else json.loads(r.meta)["artifact"])) for r in result if r.meta]
if isinstance(artifact, TextArtifact)
]
[...]
- Modify each Vector Driver so that
query
returnsmeta
as dict. - Modify
VectorQueryEngine
to useload_entry
method from Vector Driver before loading artifact.
I think best would be second option, as it won't affect LocalVectorStoreDriver
.
Desktop (please complete the following information):
- OS: Win 11
- Griptape Version 0.25.0