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: function argument parsing using named regex #4700

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

mKenfenheuer
Copy link
Contributor

@mKenfenheuer mKenfenheuer commented Jan 27, 2025

Description
This PR fixes #4671

I've added a function to parse function call arguments using named regex into valid json, in case the model is trained on non json argument / function calling.

Notes for Reviewers
Example model configuration can be found here

Signed commits

  • Yes, I signed my commits.

Copy link

netlify bot commented Jan 27, 2025

Deploy Preview for localai ready!

Name Link
🔨 Latest commit ed74ea8
🔍 Latest deploy log https://app.netlify.com/sites/localai/deploys/679761494f8eef00087e4ef5
😎 Deploy Preview https://deploy-preview-4700--localai.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Owner

@mudler mudler left a comment

Choose a reason for hiding this comment

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

This looks good, thanks!

It would be nice, if you feel like it, also to update the llama3.2 templates in the gallery so everyone will benefit.

In any case, I see just small golang nits here and there but nothing blocking. Thank you!

@@ -322,3 +329,39 @@ func ParseFunctionCall(llmresult string, functionConfig FunctionsConfig) []FuncC

return results
}

func ParseFunctionCallArgs(functionArguments string, functionConfig FunctionsConfig) string {
if len(functionConfig.ArgumentRegex) > 0 {
Copy link
Owner

@mudler mudler Jan 27, 2025

Choose a reason for hiding this comment

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

A small nit here - instead of branching I would propose something the lines of:

if len(functionConfig.ArgumentRegex) == 0 {
  return functionArguments
}

// Here the logic to handle argument regexes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A small nit here - instead of branching I would propose something the lines of:

if len(functionConfig.ArgumentRegex) == 0 {
  return functionArguments
}

// Here the logic to handle argument regexes

That's a good point!
I'll open another PR to change that, as well as for the templates in the gallery.

@mudler mudler enabled auto-merge (squash) January 27, 2025 14:24
@mudler mudler added the enhancement New feature or request label Jan 27, 2025
@mudler mudler merged commit 539e94d into mudler:master Jan 27, 2025
24 checks passed
@mKenfenheuer
Copy link
Contributor Author

Welcome!
Regarding the docs on the full model file reference - i'll update that one as well.

mKenfenheuer added a commit to mKenfenheuer/LocalAI that referenced this pull request Jan 28, 2025
mudler pushed a commit that referenced this pull request Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Function calling: support for different formats of function arguments besides JSON
2 participants