wingbot 3.76.0 → 3.76.1-alpha.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot",
3
- "version": "3.76.0",
3
+ "version": "3.76.1-alpha.2",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
@@ -951,7 +951,7 @@ class BuildRouter extends Router {
951
951
  const { llmRouter } = this._resolvedContext;
952
952
 
953
953
  if (!llmRouter) {
954
- throw new Error(`Local LLM routing requires block.llmRouting prompt on block "${this._resolvedContext.blockName || ''}"`);
954
+ return null;
955
955
  }
956
956
 
957
957
  return llmRouter.route(route.path, llmRouting.classificationDescription, options);
package/src/ChatGpt.js CHANGED
@@ -31,6 +31,7 @@ const LLM = require('./LLM');
31
31
  * @prop {string} [apiVersion]
32
32
  * @prop {string} [apiKey] // for microsoft services
33
33
  * @prop {string} [authorization] // for chat gpt api
34
+ * @prop {number} [timeout=15000] - request timeout in ms; set to 0 to disable
34
35
  */
35
36
 
36
37
  /** @typedef {'gpt-3.5-turbo'|'gpt-4'|'gpt-4-32k'|'gpt-3.5-turbo-16k'|string} ChatGPTModel */
@@ -189,11 +190,13 @@ class ChatGpt {
189
190
  openAiEndpoint = 'https://api.openai.com/v1',
190
191
  apiKey,
191
192
  authorization,
193
+ timeout = 15000,
192
194
  ...rest
193
195
  } = options;
194
196
 
195
197
  this._apiKey = apiKey;
196
198
  this._authorization = authorization;
199
+ this._timeout = timeout;
197
200
 
198
201
  this._fetch = fetch;
199
202
 
@@ -446,14 +449,19 @@ class ChatGpt {
446
449
  ? { 'api-key': this._apiKey }
447
450
  : { Authorization: `Bearer ${this._authorization}` })
448
451
  },
449
- body: JSON.stringify(body)
452
+ body: JSON.stringify(body),
453
+ ...(this._timeout > 0 ? { timeout: this._timeout } : {})
450
454
  });
451
455
 
452
456
  ({ status, statusText } = response);
453
457
 
454
458
  responseText = await response.text();
455
459
  /** @type {ChatGPTResponse} */
456
- responseData = JSON.parse(responseText);
460
+ try {
461
+ responseData = JSON.parse(responseText);
462
+ } catch {
463
+ throw new Error(`Chat GPT ${status} (non-JSON): ${responseText.slice(0, 200)}`);
464
+ }
457
465
 
458
466
  if (status !== 200
459
467
  || !Array.isArray(responseData.choices)) {
@@ -1,121 +0,0 @@
1
- name: Push
2
-
3
- on:
4
- push:
5
- branches:
6
- - "**"
7
-
8
- permissions:
9
- contents: write
10
- jobs:
11
- test:
12
- name: test
13
- runs-on: ubuntu-latest
14
-
15
- strategy:
16
- matrix:
17
- node-version: [20.x]
18
-
19
- steps:
20
- - name: Checkout
21
- uses: actions/checkout@v4
22
-
23
- - name: Node.js ${{ matrix.node-version }} setup
24
- uses: actions/setup-node@v4
25
- with:
26
- node-version: ${{ matrix.node-version }}
27
- cache: "npm"
28
- registry-url: https://npm.pkg.github.com
29
- scope: "@wingbotai"
30
-
31
- - name: Npm install
32
- run: npm i
33
- env:
34
- NODE_AUTH_TOKEN: ${{ secrets.WINGBOT_PCKG_READ_PAT }}
35
-
36
- - name: Test
37
- run: npm run test
38
-
39
- # build-docs:
40
- # name: build docs
41
- # needs: test
42
- # runs-on: ubuntu-latest
43
-
44
- # if: github.ref != 'refs/heads/master'
45
-
46
- # strategy:
47
- # matrix:
48
- # node-version: [20.x]
49
-
50
- # steps:
51
- # - name: Checkout
52
- # uses: actions/checkout@v4
53
-
54
- # - name: Node.js ${{ matrix.node-version }} setup
55
- # uses: actions/setup-node@v4
56
- # with:
57
- # node-version: ${{ matrix.node-version }}
58
- # cache: "npm"
59
- # registry-url: https://npm.pkg.github.com
60
- # scope: '@wingbotai'
61
-
62
- # - name: Npm install
63
- # run: npm i
64
- # env:
65
- # NODE_AUTH_TOKEN: ${{ secrets.WINGBOT_PCKG_READ_PAT }}
66
-
67
- # - name: Npm install docs
68
- # run: cd documentation && npm install --legacy-peer-deps && cd ..
69
-
70
- # - name: Rewrite gatsby confing inside smoothdoc
71
- # run: cp documentation/smooth-doc-gatsby-config.js documentation/node_modules/smooth-doc/gatsby-config.js
72
-
73
- # - name: Generate mdx documentation files
74
- # run: node bin/makeApiDoc
75
-
76
- # - name: Build documentation website with gatsby
77
- # run: cd documentation && npm run build
78
-
79
- # build-and-deploy-docs:
80
- # name: build and deploy docs
81
- # runs-on: ubuntu-latest
82
-
83
- # if: github.ref == 'refs/heads/master'
84
-
85
- # strategy:
86
- # matrix:
87
- # node-version: [20.x]
88
-
89
- # steps:
90
- # - name: Checkout
91
- # uses: actions/checkout@v4
92
-
93
- # - name: Node.js ${{ matrix.node-version }} setup
94
- # uses: actions/setup-node@v4
95
- # with:
96
- # node-version: ${{ matrix.node-version }}
97
- # cache: "npm"
98
- # registry-url: https://npm.pkg.github.com
99
- # scope: '@wingbotai'
100
-
101
- # - name: Npm install
102
- # run: npm i
103
- # env:
104
- # NODE_AUTH_TOKEN: ${{ secrets.WINGBOT_PCKG_READ_PAT }}
105
-
106
- # - name: Npm install docs
107
- # run: cd documentation && npm install --legacy-peer-deps && cd ..
108
-
109
- # - name: Rewrite gatsby confing inside smoothdoc
110
- # run: cp documentation/smooth-doc-gatsby-config.js documentation/node_modules/smooth-doc/gatsby-config.js
111
-
112
- # - name: Generate mdx documentation files
113
- # run: node bin/makeApiDoc
114
-
115
- # - name: Build documentation website with gatsby
116
- # run: cd documentation && npm run build
117
-
118
- # - name: Deploy documentation to github pages
119
- # uses: JamesIves/github-pages-deploy-action@v4
120
- # with:
121
- # folder: documentation/public # The folder the action should deploy.
@@ -1,31 +0,0 @@
1
- name: Pull request
2
-
3
- on:
4
- pull_request:
5
- branches:
6
- - master
7
-
8
- jobs:
9
- test:
10
- runs-on: ubuntu-latest
11
-
12
- strategy:
13
- matrix:
14
- node-version: [20.x]
15
-
16
- steps:
17
-
18
- - name: Checkout
19
- uses: actions/checkout@v2
20
-
21
- - name: Node.js ${{ matrix.node-version }} setup
22
- uses: actions/setup-node@v3
23
- with:
24
- node-version: ${{ matrix.node-version }}
25
- cache: 'npm'
26
-
27
- - name: Npm install
28
- run: npm install
29
-
30
- - name: Test
31
- run: npm run test
@@ -1,4 +0,0 @@
1
- {
2
- "version": 1,
3
- "goals": {}
4
- }