Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ llm_cfg = {
# Step 3: Create an agent. Here we use the `Assistant` agent as an example, which is capable of using tools and reading files.
system_instruction = '''After receiving the user's request, you should:
- first draw an image and obtain the image url,
- then run code `request.get(image_url)` to download the image,
- then run code `requests.get(image_url)` to download the image,
- and finally select an image operation from the given document to process the image.
Please show the image using `plt.show()`.'''
tools = ['my_image_gen', 'code_interpreter'] # `code_interpreter` is a built-in tool for executing code. For configuration details, please refer to the FAQ.
Expand Down
6 changes: 5 additions & 1 deletion qwen_agent/tools/mcp_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@

class MCPManager:
_instance = None # Private class variable to store the unique instance
_lock = threading.Lock() # Lock for thread-safe singleton

def __new__(cls, *args, **kwargs):
if cls._instance is None:
cls._instance = super(MCPManager, cls).__new__(cls, *args, **kwargs)
with cls._lock:
# Double-checked locking pattern
if cls._instance is None:
cls._instance = super(MCPManager, cls).__new__(cls, *args, **kwargs)
return cls._instance

def __init__(self):
Expand Down