I'm trying to use ainvoke while making my function asynchronous.
async def get_result(template, user_question): prompt = ChatPromptTemplate.from_template(template) model = mixtral_llm sql_response = ( RunnablePassthrough.assign(schema=get_schema) | prompt | model.bind(stop=["Question"]) | StrOutputParser() ) sql_query = await sql_response.ainvoke({"question":user_question})
But getting the error:
sql_query = await sql_response.ainvoke({"question":user_question})File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/langchain_core/runnables/base.py", line 2536, in ainvokeinput = await step.ainvoke(File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/langchain_core/runnables/base.py", line 4537, in ainvokereturn await self.bound.ainvoke(File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/langchain_core/language_models/llms.py", line 299, in ainvokellm_result = await self.agenerate_prompt(File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/langchain_core/language_models/llms.py", line 643, in agenerate_promptreturn await self.agenerate(File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/langchain_core/language_models/llms.py", line 1018, in agenerateoutput = await self._agenerate_helper(File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/langchain_core/language_models/llms.py", line 882, in _agenerate_helperraise eFile "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/langchain_core/language_models/llms.py", line 866, in _agenerate_helperawait self._agenerate(File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/langchain_core/language_models/llms.py", line 1336, in _agenerateawait self._acall(prompt, stop=stop, run_manager=run_manager, **kwargs)File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/langchain_core/language_models/llms.py", line 1295, in _acallreturn await run_in_executor(File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/langchain_core/runnables/config.py", line 514, in run_in_executorreturn await asyncio.get_running_loop().run_in_executor(File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in runresult = self.fn(*self.args, **self.kwargs)TypeError: _call() takes from 2 to 3 positional arguments but 4 were given
I tried changing the version of langchain-core but that didn't work, I got same error.
I'm running this code in following setup:
python3.9 amd64
langchain==0.1.0
langchain-core==0.1.23
Any kind of help / suggestion would be helpful! Thanks.