Enha: get func name from oai tool call
This commit is contained in:
2
bot.go
2
bot.go
@@ -442,7 +442,7 @@ func findCall(msg, toolCall string, tv *tview.TextView) {
|
|||||||
// call a func
|
// call a func
|
||||||
f, ok := fnMap[fc.Name]
|
f, ok := fnMap[fc.Name]
|
||||||
if !ok {
|
if !ok {
|
||||||
m := fc.Name + "%s is not implemented"
|
m := fc.Name + " is not implemented"
|
||||||
chatRound(m, cfg.ToolRole, tv, false, false)
|
chatRound(m, cfg.ToolRole, tv, false, false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
4
llm.go
4
llm.go
@@ -146,6 +146,10 @@ func (op OpenAIer) ParseChunk(data []byte) (*models.TextChunk, error) {
|
|||||||
}
|
}
|
||||||
if len(llmchunk.Choices[len(llmchunk.Choices)-1].Delta.ToolCalls) > 0 {
|
if len(llmchunk.Choices[len(llmchunk.Choices)-1].Delta.ToolCalls) > 0 {
|
||||||
resp.ToolChunk = llmchunk.Choices[len(llmchunk.Choices)-1].Delta.ToolCalls[0].Function.Arguments
|
resp.ToolChunk = llmchunk.Choices[len(llmchunk.Choices)-1].Delta.ToolCalls[0].Function.Arguments
|
||||||
|
fname := llmchunk.Choices[len(llmchunk.Choices)-1].Delta.ToolCalls[0].Function.Name
|
||||||
|
if fname != "" {
|
||||||
|
resp.FuncName = fname
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if llmchunk.Choices[len(llmchunk.Choices)-1].FinishReason == "stop" {
|
if llmchunk.Choices[len(llmchunk.Choices)-1].FinishReason == "stop" {
|
||||||
if resp.Chunk != "" {
|
if resp.Chunk != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user