-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question]: ValueError: loop argument must agree with lock #17528
Comments
Hey @chiyingyunhua! I'm here to help you out with any bugs, answer your questions, and guide you on how to become a contributor. Let's tackle this together! The error you're encountering, Here are a few steps you can take to resolve this issue:
By following these steps, you should be able to resolve the To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
I've never seen this before tbh. Maybe remove the nest asyncio call, that's only needed for notebooks. Running as a pure script it'll be fine |
no, remove the nest aysncio call, the error also exists。 |
Question Validation
Question
python:3.10.0
llama-index:0.12.11
code is :
import asyncio
import os
from typing import Any, List
from llama_index.core.agent.react import ReActChatFormatter, ReActOutputParser
from llama_index.core.agent.react.types import (
ActionReasoningStep,
ObservationReasoningStep,
)
from llama_index.core.llms.llm import LLM
from llama_index.core.memory import ChatMemoryBuffer
from llama_index.core.tools.types import BaseTool
from llama_index.core.workflow import (
Context,
Workflow,
StartEvent,
StopEvent,
step,
)
from llama_index.llms.openai import OpenAI
from llama_index.core.llms import ChatMessage
from llama_index.core.tools import ToolSelection, ToolOutput, FunctionTool
from llama_index.core.workflow import Event
import nest_asyncio
nest_asyncio.apply()
class PrepEvent(Event):
pass
class InputEvent(Event):
input: list[ChatMessage]
class ToolCallEvent(Event):
tool_calls: list[ToolSelection]
class FunctionOutputEvent(Event):
output: ToolOutput
class ReActAgent(Workflow):
def init(
self,
*args: Any,
llm: LLM | None = None,
tools: list[BaseTool] | None = None,
extra_context: str | None = None,
**kwargs: Any,
) -> None:
super().init(*args, **kwargs)
self.tools = tools or []
async def main():
# 设置OpenAI API密钥
os.environ["OPENAI_API_KEY"] = "your_openai_api_key"
if name == "main":
asyncio.run(main())
error is:
Traceback (most recent call last):
File "C:\workfile\code\python\test_llama_index\llama_workflow\react_agent.py", line 204, in
asyncio.run(main())
File "C:\Users\fuhuaz\AppData\Local\miniconda3\envs\py310\lib\site-packages\nest_asyncio.py", line 30, in run
return loop.run_until_complete(task)
File "C:\Users\fuhuaz\AppData\Local\miniconda3\envs\py310\lib\site-packages\nest_asyncio.py", line 98, in run_until_complete
return f.result()
File "C:\Users\fuhuaz\AppData\Local\miniconda3\envs\py310\lib\asyncio\futures.py", line 201, in result
raise self._exception
File "C:\Users\fuhuaz\AppData\Local\miniconda3\envs\py310\lib\asyncio\tasks.py", line 232, in __step
result = coro.send(None)
File "C:\workfile\code\python\test_llama_index\llama_workflow\react_agent.py", line 200, in main
ret = await agent.run(input="Hello!")
File "C:\Users\fuhuaz\AppData\Local\miniconda3\envs\py310\lib\site-packages\llama_index\core\instrumentation\dispatcher.py", line 321, in wrapper
result = func(*args, **kwargs)
File "C:\Users\fuhuaz\AppData\Local\miniconda3\envs\py310\lib\site-packages\llama_index\core\workflow\workflow.py", line 393, in run
ctx, run_id = self._start(
File "C:\Users\fuhuaz\AppData\Local\miniconda3\envs\py310\lib\site-packages\llama_index\core\workflow\workflow.py", line 184, in _start
ctx = Context(self, stepwise=stepwise)
File "C:\Users\fuhuaz\AppData\Local\miniconda3\envs\py310\lib\site-packages\llama_index\core\workflow\context.py", line 44, in init
self._step_condition: asyncio.Condition = asyncio.Condition(
File "C:\Users\fuhuaz\AppData\Local\miniconda3\envs\py310\lib\asyncio\locks.py", line 234, in init
raise ValueError("loop argument must agree with lock")
ValueError: loop argument must agree with lock。
The text was updated successfully, but these errors were encountered: