Skip to content

Commit

Permalink
feat: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangsx committed Jul 3, 2023
1 parent 4f0d931 commit fdda100
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,13 @@ docker-compose up --build -d

## 🚀 Let's Use GPT4

> Find supports model and site http://127.0.0.1:3000/supports [GET]
> The same as openai http://127.0.0.1:3000/v1/chat/completions [POST]
> Return when chat complete http://127.0.0.1:3000/ask?prompt=***&model=***&site=***
> Return when chat complete http://127.0.0.1:3000/ask?prompt=***&model=***&site=*** [POST/GET]
> Return with eventstream http://127.0.0.1:3000/ask/stream?prompt=***&model=***&site=***
> Return with eventstream http://127.0.0.1:3000/ask/stream?prompt=***&model=***&site=*** [POST/GET]
### Request Params 📝

Expand Down
8 changes: 6 additions & 2 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,13 @@ docker-compose up --build -d

## 🚀 Let's Use GPT4

> 当对话结束时返回示例 http://127.0.0.1:3000/ask?prompt=***&model=***&site=***
> 查看目前支持的site以及model http://127.0.0.1:3000/supports [GET]
> 以stream模式返回示例 http://127.0.0.1:3000/ask/stream?prompt=***&model=***&site=***
> 和openai一致的返回格式 http://127.0.0.1:3000/v1/chat/completions [POST]
> 会话完成之后返回示例 http://127.0.0.1:3000/ask?prompt=***&model=***&site=*** [POST/GET]
> 以stream模式返回示例 http://127.0.0.1:3000/ask/stream?prompt=***&model=***&site=*** [POST/GET]
### 请求参数,请放在query里 📝

Expand Down
25 changes: 25 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,31 @@ interface OpenAIReq {
messages: Message[];
}

interface Support {
site: string;
models: string[];
}

router.get('/supports', (ctx) => {
const result: Support[] = [];
for (const key in Site) {
//@ts-ignore
const site = Site[key];
//@ts-ignore
const chat = chatModel.get(site);
const support: Support = {site:site, models: []}
for (const mKey in ModelType) {
//@ts-ignore
const model = ModelType[mKey];
//@ts-ignore
if (chat?.support(model)) {
support.models.push(model);
}
}
result.push(support)
}
ctx.body = result;
});
router.get('/ask', AskHandle);
router.post('/ask', AskHandle);
router.get('/ask/stream', AskStreamHandle(EventStream))
Expand Down

0 comments on commit fdda100

Please sign in to comment.