Looks fine to me π€
Whats the error when querying?
@Logan M When running a query to the graph with the mode "recursive" augment. I get an error that the augment "mode" is unexpected.
My build graph function looks like this:
def build_and_save_graph(indexes, summaries):
global graph
graph = ComposableGraph.from_indices(
GPTTreeIndex,
indexes,
index_summaries=summaries
)
And my query looks like this:
def query_index(query_text):
global graph, service_context
"""Query the global index."""
response = graph.query(
str(query_text),
mode="recursive",
query_configs=query_configs,
service_context=service_context
)
return response
I assumed I must be loading in things incorrectly. Or at least this was my first troubleshooting step.
My specific error is:
TypeError: ComposableGraph.query() got an unexpected keyword argument 'mode'
Oh, I don't think the mode argument is needed here! You can remove it π
@Logan M So there is definitely progress, it thinks for a bit and spits out something I assume but I guess I am incorrectly processing it.
Here is my error:
"similarity": round(x.similarity, 2),
TypeError: type NoneType doesn't define round method
Here is the code:
response_json = {
"text": str(response),
"sources": [{"text": str(x.source_text),
"similarity": round(x.similarity, 2),
"doc_id": str(x.doc_id),
"start": x.node_info['start'],
"end": x.node_info['end']
} for x in response.source_nodes]
}
return make_response(jsonify(response_json)), 200
This was pulled from the original flask example in the docs where we load a simple index. I assume I can't pull sources anymore and that's my issue?
Ah, I need to update that tutorial! Whoops lol
Try x.score
instead of x.similarity
@Logan M That doesn't seem to have made a difference in my case. But I think that the variable "x" which represents the sources is likely empty. Where is this generated considering the query of the graph only returns the answer?
The code should work even if response.source_nodes is empty, since otherwise it would be an empty list π€
But true, I don't think I tested this on a graph lol. What happens if you comment the sources key for now?
@Logan M The call works. The whole front-end breaks but that's not a concern right now.
So I assume it's the empty list that is the issue. Is there a way I can debug the response.source_nodes?
(To avoid breaking the frintend, you could try putting in dummy values)
I'm not sure actually. I think something about using a graph is not returning source nodes properly π€ π
@Logan M Well, I certainly appreciate your help so far! I might spend some time this week stripping it back and just doing calls directly to troubleshoot.
Sounds good to me! Good luck! πͺπ«‘