Segue meu código, semelhante ao do curso:
model = 'llama-3.3-70b-versatile'
model_hf_emb = 'BAAI/bge-m3'
Settings.llm = Groq(model=model, groq_api_key=key)
Settings.embed_model = HuggingFaceEmbedding(model_name=model_hf_emb)
sql_database = SQLDatabase(engine)
table_node_map = SQLTableNodeMapping(sql_database)
table_schema_obj = []
for table_name in metadata_obj.tables.keys():
table_schema_obj.append(
SQLTableSchema(table_name=table_name))
object_index = ObjectIndex.from_objects(table_schema_obj, table_node_map, VectorStoreIndex)
obj_retriever = object_index.as_retriever(similarity_top_k=1)
query_engine = SQLTableRetrieverQueryEngine(
sql_database=sql_database,
table_retriever=obj_retriever
)
resp = query_engine.query('Quais são os clientes cadastrados?')
Porém ao executá-lo aparece o seguinte erro:
WARNING:llama_index.llms.openai.utils:Retrying llama_index.llms.openai.base.OpenAI._chat in 1.0 seconds as it raised APIConnectionError: Connection error..
WARNING:llama_index.llms.openai.utils:Retrying llama_index.llms.openai.base.OpenAI._chat in 1.4790521048410215 seconds as it raised APIConnectionError: Connection error..
---------------------------------------------------------------------------
LocalProtocolError Traceback (most recent call last)
/usr/local/lib/python3.11/dist-packages/httpx/_transports/default.py in map_httpcore_exceptions()
100 try:
--> 101 yield
102 except Exception as exc:
50 frames
LocalProtocolError: Illegal header value b'Bearer '
The above exception was the direct cause of the following exception:
LocalProtocolError Traceback (most recent call last)
LocalProtocolError: Illegal header value b'Bearer '
The above exception was the direct cause of the following exception:
APIConnectionError Traceback (most recent call last)
/usr/local/lib/python3.11/dist-packages/openai/_base_client.py in _request(self, cast_to, options, retries_taken, stream, stream_cls)
1028
1029 log.debug("Raising connection error")
-> 1030 raise APIConnectionError(request=request) from err
1031
1032 log.debug(
APIConnectionError: Connection error.
Mesmo usando o Groq, com modelo Llama, aparentemente o LlamaIndex está tentando usar a API do OpenAI. Alguma razão para isto estar acontecendo?