mirror of
https://github.com/mudler/LocalAI.git
synced 2024-06-07 19:40:48 +00:00
Signed-off-by: Dave <dave@gray101.com> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Signed-off-by: Dave <dave@gray101.com> Co-authored-by: Dave <dave@gray101.com>
This commit is contained in:
parent
bcaa320f36
commit
6b06d4e0af
@ -778,13 +778,16 @@ func parseFunctionCall(llmresult string, multipleResults bool) []funcCallResults
|
||||
// As we have to change the result before processing, we can't stream the answer token-by-token (yet?)
|
||||
ss := map[string]interface{}{}
|
||||
// This prevent newlines to break JSON parsing for clients
|
||||
// s := utils.EscapeNewLines(llmresult)
|
||||
json.Unmarshal([]byte(llmresult), &ss)
|
||||
s := utils.EscapeNewLines(llmresult)
|
||||
if err := json.Unmarshal([]byte(s), &ss); err != nil {
|
||||
log.Error().Msgf("error unmarshalling JSON: %s", err.Error())
|
||||
return results
|
||||
}
|
||||
|
||||
// The grammar defines the function name as "function", while OpenAI returns "name"
|
||||
func_name, ok := ss["function"]
|
||||
if !ok {
|
||||
log.Debug().Msg("ss[function] is not OK!")
|
||||
log.Debug().Msgf("ss[function] is not OK!, llm result: %q", llmresult)
|
||||
return results
|
||||
}
|
||||
// Similarly, while here arguments is a map[string]interface{}, OpenAI actually want a stringified object
|
||||
|
Loading…
Reference in New Issue
Block a user