Skip to content

Nil pointer dereference when using function calling and a chat_message template #1046

@mtharrison

Description

@mtharrison

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.

Metadata

Metadata

Assignees

Labels

StalebugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions