Nil pointer dereference when using function calling and a chat_message template
LocalAI version: Mac ARM native built
Environment, CPU architecture, OS, and Version:
Darwin M-YPDW3RKWDM 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 arm64
Describe the bug
When using a chat_message template and function calling I get a nil pointer dereference when templating the function_call message because Content is not set.
The panic occurs here: https://github.com/go-skynet/LocalAI/blob/master/api/openai/chat.go#L142 as for an assistant message with function call the content may be nil.
I think Content for the template should be set to the marshalled function call as per the code here: https://github.com/go-skynet/LocalAI/blob/master/api/openai/chat.go#L163-L172
To Reproduce
Try functional calling example with only a chat_message template
Expected behavior
Content in the chat_message template should be JSON stringified version of the function call.
I have a working fix on a branch, however I think to add a test I need to update the models_fixtures too. I'll give it a try.
:warning::warning::warning::warning::warning:
Hi! I'm a bot running with LocalAI ( a crazy experiment of @mudler ) - please beware that I might hallucinate sometimes!
but.... I can also be funny or helpful :smile_cat: and I can provide generally speaking good tips or places where to look after in the documentation or in the code based on what you wrote in the issue.
Don't engage in conversation with me, I don't support (yet) replying!
:warning::warning::warning::warning::warning:
Thank you for providing the context and issue description. It seems like there is a bug in the LocalAI code that causes a nil pointer dereference when templating a function call message with a chat_message template. The fix would be to set the Content field in the template to the marshalled version of the function call, as per the code you mentioned.
To reproduce the issue, you can try creating a functional calling example with only a chat_message template and see if it triggers the nil pointer dereference error. If you have a working fix on a branch, you can submit a pull request to the LocalAI repository with your changes and explain the issue and the fix in the accompanying comment.
If you need further assistance or have any questions, feel free to ask!
Sources:
- https://github.com/go-skynet/LocalAI/tree/master/.github/ISSUE_TEMPLATE/bug_report.md
- https://github.com/go-skynet/LocalAI/tree/master/examples/chatbot-ui/docker-compose.yaml
- https://github.com/go-skynet/LocalAI/tree/master/examples/chatbot-ui-manual/docker-compose.yaml
- https://github.com/go-skynet/LocalAI/tree/master/examples/README.md
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.