langchaingo
langchaingo copied to clipboard
openai: functions are deprecated in the API, "tools" is the new way
Based on the API docs of the new chat endpoints, function_call is now deprecated and users are encouraged to use tool_choice instead.
The only supported kind of tool is still a function, but this leaves space for future expansion.
This may be related to https://github.com/tmc/langchaingo/pull/145 -- if we switch to use https://github.com/sashabaranov/go-openai, we won't have to work as hard to changes in the API
ToolChoice option is not respected!
It should be filled here:
req := &openaiclient.ChatRequest{
Model: opts.Model,
StopWords: opts.StopWords,
Messages: chatMsgs,
StreamingFunc: opts.StreamingFunc,
Temperature: opts.Temperature,
MaxTokens: opts.MaxTokens,
N: opts.N,
FrequencyPenalty: opts.FrequencyPenalty,
PresencePenalty: opts.PresencePenalty,
FunctionCallBehavior: openaiclient.FunctionCallBehavior(opts.FunctionCallBehavior),
Seed: opts.Seed,
Metadata: opts.Metadata,
}