langchaingo icon indicating copy to clipboard operation
langchaingo copied to clipboard

openai: functions are deprecated in the API, "tools" is the new way

Open eliben opened this issue 1 year ago • 1 comments

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

eliben avatar Jan 10 '24 14:01 eliben

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,
	}

President avatar May 10 '24 18:05 President