mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-21 21:32:13 +01:00
added openaibaseurl parameter to client:set (#141)
This commit is contained in:
parent
96980b2f83
commit
535fd0d7d9
@ -3628,8 +3628,21 @@ func ClientSetCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (ss
|
||||
return nil, fmt.Errorf("error updating client openai maxchoices: %v", err)
|
||||
}
|
||||
}
|
||||
if aiBaseURL, found := pk.Kwargs["openaibaseurl"]; found {
|
||||
aiOpts := clientData.OpenAIOpts
|
||||
if aiOpts == nil {
|
||||
aiOpts = &sstore.OpenAIOptsType{}
|
||||
clientData.OpenAIOpts = aiOpts
|
||||
}
|
||||
aiOpts.BaseURL = aiBaseURL
|
||||
varsUpdated = append(varsUpdated, "openaibaseurl")
|
||||
err = sstore.UpdateClientOpenAIOpts(ctx, *aiOpts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error updating client openai base url: %v", err)
|
||||
}
|
||||
}
|
||||
if len(varsUpdated) == 0 {
|
||||
return nil, fmt.Errorf("/client:set requires a value to set: %s", formatStrs([]string{"termfontsize", "openaiapitoken", "openaimodel", "openaimaxtokens", "openaimaxchoices"}, "or", false))
|
||||
return nil, fmt.Errorf("/client:set requires a value to set: %s", formatStrs([]string{"termfontsize", "openaiapitoken", "openaimodel", "openaibaseurl", "openaimaxtokens", "openaimaxchoices"}, "or", false))
|
||||
}
|
||||
clientData, err = sstore.EnsureClientData(ctx)
|
||||
if err != nil {
|
||||
|
@ -49,7 +49,11 @@ func RunCompletion(ctx context.Context, opts *sstore.OpenAIOptsType, prompt []ss
|
||||
if opts.APIToken == "" {
|
||||
return nil, fmt.Errorf("no api token")
|
||||
}
|
||||
client := openaiapi.NewClient(opts.APIToken)
|
||||
clientConfig := openaiapi.DefaultConfig(opts.APIToken)
|
||||
if opts.BaseURL != "" {
|
||||
clientConfig.BaseURL = opts.BaseURL
|
||||
}
|
||||
client := openaiapi.NewClientWithConfig(clientConfig)
|
||||
req := openaiapi.ChatCompletionRequest{
|
||||
Model: opts.Model,
|
||||
Messages: convertPrompt(prompt),
|
||||
@ -78,7 +82,11 @@ func RunCompletionStream(ctx context.Context, opts *sstore.OpenAIOptsType, promp
|
||||
if opts.APIToken == "" {
|
||||
return nil, fmt.Errorf("no api token")
|
||||
}
|
||||
client := openaiapi.NewClient(opts.APIToken)
|
||||
clientConfig := openaiapi.DefaultConfig(opts.APIToken)
|
||||
if opts.BaseURL != "" {
|
||||
clientConfig.BaseURL = opts.BaseURL
|
||||
}
|
||||
client := openaiapi.NewClientWithConfig(clientConfig)
|
||||
req := openaiapi.ChatCompletionRequest{
|
||||
Model: opts.Model,
|
||||
Messages: convertPrompt(prompt),
|
||||
|
@ -433,7 +433,7 @@ func (h *HistoryItemType) FromMap(m map[string]interface{}) bool {
|
||||
|
||||
type ScreenOptsType struct {
|
||||
TabColor string `json:"tabcolor,omitempty"`
|
||||
TabIcon string `json:"tabicon,omitempty"`
|
||||
TabIcon string `json:"tabicon,omitempty"`
|
||||
PTerm string `json:"pterm,omitempty"`
|
||||
}
|
||||
|
||||
@ -924,6 +924,7 @@ type RemoteOptsType struct {
|
||||
type OpenAIOptsType struct {
|
||||
Model string `json:"model"`
|
||||
APIToken string `json:"apitoken"`
|
||||
BaseURL string `json:"baseurl,omitempty"`
|
||||
MaxTokens int `json:"maxtokens,omitempty"`
|
||||
MaxChoices int `json:"maxchoices,omitempty"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user