symposium 0.1.0 → 0.1.1

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/Agent.js CHANGED
@@ -1,11 +1,10 @@
1
- import OpenAI from "openai";
1
+ import {Symposium} from "./Symposium.js";
2
2
  import {Conversation} from "./Conversation.js";
3
3
 
4
4
  class Agent {
5
5
  name = 'Agent';
6
6
  descriptionForFront = '';
7
7
  options = {};
8
- openai;
9
8
  conversations;
10
9
  functions = null;
11
10
  middlewares = new Map();
@@ -99,9 +98,6 @@ class Agent {
99
98
  }
100
99
  });
101
100
 
102
- this.openai = new OpenAI({
103
- apiKey: process.env.OPENAI_API_KEY,
104
- });
105
101
  this.conversations = new Map();
106
102
  }
107
103
 
@@ -258,7 +254,8 @@ class Agent {
258
254
  delete completion_payload.function_call;
259
255
  }
260
256
 
261
- const chatCompletion = await this.openai.chat.completions.create(completion_payload);
257
+ const openai = await Symposium.getOpenAi();
258
+ const chatCompletion = await openai.chat.completions.create(completion_payload);
262
259
 
263
260
  let completion = chatCompletion.choices[0].message;
264
261
  if (completion.function_call && completion.function_call.arguments)
@@ -355,17 +352,6 @@ class Agent {
355
352
  async getPromptWordsForTranscription(conversation) {
356
353
  return [this.name];
357
354
  }
358
-
359
- async transcribe(file, conversation) {
360
- let words = await this.getPromptWordsForTranscription(conversation);
361
-
362
- let response = await this.openai.audio.transcriptions.create({
363
- file,
364
- model: 'whisper-1',
365
- prompt: words.join(', '),
366
- });
367
- return response.text;
368
- }
369
355
  }
370
356
 
371
357
  export {Agent};
package/Symposium.js ADDED
@@ -0,0 +1,30 @@
1
+ import Redis from "@travio/redis";
2
+ import OpenAI from "openai";
3
+
4
+ class Symposium {
5
+ static openai;
6
+
7
+ static async init() {
8
+ return Redis.init();
9
+ }
10
+
11
+ static async getOpenAi() {
12
+ if (!this.openai)
13
+ this.openai = new OpenAI({apiKey: process.env.OPENAI_API_KEY});
14
+
15
+ return this.openai;
16
+ }
17
+
18
+ static async transcribe(agent, file, conversation) {
19
+ let words = await agent.getPromptWordsForTranscription(conversation);
20
+
21
+ let response = await this.openai.audio.transcriptions.create({
22
+ file,
23
+ model: 'whisper-1',
24
+ prompt: words.join(', '),
25
+ });
26
+ return response.text;
27
+ }
28
+ }
29
+
30
+ export {Symposium};
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ import {Symposium} from "./Symposium.js";
3
4
  import {Agent} from "./Agent.js";
4
5
  import {Conversation} from "./Conversation.js";
5
6
  import {Message} from "./Message.js";
@@ -10,6 +11,7 @@ import {Middleware} from "./Middleware.js";
10
11
  import {Summarizer} from "./Summarizer.js";
11
12
 
12
13
  export {
14
+ Symposium,
13
15
  Agent,
14
16
  Conversation,
15
17
  Message,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "symposium",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "description": "Agents",
6
6
  "main": "index.js",
7
7
  "scripts": {