Private
Public Access
1
0

Add metadata json field to Message, store generation model/provider

This commit is contained in:
2024-09-30 17:37:50 +00:00
parent 327a128b2f
commit 5d13c3e056
4 changed files with 44 additions and 21 deletions

View File

@@ -248,7 +248,11 @@ func (a *AppModel) ExecuteToolCalls(toolCalls []api.ToolCall) ([]api.ToolResult,
return agents.ExecuteToolCalls(toolCalls, agent.Toolbox)
}
func (a *AppModel) PromptLLM(messages []api.Message, chatReplyChunks chan provider.Chunk, stopSignal chan struct{}) (*api.Message, error) {
func (a *AppModel) Prompt(
messages []api.Message,
chatReplyChunks chan provider.Chunk,
stopSignal chan struct{},
) (*api.Message, error) {
model, _, p, err := a.Ctx.GetModelProvider(a.Model, a.ProviderName)
if err != nil {
return nil, err
@@ -274,7 +278,12 @@ func (a *AppModel) PromptLLM(messages []api.Message, chatReplyChunks chan provid
}
}()
return p.CreateChatCompletionStream(
msg, err := p.CreateChatCompletionStream(
ctx, params, messages, chatReplyChunks,
)
if msg != nil {
msg.Metadata.GenerationProvider = &a.ProviderName
msg.Metadata.GenerationModel = &a.Model
}
return msg, err
}