You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I searched existing ideas and did not find a similar one
I added a very descriptive title
I've clearly described the feature request and motivation for it
Feature request
Add tool calling for DeepSeek-R1 in AzureChatOpenAI.
For eg. with the Python script below:
from langchain_openai import AzureChatOpenAI # Updated import
from langchain_core.tools import tool
from langgraph.prebuilt import create_react_agent
from langchain_core.messages import SystemMessage, HumanMessage
# # Define and create a simple tool using the decorator
@tool
def calculator(expression: str) -> str:
"""Evaluate a mathematical expression."""
try:
return str(eval(expression))
except Exception as e:
return f"Error: {str(e)}"
# Initialize the Azure OpenAI chat model
model = AzureChatOpenAI(
azure_deployment="DeepSeek-R1",
openai_api_version="2024-05-01-preview",
azure_endpoint="MY_AZURE_ENDPOINT",
api_key="MY_AZURE_API_KEY",
model_name="DeepSeek-R1" # Add this line to specify the model
)
tools = [calculator]
system_human_messages = [SystemMessage(content="You are a helpful assistant with access to tools. You should use the available tools whenever possible to ensure accurate calculations. Always use the calculator tool for mathematical operations, even for simple calculations."),
HumanMessage(content="What is 123 * 456?")]
agent_executor = create_react_agent(model, tools)
response = agent_executor.invoke({"messages": system_human_messages})
response["messages"]
The output I am getting from the script above is:
[SystemMessage(content='You are a helpful assistant with access to tools. You should use the available tools whenever possible to ensure accurate calculations. Always use the calculator tool for mathematical operations, even for simple calculations.', additional_kwargs={}, response_metadata={}, id='189033f7-4769-4ca4-96ce-c43035ab48d6'),
HumanMessage(content='What is 123 * 456?', additional_kwargs={}, response_metadata={}, id='a22cf89e-8e01-41cd-818f-e0ccd1faaca7'),
AIMessage(content="<think>\nOkay, let me figure out what 123 multiplied by 456 is. Hmm, I'm not sure off the top of my head, so I better use the calculator to make sure I get it right. First, I'll input 123 times 456 into the calculator tool. Let me check the numbers again to avoid any typos. Yep, 123 and 456. Alright, multiplying those together. The calculator should give me the exact product. I remember that multiplying larger numbers can sometimes lead to mistakes if done manually, so using the tool here is definitely the way to go. Let me just double-check by maybe breaking it down. 123 times 400 is 49,200, and 123 times 56 is... let's see, 123*50=6,150 and 123*6=738. Adding those gives 6,150 + 738 = 6,888. Then adding that to 49,200 gives 49,200 + 6,888 = 56,088. Wait, does that match the calculator result? Let me confirm with the tool again to be sure. Yeah, the calculator tool is more accurate here. So the final answer should be 56,088.\n</think>\n\nThe result of multiplying 123 by 456 is calculated as follows:\n\n123 × 456 = 56,088\n\n**Answer:** 56,088", additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 290, 'prompt_tokens': 48, 'total_tokens': 338, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'DeepSeek-R1', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None, 'content_filter_results': {}}, id='run-d6f6d0a5-279b-4045-8093-d4a7de0dffd0-0', usage_metadata={'input_tokens': 48, 'output_tokens': 290, 'total_tokens': 338, 'input_token_details': {}, 'output_token_details': {}})]
From the output above, ToolMessage was not called. I have tried different system message to make it stronger for the LLM to use the tool and also asked a more complex math calculation, but the agent is still not calling the tool.
Motivation
Please equip Deepseek R1 in AzureChatOpenAI with tool calling since Deepseek R1 is a major model now and Azure is also a major platform. In addition, Azure is currently offering Deepseek R1 for free so this would likely interest a lot of devs with a strong demand for this.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Checked
Feature request
Add tool calling for DeepSeek-R1 in AzureChatOpenAI.
For eg. with the Python script below:
The output I am getting from the script above is:
From the output above,
ToolMessage
was not called. I have tried different system message to make it stronger for the LLM to use the tool and also asked a more complex math calculation, but the agent is still not calling the tool.Motivation
Please equip Deepseek R1 in AzureChatOpenAI with tool calling since Deepseek R1 is a major model now and Azure is also a major platform. In addition, Azure is currently offering Deepseek R1 for free so this would likely interest a lot of devs with a strong demand for this.
Proposal (If applicable)
No response
Beta Was this translation helpful? Give feedback.
All reactions