mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-18 06:17:06 +00:00
fix: openAiBaseUrl为空的情况
This commit is contained in:
parent
b140a9955b
commit
4ae57ee075
2 changed files with 6 additions and 6 deletions
|
|
@ -363,7 +363,7 @@ export async function isCN () {
|
||||||
try {
|
try {
|
||||||
let response = await fetch('https://ipinfo.io/country')
|
let response = await fetch('https://ipinfo.io/country')
|
||||||
let countryCode = (await response.text()).trim()
|
let countryCode = (await response.text()).trim()
|
||||||
await redis.set('CHATGPT:COUNTRY_CODE', countryCode, { EX: 3600 * 24 * 7 })
|
await redis.set('CHATGPT:COUNTRY_CODE', countryCode, { EX: 3600 })
|
||||||
if (countryCode !== 'CN') {
|
if (countryCode !== 'CN') {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Configuration, OpenAIApi } from 'openai'
|
import { Configuration, OpenAIApi } from 'openai'
|
||||||
import {Config, defaultOpenAIReverseProxy, officialChatGPTAPI} from './config.js'
|
import {Config, defaultOpenAIAPI, defaultOpenAIReverseProxy, officialChatGPTAPI} from './config.js'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import { mkdirs } from './common.js'
|
import {isCN, mkdirs} from './common.js'
|
||||||
let proxy
|
let proxy
|
||||||
if (Config.proxy) {
|
if (Config.proxy) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -24,7 +24,7 @@ export async function createImage (prompt, n = 1, size = '512x512') {
|
||||||
basePath = defaultOpenAIReverseProxy
|
basePath = defaultOpenAIReverseProxy
|
||||||
}
|
}
|
||||||
if (!Config.openAiBaseUrl) {
|
if (!Config.openAiBaseUrl) {
|
||||||
basePath = defaultOpenAIReverseProxy
|
basePath = await isCN() ? defaultOpenAIReverseProxy : defaultOpenAIAPI
|
||||||
}
|
}
|
||||||
const configuration = new Configuration({
|
const configuration = new Configuration({
|
||||||
apiKey: Config.apiKey,
|
apiKey: Config.apiKey,
|
||||||
|
|
@ -54,7 +54,7 @@ export async function imageVariation (imageUrl, n = 1, size = '512x512') {
|
||||||
basePath = defaultOpenAIReverseProxy
|
basePath = defaultOpenAIReverseProxy
|
||||||
}
|
}
|
||||||
if (!Config.openAiBaseUrl) {
|
if (!Config.openAiBaseUrl) {
|
||||||
basePath = defaultOpenAIReverseProxy
|
basePath = await isCN() ? defaultOpenAIReverseProxy : defaultOpenAIAPI
|
||||||
}
|
}
|
||||||
const configuration = new Configuration({
|
const configuration = new Configuration({
|
||||||
apiKey: Config.apiKey,
|
apiKey: Config.apiKey,
|
||||||
|
|
@ -131,7 +131,7 @@ export async function editImage (originalImage, mask = [], prompt, num = 1, size
|
||||||
basePath = defaultOpenAIReverseProxy
|
basePath = defaultOpenAIReverseProxy
|
||||||
}
|
}
|
||||||
if (!Config.openAiBaseUrl) {
|
if (!Config.openAiBaseUrl) {
|
||||||
basePath = defaultOpenAIReverseProxy
|
basePath = await isCN() ? defaultOpenAIReverseProxy : defaultOpenAIAPI
|
||||||
}
|
}
|
||||||
const configuration = new Configuration({
|
const configuration = new Configuration({
|
||||||
apiKey: Config.apiKey,
|
apiKey: Config.apiKey,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue