Skip to content

Commit

Permalink
Evaluate function names in chat templates
Browse files Browse the repository at this point in the history
  • Loading branch information
mudler committed Feb 16, 2024
1 parent 496374a commit aaf2758
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/openai/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,15 @@ func ChatEndpoint(cm *config.ConfigLoader, o *options.Option) func(c *fiber.Ctx)
}
r := config.Roles[role]
contentExists := i.Content != nil && i.StringContent != ""

// First attempt to populate content via a chat message specific template
if config.TemplateConfig.ChatMessage != "" {
chatMessageData := model.ChatMessageTemplateData{
SystemPrompt: config.SystemPrompt,
Role: r,
RoleName: role,
Content: i.StringContent,
FunctionName: i.Name,

Check failure on line 210 in api/openai/chat.go

View workflow job for this annotation

GitHub Actions / build-macOS (avx2)

unknown field FunctionName in struct literal of type "github.com/go-skynet/LocalAI/pkg/model".ChatMessageTemplateData

Check failure on line 210 in api/openai/chat.go

View workflow job for this annotation

GitHub Actions / build-linux (avx2)

unknown field FunctionName in struct literal of type "github.com/go-skynet/LocalAI/pkg/model".ChatMessageTemplateData

Check failure on line 210 in api/openai/chat.go

View workflow job for this annotation

GitHub Actions / tests-linux (1.21.x)

unknown field FunctionName in struct literal of type "github.com/go-skynet/LocalAI/pkg/model".ChatMessageTemplateData
MessageIndex: messageIndex,
}
templatedChatMessage, err := o.Loader.EvaluateTemplateForChatMessage(config.TemplateConfig.ChatMessage, chatMessageData)
Expand Down
4 changes: 4 additions & 0 deletions api/schema/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ type ContentURL struct {
type Message struct {
// The message role
Role string `json:"role,omitempty" yaml:"role"`

// The message name (used for tools calls)
Name string `json:"name,omitempty" yaml:"name"`

// The message content
Content interface{} `json:"content" yaml:"content"`

Expand Down

0 comments on commit aaf2758

Please sign in to comment.