fix(mcp): resolve indentation error in mcp_client.py

pull/819/head
Pavan Kumar 3 months ago committed by ascender1729
parent a612352abd
commit f61ada7928

@ -1,29 +1,30 @@
from swarms import Agent
from swarms.tools.mcp_integration import MCPServerSseParams
from loguru import logger
# Comprehensive math prompt that encourages proper JSON formatting from swarms import Agent
MATH_AGENT_PROMPT = """ from swarms.tools.mcp_integration import MCPServerSseParams
You are a helpful math calculator assistant. from loguru import logger
Your role is to understand natural language math requests and perform calculations. # Comprehensive math prompt that encourages proper JSON formatting
When asked to perform calculations: MATH_AGENT_PROMPT = """
You are a helpful math calculator assistant.
1. Determine the operation (add, multiply, or divide) Your role is to understand natural language math requests and perform calculations.
2. Extract the numbers from the request When asked to perform calculations:
3. Use the appropriate math operation tool
FORMAT YOUR TOOL CALLS AS JSON with this format: 1. Determine the operation (add, multiply, or divide)
{"tool_name": "add", "a": <first_number>, "b": <second_number>} 2. Extract the numbers from the request
or 3. Use the appropriate math operation tool
{"tool_name": "multiply", "a": <first_number>, "b": <second_number>}
or
{"tool_name": "divide", "a": <first_number>, "b": <second_number>}
Always respond with a tool call in JSON format first, followed by a brief explanation. FORMAT YOUR TOOL CALLS AS JSON with this format:
""" {"tool_name": "add", "a": <first_number>, "b": <second_number>}
or
{"tool_name": "multiply", "a": <first_number>, "b": <second_number>}
or
{"tool_name": "divide", "a": <first_number>, "b": <second_number>}
def initialize_math_system(): Always respond with a tool call in JSON format first, followed by a brief explanation.
"""
def initialize_math_system():
"""Initialize the math agent with MCP server configuration.""" """Initialize the math agent with MCP server configuration."""
# Configure the MCP server connection # Configure the MCP server connection
math_server = MCPServerSseParams( math_server = MCPServerSseParams(
@ -46,7 +47,7 @@
return math_agent return math_agent
def main(): def main():
try: try:
logger.info("Initializing math system...") logger.info("Initializing math system...")
math_agent = initialize_math_system() math_agent = initialize_math_system()
@ -79,5 +80,5 @@
logger.error(f"System initialization error: {e}") logger.error(f"System initialization error: {e}")
print(f"Failed to start the math system: {str(e)}") print(f"Failed to start the math system: {str(e)}")
if __name__ == "__main__": if __name__ == "__main__":
main() main()
Loading…
Cancel
Save