Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit

Permalink
feat: 由于独立计费,所以增加gpt4-mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
liuhuapiaoyuan committed Jan 1, 2024
1 parent 2fa28f7 commit 6b70eb4
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 6 deletions.
29 changes: 29 additions & 0 deletions backend-api/backend-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,12 @@ func ProxyAll(r *ghttp.Request) {
// 如果path 以 ‘backend-api/files’ startwith开头
isCreateConversation := strings.HasPrefix(path, "/backend-api/conversation/gen_title")
isShare := strings.HasPrefix(path, "/backend-api/share/creat")
isLoadModels := strings.HasPrefix(path, "/backend-api/models")

if isCreateConversation {
CreateConversation(ctx, userId, accessToken, r.UserAgent(), path)
} else if isLoadModels {
AttachGPT4Mobile(ctx, response)
} else if isShare {
originalBody, shouldReturn, returnValue := loadRespString(response)
if shouldReturn {
Expand Down Expand Up @@ -125,6 +128,32 @@ func ProxyAll(r *ghttp.Request) {

}

// 处理models 增加gpt-4-mobile
func AttachGPT4Mobile(ctx g.Ctx, response *http.Response) error {
// 提取 /backend-api/models
originalBody, shouldReturn, returnValue := loadRespString(response)
if shouldReturn {
return returnValue
}
modifiedBody := string(originalBody)
if strings.Contains(modifiedBody, "gpt-4") {
resJson := gjson.New(modifiedBody)
models := resJson.Get("models").Array()
newObject := gjson.New(`{"capabilities":{},"description":"Browsing, Advanced Data Analysis, and DALL·E are now built into GPT-4","enabled_tools":["tools","tools2"],"max_tokens":32767,"product_features":{"attachments":{"accepted_mime_types":["text/x-csharp","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/x-tex","text/x-typescript","text/plain","text/x-ruby","application/msword","text/x-php","text/x-c++","text/markdown","application/x-latext","text/x-c","text/javascript","text/html","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/json","text/x-java","application/pdf","text/x-script.python","text/x-sh"],"can_accept_all_mime_types":true,"image_mime_types":["image/jpeg","image/webp","image/gif","image/png"],"type":"retrieval"}},"slug":"gpt-4-mobile","tags":["confidential","gpt4","plus"],"title":"GPT4 (Mobile)"}`)
models = append(models, newObject)
resJson.Set("models", models)
modifiedBody = resJson.String()
}
// 将修改后的内容写回响应体
response.Body = io.NopCloser(bytes.NewBufferString(modifiedBody))
// 更新Content-Length
response.ContentLength = int64(len(modifiedBody))
response.Header.Set("Content-Length", strconv.Itoa(len(modifiedBody)))
// 删除Content-Encoding头部
response.Header.Del("Content-Encoding")
return nil
}

// 创建信息,接受参数 conversationId
func CreateConversation(ctx g.Ctx, userId int, AccessToken string, userAgent string, conversationPath string) {
// 提取 /backend-api/conversation/gen_title/{id}
Expand Down
11 changes: 5 additions & 6 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
server:
serverRoot: "resource/public"
clientMaxBodySize: 104857600 # 100MB in bytes 100*1024*1024
clientMaxBodySize: 104857600 # 100MB in bytes 100*1024*1024

logger:
path: "./data/logs/"
file: "{Y-m-d}.log"
level : "all"
level: "all"
stdout: true


database:
# default:
# type: "sqlite" # 数据库类型
Expand All @@ -33,7 +32,7 @@ redis:
cool:
address: "127.0.0.1:6379"
db: 0

cool:
autoMigrate: true
eps: true
Expand Down Expand Up @@ -62,5 +61,5 @@ CHATPROXY: "https://demo.xyhelper.cn"
AUTHKEY: "xyhelper"
ONLYTOKEN: false
CDNHOST: "https://file.chatgpt.ggss.club"

# 5a07e29c-31d8-4976-ba66-f183598587d9
ASSET_PREFIX: "https://cdn.chatgpt.ggss.club"
# 5a07e29c-31d8-4976-ba66-f183598587d9
1 change: 1 addition & 0 deletions resource/template/WtU07IOQoMFgLEFUvpFfy/chat.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html><head>{{.envScript}}<meta charSet="utf-8" /><title>ChatGPT</title><link rel="apple-touch-icon" sizes="180x180" href="{{.assetPrefix}}/_next/static/media/apple-touch-icon.59f2e898.png" /><link rel="icon" type="image/png" sizes="32x32" href="{{.assetPrefix}}/_next/static/media/favicon-32x32.be48395e.png" /><link rel="icon" type="image/png" sizes="16x16" href="{{.assetPrefix}}/_next/static/media/favicon-16x16.9b8dbb69.png" /><link rel="preconnect" href="{{.assetPrefix}}" /><meta name="title" content="ChatGPT: Get instant answers, find inspiration, learn something new" /><meta name="description" content="ChatGPT is a free-to-use AI system. Use it for engaging conversations, gain insights, automate tasks, and witness the future of AI, all in one place." /><meta name="keywords" content="ai chat,ai,chap gpt,chat gbt,chat gpt 3,chat gpt login,chat gpt website,chat gpt,chat gtp,chat openai,chat,chatai,chatbot gpt,chatg,chatgpt login,chatgpt,gpt chat,open ai,openai chat,openai chatgpt,openai" /><meta property="og:description" content="A conversational AI system that listens, learns, and challenges" /><meta name="robots" content="index, follow" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><meta property="og:title" content="ChatGPT" /><meta property="og:image" content="{{.assetPrefix}}/_next/static/media/chatgpt-share-og.49cbbffe.png" /><meta property="og:url" content="https://chat.openai.com" /><meta name="apple-itunes-app" content="app-id=6448311069" /><meta name="next-head-count" content="17" /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-buch.13189857.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-halbfett.977f1845.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-mono-buch.de677af1.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-mono-halbfett.b082e8e2.woff2" as="font" crossorigin /><link data-next-font rel="preconnect" href="/" crossorigin="anonymous" /><link rel="preload" href="{{.assetPrefix}}/_next/static/css/73fc0a5f171c2f83.css" as="style" /><link rel="stylesheet" href="{{.assetPrefix}}/_next/static/css/73fc0a5f171c2f83.css" data-n-g /><noscript data-n-css></noscript><script defer nomodule src="{{.assetPrefix}}/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="{{.assetPrefix}}/_next/static/chunks/webpack-e9f77ccad7f872cc.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/framework-10a404587b40544b.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/main-5b2c736082034b80.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/_app-ad5681fd29f88764.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/%5B%5B...default%5D%5D-f655a2695b0d28dd.js" defer></script><script src="{{.assetPrefix}}/_next/static/WtU07IOQoMFgLEFUvpFfy/_buildManifest.js" defer></script><script src="{{.assetPrefix}}/_next/static/WtU07IOQoMFgLEFUvpFfy/_ssgManifest.js" defer></script></head><body class="antialiased"><div id="__next"><script>!function(){try{var d=document.documentElement,c=d.classList;c.remove('light','dark');var e=localStorage.getItem('theme');if('system'===e||(!e&&true)){var t='(prefers-color-scheme: dark)',m=window.matchMedia(t);if(m.media!==t||m.matches){d.style.colorScheme = 'dark';c.add('dark')}else{d.style.colorScheme = 'light';c.add('light')}}else if(e){c.add(e|| '')}if(e==='light'||e==='dark')d.style.colorScheme=e}catch(e){}}()</script><div class="relative z-0 flex h-full w-full overflow-hidden"><div class="relative flex h-full max-w-full flex-1 flex-col overflow-hidden"><main class="relative h-full w-full flex-1 overflow-auto transition-width"></main></div></div><div class="absolute left-0 right-0 top-0 z-[2]"></div></div><script id="__NEXT_DATA__" type="application/json">{{.props}}</script><script></script></body></html>
1 change: 1 addition & 0 deletions resource/template/WtU07IOQoMFgLEFUvpFfy/discovery.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html><head>{{.envScript}}<meta charSet="utf-8" /><title>ChatGPT</title><link rel="apple-touch-icon" sizes="180x180" href="{{.assetPrefix}}/_next/static/media/apple-touch-icon.59f2e898.png" /><link rel="icon" type="image/png" sizes="32x32" href="{{.assetPrefix}}/_next/static/media/favicon-32x32.be48395e.png" /><link rel="icon" type="image/png" sizes="16x16" href="{{.assetPrefix}}/_next/static/media/favicon-16x16.9b8dbb69.png" /><link rel="preconnect" href="{{.assetPrefix}}" /><meta name="title" content="ChatGPT: Get instant answers, find inspiration, learn something new" /><meta name="description" content="ChatGPT is a free-to-use AI system. Use it for engaging conversations, gain insights, automate tasks, and witness the future of AI, all in one place." /><meta name="keywords" content="ai chat,ai,chap gpt,chat gbt,chat gpt 3,chat gpt login,chat gpt website,chat gpt,chat gtp,chat openai,chat,chatai,chatbot gpt,chatg,chatgpt login,chatgpt,gpt chat,open ai,openai chat,openai chatgpt,openai" /><meta property="og:description" content="A conversational AI system that listens, learns, and challenges" /><meta name="robots" content="index, follow" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><meta property="og:title" content="ChatGPT" /><meta property="og:image" content="{{.assetPrefix}}/_next/static/media/chatgpt-share-og.49cbbffe.png" /><meta property="og:url" content="https://chat.openai.com" /><meta name="apple-itunes-app" content="app-id=6448311069" /><meta name="next-head-count" content="17" /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-buch.13189857.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-halbfett.977f1845.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-mono-buch.de677af1.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-mono-halbfett.b082e8e2.woff2" as="font" crossorigin /><link data-next-font rel="preconnect" href="/" crossorigin="anonymous" /><link rel="preload" href="{{.assetPrefix}}/_next/static/css/73fc0a5f171c2f83.css" as="style" /><link rel="stylesheet" href="{{.assetPrefix}}/_next/static/css/73fc0a5f171c2f83.css" data-n-g /><noscript data-n-css></noscript><script defer nomodule src="{{.assetPrefix}}/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="{{.assetPrefix}}/_next/static/chunks/webpack-e9f77ccad7f872cc.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/framework-10a404587b40544b.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/main-5b2c736082034b80.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/_app-ad5681fd29f88764.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/6276-daa78bdf869b1a13.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/gpts/discovery-04d6cb68d3f1d0f9.js" defer></script><script src="{{.assetPrefix}}/_next/static/WtU07IOQoMFgLEFUvpFfy/_buildManifest.js" defer></script><script src="{{.assetPrefix}}/_next/static/WtU07IOQoMFgLEFUvpFfy/_ssgManifest.js" defer></script></head><body class="antialiased"><div id="__next"><script>!function(){try{var d=document.documentElement,c=d.classList;c.remove('light','dark');var e=localStorage.getItem('theme');if('system'===e||(!e&&true)){var t='(prefers-color-scheme: dark)',m=window.matchMedia(t);if(m.media!==t||m.matches){d.style.colorScheme = 'dark';c.add('dark')}else{d.style.colorScheme = 'light';c.add('light')}}else if(e){c.add(e|| '')}if(e==='light'||e==='dark')d.style.colorScheme=e}catch(e){}}()</script><div class="absolute left-0 right-0 top-0 z-[2]"></div></div><script id="__NEXT_DATA__" type="application/json">{{.props}}</script><script></script></body></html>
1 change: 1 addition & 0 deletions resource/template/WtU07IOQoMFgLEFUvpFfy/editor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html><head>{{.envScript}}<meta charSet="utf-8" /><title>ChatGPT</title><link rel="apple-touch-icon" sizes="180x180" href="{{.assetPrefix}}/_next/static/media/apple-touch-icon.59f2e898.png" /><link rel="icon" type="image/png" sizes="32x32" href="{{.assetPrefix}}/_next/static/media/favicon-32x32.be48395e.png" /><link rel="icon" type="image/png" sizes="16x16" href="{{.assetPrefix}}/_next/static/media/favicon-16x16.9b8dbb69.png" /><link rel="preconnect" href="{{.assetPrefix}}" /><meta name="title" content="ChatGPT: Get instant answers, find inspiration, learn something new" /><meta name="description" content="ChatGPT is a free-to-use AI system. Use it for engaging conversations, gain insights, automate tasks, and witness the future of AI, all in one place." /><meta name="keywords" content="ai chat,ai,chap gpt,chat gbt,chat gpt 3,chat gpt login,chat gpt website,chat gpt,chat gtp,chat openai,chat,chatai,chatbot gpt,chatg,chatgpt login,chatgpt,gpt chat,open ai,openai chat,openai chatgpt,openai" /><meta property="og:description" content="A conversational AI system that listens, learns, and challenges" /><meta name="robots" content="index, follow" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><meta property="og:title" content="ChatGPT" /><meta property="og:image" content="{{.assetPrefix}}/_next/static/media/chatgpt-share-og.49cbbffe.png" /><meta property="og:url" content="https://chat.openai.com" /><meta name="apple-itunes-app" content="app-id=6448311069" /><meta name="next-head-count" content="17" /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-buch.13189857.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-halbfett.977f1845.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-mono-buch.de677af1.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-mono-halbfett.b082e8e2.woff2" as="font" crossorigin /><link data-next-font rel="preconnect" href="/" crossorigin="anonymous" /><link rel="preload" href="{{.assetPrefix}}/_next/static/css/73fc0a5f171c2f83.css" as="style" /><link rel="stylesheet" href="{{.assetPrefix}}/_next/static/css/73fc0a5f171c2f83.css" data-n-g /><noscript data-n-css></noscript><script defer nomodule src="{{.assetPrefix}}/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="{{.assetPrefix}}/_next/static/chunks/webpack-e9f77ccad7f872cc.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/framework-10a404587b40544b.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/main-5b2c736082034b80.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/_app-ad5681fd29f88764.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/192-ad27ef03b2f15a6c.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/gpts/editor-066904f093c6dd65.js" defer></script><script src="{{.assetPrefix}}/_next/static/WtU07IOQoMFgLEFUvpFfy/_buildManifest.js" defer></script><script src="{{.assetPrefix}}/_next/static/WtU07IOQoMFgLEFUvpFfy/_ssgManifest.js" defer></script></head><body class="antialiased"><div id="__next"><script>!function(){try{var d=document.documentElement,c=d.classList;c.remove('light','dark');var e=localStorage.getItem('theme');if('system'===e||(!e&&true)){var t='(prefers-color-scheme: dark)',m=window.matchMedia(t);if(m.media!==t||m.matches){d.style.colorScheme = 'dark';c.add('dark')}else{d.style.colorScheme = 'light';c.add('light')}}else if(e){c.add(e|| '')}if(e==='light'||e==='dark')d.style.colorScheme=e}catch(e){}}()</script><div class="absolute left-0 right-0 top-0 z-[2]"></div></div><script id="__NEXT_DATA__" type="application/json">{{.props}}</script><script></script></body></html>
1 change: 1 addition & 0 deletions resource/template/WtU07IOQoMFgLEFUvpFfy/g.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html><head>{{.envScript}}<meta charSet="utf-8" /><title>ChatGPT</title><link rel="apple-touch-icon" sizes="180x180" href="{{.assetPrefix}}/_next/static/media/apple-touch-icon.59f2e898.png" /><link rel="icon" type="image/png" sizes="32x32" href="{{.assetPrefix}}/_next/static/media/favicon-32x32.be48395e.png" /><link rel="icon" type="image/png" sizes="16x16" href="{{.assetPrefix}}/_next/static/media/favicon-16x16.9b8dbb69.png" /><link rel="preconnect" href="{{.assetPrefix}}" /><meta name="title" content="ChatGPT: Get instant answers, find inspiration, learn something new" /><meta name="description" content="ChatGPT is a free-to-use AI system. Use it for engaging conversations, gain insights, automate tasks, and witness the future of AI, all in one place." /><meta name="keywords" content="ai chat,ai,chap gpt,chat gbt,chat gpt 3,chat gpt login,chat gpt website,chat gpt,chat gtp,chat openai,chat,chatai,chatbot gpt,chatg,chatgpt login,chatgpt,gpt chat,open ai,openai chat,openai chatgpt,openai" /><meta property="og:description" content="A conversational AI system that listens, learns, and challenges" /><meta name="robots" content="index, follow" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><meta property="og:title" content="ChatGPT" /><meta property="og:image" content="{{.assetPrefix}}/_next/static/media/chatgpt-share-og.49cbbffe.png" /><meta property="og:url" content="https://chat.openai.com" /><meta name="apple-itunes-app" content="app-id=6448311069" /><meta name="next-head-count" content="17" /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-buch.13189857.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-halbfett.977f1845.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-mono-buch.de677af1.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-mono-halbfett.b082e8e2.woff2" as="font" crossorigin /><link data-next-font rel="preconnect" href="/" crossorigin="anonymous" /><link rel="preload" href="{{.assetPrefix}}/_next/static/css/73fc0a5f171c2f83.css" as="style" /><link rel="stylesheet" href="{{.assetPrefix}}/_next/static/css/73fc0a5f171c2f83.css" data-n-g /><noscript data-n-css></noscript><script defer nomodule src="{{.assetPrefix}}/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="{{.assetPrefix}}/_next/static/chunks/webpack-e9f77ccad7f872cc.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/framework-10a404587b40544b.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/main-5b2c736082034b80.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/_app-ad5681fd29f88764.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/g/%5BgizmoId%5D-c865238c12b838da.js" defer></script><script src="{{.assetPrefix}}/_next/static/WtU07IOQoMFgLEFUvpFfy/_buildManifest.js" defer></script><script src="{{.assetPrefix}}/_next/static/WtU07IOQoMFgLEFUvpFfy/_ssgManifest.js" defer></script></head><body class="antialiased"><div id="__next"><script>!function(){try{var d=document.documentElement,c=d.classList;c.remove('light','dark');var e=localStorage.getItem('theme');if('system'===e||(!e&&true)){var t='(prefers-color-scheme: dark)',m=window.matchMedia(t);if(m.media!==t||m.matches){d.style.colorScheme = 'dark';c.add('dark')}else{d.style.colorScheme = 'light';c.add('light')}}else if(e){c.add(e|| '')}if(e==='light'||e==='dark')d.style.colorScheme=e}catch(e){}}()</script><div class="relative z-0 flex h-full w-full overflow-hidden"><div class="relative flex h-full max-w-full flex-1 flex-col overflow-hidden"><main class="relative h-full w-full flex-1 overflow-auto transition-width"></main></div></div><div class="absolute left-0 right-0 top-0 z-[2]"></div></div><script id="__NEXT_DATA__" type="application/json">{{.props}}</script><script></script></body></html>
Loading

0 comments on commit 6b70eb4

Please sign in to comment.