Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinlic committed Mar 16, 2024
0 parents commit 700233d
Show file tree
Hide file tree
Showing 34 changed files with 2,526 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
logs
dist
doc
node_modules
.vscode
.git
.gitignore
README.md
*.tar.gz
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
node_modules/
logs/
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:lts AS BUILD_IMAGE

WORKDIR /app

COPY . /app

RUN npm i --registry http://registry.npmmirror.com && npm run build

FROM node:lts-alpine

COPY --from=BUILD_IMAGE /app/configs ./configs
COPY --from=BUILD_IMAGE /app/package.json ./package.json
COPY --from=BUILD_IMAGE /app/dist ./dist
COPY --from=BUILD_IMAGE /app/node_modules ./node_modules

WORKDIR /app

EXPOSE 8000

CMD ["npm", "start"]
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Emohaa AI Free 服务

![](https://img.shields.io/github/license/llm-red-team/emohaa-free-api.svg)
![](https://img.shields.io/github/stars/llm-red-team/emohaa-free-api.svg)
![](https://img.shields.io/github/forks/llm-red-team/emohaa-free-api.svg)
![](https://img.shields.io/docker/pulls/vinlic/emohaa-free-api.svg)

支持高速流式输出、支持多轮对话,零配置部署,多路token支持,自动清理会话痕迹。

与ChatGPT接口完全兼容。
6 changes: 6 additions & 0 deletions configs/dev/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# 服务名称
name: emohaa-free-api
# 服务绑定主机地址
host: '0.0.0.0'
# 服务绑定端口
port: 8000
14 changes: 14 additions & 0 deletions configs/dev/system.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 是否开启请求日志
requestLog: true
# 临时目录路径
tmpDir: ./tmp
# 日志目录路径
logDir: ./logs
# 日志写入间隔(毫秒)
logWriteInterval: 200
# 日志文件有效期(毫秒)
logFileExpires: 2626560000
# 公共目录路径
publicDir: ./public
# 临时文件有效期(毫秒)
tmpFileExpires: 86400000
Empty file added libs.d.ts
Empty file.
49 changes: 49 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "emohaa-free-api",
"version": "0.0.1",
"description": "Emohaa Free API Server",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"directories": {
"dist": "dist"
},
"files": [
"dist/"
],
"scripts": {
"dev": "tsup src/index.ts --format cjs,esm --sourcemap --dts --publicDir public --watch --onSuccess \"node dist/index.js\"",
"start": "node dist/index.js",
"build": "tsup src/index.ts --format cjs,esm --sourcemap --dts --clean --publicDir public"
},
"author": "Vinlic",
"license": "ISC",
"dependencies": {
"axios": "^1.6.7",
"colors": "^1.4.0",
"crc-32": "^1.2.2",
"cron": "^3.1.6",
"date-fns": "^3.3.1",
"eventsource-parser": "^1.1.2",
"fs-extra": "^11.2.0",
"koa": "^2.15.0",
"koa-body": "^5.0.0",
"koa-bodyparser": "^4.4.1",
"koa-range": "^0.3.0",
"koa-router": "^12.0.1",
"koa2-cors": "^2.0.6",
"lodash": "^4.17.21",
"mime": "^4.0.1",
"minimist": "^1.2.8",
"randomstring": "^1.3.0",
"uuid": "^9.0.1",
"yaml": "^2.3.4"
},
"devDependencies": {
"@types/lodash": "^4.14.202",
"@types/mime": "^3.0.4",
"tsup": "^8.0.2",
"typescript": "^5.3.3"
}
}
9 changes: 9 additions & 0 deletions src/api/consts/exceptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
API_TEST: [-9999, 'API异常错误'],
API_REQUEST_PARAMS_INVALID: [-2000, '请求参数非法'],
API_REQUEST_FAILED: [-2001, '请求失败'],
API_TOKEN_EXPIRES: [-2002, 'Token已失效'],
API_FILE_URL_INVALID: [-2003, '远程文件URL非法'],
API_FILE_EXECEEDS_SIZE: [-2004, '远程文件超出大小'],
API_CHAT_STREAM_PUSHING: [-2005, '已有对话流正在输出']
}
Loading

0 comments on commit 700233d

Please sign in to comment.