Skip to content
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

feat: deepseek r1 alternative tool calling format #975

Closed
wants to merge 6 commits into from

Conversation

michaelneale
Copy link
Collaborator

deepseek can be used (in many ways) from openrouter, so I am trying the largest ones with this.
I found that I can replace the tool calls with a system prompt and it works... a lot of the time. If this continues, could be a more general approach for models which don't support tool calling (use type of format).

cc @ahau-square for the idea

@michaelneale michaelneale changed the title experimental: deepseek r1 openrouter format feat: deepseek r1 alternative tool calling format Jan 31, 2025
.and_then(|obj| obj.get_mut("messages"))
.and_then(|messages| messages.as_array_mut())
{
// Add "cache_control" to the last and second-to-last "user" messages
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cache_control is just for anthropic models

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah - it is conditional in some spots but not others, still messy code!

Comment on lines 299 to 303
let effective_tools = if let Some(system_tools) = Self::extract_tools_from_system(system) {
system_tools
} else {
tools.to_vec()
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need to parse tools from the system prompt if the tools get translated into strings in the system prompt below in create_request_based_on_model ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that was left over code from earlier attempt

@ahau-square
Copy link
Collaborator

I think you need to parse the response into tool calls?

@michaelneale
Copy link
Collaborator Author

trying a fresh take here: #1016

@michaelneale michaelneale deleted the micn/deepseek-r1-openrouter-format branch February 7, 2025 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants