@@ -159,21 +159,21 @@ async function createImage(prompt) {
159
159
}
160
160
161
161
// src/mm-client.ts
162
- import Log2 from "debug-level" ;
163
162
import { WebSocket } from "ws" ;
163
+ import fetch from "node-fetch" ;
164
164
import pkg from "@mattermost/client" ;
165
+ var { Client4, WebSocketClient } = pkg ;
165
166
if ( ! global . WebSocket ) {
166
167
global . WebSocket = WebSocket ;
167
168
}
168
- var { Client4, WebSocketClient } = pkg ;
169
- var log = new Log2 ( "bot" ) ;
169
+ global . fetch = fetch ;
170
170
var mattermostToken = process . env [ "MATTERMOST_TOKEN" ] ;
171
171
var matterMostURLString = process . env [ "MATTERMOST_URL" ] ;
172
172
if ( ! mattermostToken || ! matterMostURLString ) {
173
- log . error ( "MATTERMOST_TOKEN or MATTERMOST_URL is undefined" ) ;
173
+ botLog . error ( "MATTERMOST_TOKEN or MATTERMOST_URL is undefined" ) ;
174
174
throw new Error ( "MATTERMOST_TOKEN or MATTERMOST_URL is undefined" ) ;
175
175
}
176
- log . trace ( "Configuring Mattermost URL to " + matterMostURLString ) ;
176
+ botLog . trace ( "Configuring Mattermost URL to " + matterMostURLString ) ;
177
177
var mmClient = new Client4 ( ) ;
178
178
mmClient . setUrl ( matterMostURLString ) ;
179
179
mmClient . setToken ( mattermostToken ) ;
@@ -188,7 +188,7 @@ new Promise((_resolve, reject) => {
188
188
} ) . then ( ( ) => {
189
189
process . exit ( 0 ) ;
190
190
} ) . catch ( ( reason ) => {
191
- log . error ( reason ) ;
191
+ botLog . error ( reason ) ;
192
192
process . exit ( - 1 ) ;
193
193
} ) ;
194
194
function workaroundWebsocketPackageLostIssue ( webSocketClient ) {
@@ -204,13 +204,12 @@ workaroundWebsocketPackageLostIssue(wsClient);
204
204
wsClient . initialize ( wsUrl . toString ( ) , mattermostToken ) ;
205
205
206
206
// src/plugins/PluginBase.ts
207
- import { Log as Log3 } from "debug-level" ;
208
207
var PluginBase = class {
209
208
constructor ( key , description ) {
210
209
this . key = key ;
211
210
this . description = description ;
212
211
}
213
- log = new Log3 ( "bot" ) ;
212
+ log = botLog ;
214
213
pluginArguments = { } ;
215
214
requiredArguments = [ ] ;
216
215
setup ( ) {
@@ -241,7 +240,7 @@ import FormData3 from "form-data";
241
240
// src/plugins/GraphPlugin.ts
242
241
import { ChatCompletionRequestMessageRoleEnum } from "openai" ;
243
242
import FormData from "form-data" ;
244
- import fetch from "node-fetch" ;
243
+ import fetch2 from "node-fetch" ;
245
244
var GraphPlugin = class extends PluginBase {
246
245
yFilesGPTServerUrl = process . env [ "YFILES_SERVER_URL" ] ;
247
246
yFilesEndpoint = this . yFilesGPTServerUrl ? new URL ( "/json-to-svg" , this . yFilesGPTServerUrl ) : void 0 ;
@@ -311,7 +310,7 @@ ${graphContent}`);
311
310
return result ;
312
311
}
313
312
async generateSvg ( jsonString ) {
314
- return fetch ( this . yFilesEndpoint , {
313
+ return fetch2 ( this . yFilesEndpoint , {
315
314
method : "POST" ,
316
315
body : jsonString ,
317
316
headers : {
@@ -356,7 +355,11 @@ var ImagePlugin = class extends PluginBase {
356
355
const imagePrompt = await this . createImagePrompt ( args . imageDescription ) ;
357
356
if ( imagePrompt ) {
358
357
this . log . trace ( { imageInputPrompt : args . imageDescription , imageOutputPrompt : imagePrompt } ) ;
359
- const base64Image = await createImage ( imagePrompt ) ;
358
+ const base64Image = (
359
+ /*this.img256 //*/
360
+ /*this.sampleB64String */
361
+ await createImage ( imagePrompt )
362
+ ) ;
360
363
if ( base64Image ) {
361
364
const fileId = await this . base64ToFile ( base64Image , msgData . post . channel_id ) ;
362
365
aiResponse . message = "Here is the image you requested: " + imagePrompt ;
0 commit comments