Add metadata json field to Message, store generation model/provider
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ func (m *Model) promptLLM() tea.Cmd {
|
||||
m.tokenCount = 0
|
||||
|
||||
return func() tea.Msg {
|
||||
resp, err := m.App.PromptLLM(m.App.Messages, m.chatReplyChunks, m.stopSignal)
|
||||
resp, err := m.App.Prompt(m.App.Messages, m.chatReplyChunks, m.stopSignal)
|
||||
if err != nil {
|
||||
return msgChatResponseError{ Err: err }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user