mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-20 07:16:10 +01:00
🐛 Unable to set up Azure OpenAI https://github.com/siyuan-note/siyuan/issues/10469
This commit is contained in:
parent
9f69d7dc4a
commit
77885a8cc0
10 changed files with 35 additions and 3 deletions
|
|
@ -37,6 +37,7 @@ type OpenAI struct {
|
|||
APIBaseURL string `json:"apiBaseURL"`
|
||||
APIUserAgent string `json:"apiUserAgent"`
|
||||
APIProvider string `json:"apiProvider"` // OpenAI, Azure
|
||||
APIVersion string `json:"apiVersion"` // Azure API version
|
||||
}
|
||||
|
||||
func NewAI() *AI {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ func chatGPTContinueWrite(msg string, contextMsgs []string, cloud bool) (ret str
|
|||
if cloud {
|
||||
gpt = &CloudGPT{}
|
||||
} else {
|
||||
gpt = &OpenAIGPT{c: util.NewOpenAIClient(Conf.AI.OpenAI.APIKey, Conf.AI.OpenAI.APIProxy, Conf.AI.OpenAI.APIBaseURL, Conf.AI.OpenAI.APIUserAgent)}
|
||||
gpt = &OpenAIGPT{c: util.NewOpenAIClient(Conf.AI.OpenAI.APIKey, Conf.AI.OpenAI.APIProxy, Conf.AI.OpenAI.APIBaseURL, Conf.AI.OpenAI.APIUserAgent, Conf.AI.OpenAI.APIVersion, Conf.AI.OpenAI.APIProvider)}
|
||||
}
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
|
|
|
|||
|
|
@ -75,8 +75,13 @@ func ChatGPT(msg string, contextMsgs []string, c *openai.Client, model string, m
|
|||
return
|
||||
}
|
||||
|
||||
func NewOpenAIClient(apiKey, apiProxy, apiBaseURL, apiUserAgent string) *openai.Client {
|
||||
func NewOpenAIClient(apiKey, apiProxy, apiBaseURL, apiUserAgent, apiVersion, apiProvider string) *openai.Client {
|
||||
config := openai.DefaultConfig(apiKey)
|
||||
if "Azure" == apiProvider {
|
||||
config = openai.DefaultAzureConfig(apiKey, apiBaseURL)
|
||||
config.APIVersion = apiVersion
|
||||
}
|
||||
|
||||
transport := &http.Transport{}
|
||||
if "" != apiProxy {
|
||||
proxyUrl, err := url.Parse(apiProxy)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue