Hello i have this code that translate human language question into sql query.when i ran in notebook it work fine but i tried to run in a python file and i get errors.
# Define the full chain for generating the natural language response
full_chain = (
RunnablePassthrough.assign(query=sql_chain).assign(
schema=get_db_schema,
response=lambda vars: run_db_query(vars["query"]),
)
| prompt_response
| llm
| StrOutputParser()
)
# Invoke the full chain with the user's question
final_response = full_chain.invoke({"question": "how many products we have?"})
print(f"Natural Language Response: {final_response}")
when i ran that code i get this errors:
Generated SQL Query: ```
SELECT COUNT(*) AS total_products
FROM products;
Natural Language Response: The total number of products in the database is 32.
Error in sys.excepthook:
Traceback (most recent call last):
File "/home/chiheb/miniconda3/envs/tf/lib/python3.10/site-packages/exceptiongroup/_formatting.py", line 71, in exceptiongroup_excepthook
TypeError: 'NoneType' object is not callable
Original exception was:
Traceback (most recent call last):
File "src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi", line 110, in grpc._cython.cygrpc.shutdown_grpc_aio
File "src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi", line 114, in grpc._cython.cygrpc.shutdown_grpc_aio
File "src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi", line 78, in grpc._cython.cygrpc._actual_aio_shutdown
AttributeError: 'NoneType' object has no attribute 'POLLER'
Exception ignored in: 'grpc._cython.cygrpc.AioChannel.__dealloc__'
Traceback (most recent call last):
File "src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi", line 110, in grpc._cython.cygrpc.shutdown_grpc_aio
File "src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi", line 114, in grpc._cython.cygrpc.shutdown_grpc_aio
File "src/python/grpcio/grpc/_cython/_cygrpc/aio/grpc_aio.pyx.pxi", line 78, in grpc._cython.cygrpc._actual_aio_shutdown
AttributeError: 'NoneType' object has no attribute 'POLLER'
New contributor
Chiheb Nouri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.