@tencent-ai/agent-server 0.1.0-next.731
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.genie/dist/backend/index.js +1 -0
- package/README.md +73 -0
- package/bin/agent-server +2 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Genie - Agent Server
|
|
2
|
+
|
|
3
|
+
### 安装应用
|
|
4
|
+
```
|
|
5
|
+
npm install @genie/agent-server
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
### 配置环境变量
|
|
9
|
+
|
|
10
|
+
在项目根目录下新建.env文件,配置相关的OPEN API的信息
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
# OpenAI API Key
|
|
14
|
+
OPENAI_API_KEY=
|
|
15
|
+
MODEL_NAME=
|
|
16
|
+
BASE_URL=
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 启动服务
|
|
20
|
+
|
|
21
|
+
服务默认运行在3000端口
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
npx agent-server
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 修改端口
|
|
28
|
+
|
|
29
|
+
如需要将端口修改为3009
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
// package.json, 服务将在3009启动
|
|
33
|
+
|
|
34
|
+
"scripts": {
|
|
35
|
+
"server": "npx cross-env SERVER_PORT=3009 agent-server"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
安装cross-env
|
|
41
|
+
```
|
|
42
|
+
npm install -D cross-env
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
启动服务
|
|
46
|
+
```
|
|
47
|
+
npm run server
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 接口
|
|
51
|
+
|
|
52
|
+
- 发起对话
|
|
53
|
+
```
|
|
54
|
+
url: /api/v1/chat
|
|
55
|
+
method: POST
|
|
56
|
+
payload: {
|
|
57
|
+
"messages":[{"role":"user","content":"写一个排序算法"}]
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
对话发起后,将会流式返回数据。
|
|
62
|
+
|
|
63
|
+
示例:
|
|
64
|
+
```
|
|
65
|
+
fetch("http://localhost:3000/api/v1/chat", {
|
|
66
|
+
"headers": {
|
|
67
|
+
"content-type": "application/json",
|
|
68
|
+
},
|
|
69
|
+
"body": "{\"messages\":[{\"role\":\"user\",\"content\":\"写一个排序算法\"}]}",
|
|
70
|
+
"method": "POST",
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
package/bin/agent-server
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tencent-ai/agent-server",
|
|
3
|
+
"version": "0.1.0-next.731+506d1978",
|
|
4
|
+
"description": "Genie - Agent Server Component",
|
|
5
|
+
"main": ".genie/dist/backend/index.js",
|
|
6
|
+
"typings": "lib/node/index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"bin": {
|
|
9
|
+
"agent-server": "./bin/agent-server"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public",
|
|
13
|
+
"name": "@tencent-ai/agent-server"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"genie-component",
|
|
17
|
+
"cell-component",
|
|
18
|
+
"agent-server"
|
|
19
|
+
],
|
|
20
|
+
"files": [
|
|
21
|
+
".genie/dist/backend/**/*",
|
|
22
|
+
"bin"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"lint": "genie-component lint",
|
|
26
|
+
"build": "genie-component build",
|
|
27
|
+
"compile": "genie-component compile",
|
|
28
|
+
"watch": "genie-component watch",
|
|
29
|
+
"clean": "genie-component clean",
|
|
30
|
+
"test": "genie-component test:js",
|
|
31
|
+
"prepublishOnly": "chmod +x ./prepublish.sh && ./prepublish.sh",
|
|
32
|
+
"postpublish": "mv package.json.bak package.json"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@celljs/cli": "3.6.4",
|
|
36
|
+
"@genie/component": "0.0.0"
|
|
37
|
+
},
|
|
38
|
+
"gitHead": "506d1978648ab169a4b261a32aabcf2c10e20cdf"
|
|
39
|
+
}
|