Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
efdc6c75
authored
Jul 15, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support ChatGLM2 (close #274)
parent
1158a8c3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
5 deletions
+25
-5
README.md
+2
-1
controller/model.go
+18
-0
controller/relay-text.go
+5
-4
No files found.
README.md
View file @
efdc6c75
...
...
@@ -91,7 +91,8 @@ _✨ All in one 的 OpenAI 接口,整合各种 API 访问方式,开箱即用
+
邮箱登录注册以及通过邮箱进行密码重置。
+
[
GitHub 开放授权
](
https://github.com/settings/applications/new
)
。
+
微信公众号授权(需要额外部署
[
WeChat Server
](
https://github.com/songquanpeng/wechat-server
)
)。
20.
未来其他大模型开放 API 后,将第一时间支持,并将其封装成同样的 API 访问方式。
20.
支持
[
ChatGLM
](
https://github.com/THUDM/ChatGLM2-6B
)
。
21.
未来其他大模型开放 API 后,将第一时间支持,并将其封装成同样的 API 访问方式。
## 部署
### 基于 Docker 进行部署
...
...
controller/model.go
View file @
efdc6c75
...
...
@@ -252,6 +252,24 @@ func init() {
Root
:
"code-davinci-edit-001"
,
Parent
:
nil
,
},
{
Id
:
"ChatGLM"
,
Object
:
"model"
,
Created
:
1677649963
,
OwnedBy
:
"thudm"
,
Permission
:
permission
,
Root
:
"ChatGLM"
,
Parent
:
nil
,
},
{
Id
:
"ChatGLM2"
,
Object
:
"model"
,
Created
:
1677649963
,
OwnedBy
:
"thudm"
,
Permission
:
permission
,
Root
:
"ChatGLM2"
,
Parent
:
nil
,
},
}
openAIModelsMap
=
make
(
map
[
string
]
OpenAIModels
)
for
_
,
model
:=
range
openAIModels
{
...
...
controller/relay-text.go
View file @
efdc6c75
...
...
@@ -227,8 +227,8 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
return
0
,
nil
,
nil
}
if
i
:=
strings
.
Index
(
string
(
data
),
"
\n
\n
"
);
i
>=
0
{
return
i
+
2
,
data
[
0
:
i
],
nil
if
i
:=
strings
.
Index
(
string
(
data
),
"
\n
"
);
i
>=
0
{
return
i
+
1
,
data
[
0
:
i
],
nil
}
if
atEOF
{
...
...
@@ -242,8 +242,7 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
go
func
()
{
for
scanner
.
Scan
()
{
data
:=
scanner
.
Text
()
if
len
(
data
)
<
6
{
// must be something wrong!
common
.
SysError
(
"invalid stream response: "
+
data
)
if
len
(
data
)
<
6
{
// ignore blank line or wrong format
continue
}
dataChan
<-
data
...
...
@@ -286,6 +285,8 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
if
strings
.
HasPrefix
(
data
,
"data: [DONE]"
)
{
data
=
data
[
:
12
]
}
// some implementations may add \r at the end of data
data
=
strings
.
TrimSuffix
(
data
,
"
\r
"
)
c
.
Render
(
-
1
,
common
.
CustomEvent
{
Data
:
data
})
return
true
case
<-
stopChan
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment