holosphere 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/index.js +9 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import 'dotenv/config'
2
1
  import h3 from 'h3-js';
3
2
  import OpenAI from 'openai';
4
3
  import Gun from 'gun'
@@ -6,7 +5,7 @@ import Ajv2019 from 'ajv/dist/2019.js'
6
5
  import { createHash } from "crypto";
7
6
 
8
7
  class HoloSphere {
9
- constructor(appname) {
8
+ constructor(appname, openaikey = null) {
10
9
  this.validator = new Ajv2019({ allErrors: false, strict: false });
11
10
  this.gun = Gun({
12
11
  peers: ['https://59.src.eco/gun'],
@@ -17,9 +16,11 @@ class HoloSphere {
17
16
  });
18
17
 
19
18
  this.gun = gun.get(appname)
20
- this.openai = new OpenAI({
21
- apiKey: process.env.OPENAI,
22
- });
19
+ if (openaikey != null) {
20
+ this.openai = new OpenAI({
21
+ apiKey: openaikey,
22
+ });
23
+ }
23
24
 
24
25
  //this.bot.command('sethex', async (ctx) => { this.setHex(ctx) }) TODO: MOVE HERE FROM SETTINGS
25
26
 
@@ -330,6 +331,9 @@ class HoloSphere {
330
331
 
331
332
 
332
333
  async summarize(history) {
334
+ if (!this.openai) {
335
+ return 'OpenAI not initialized, please specify the API key in the constructor.'
336
+ }
333
337
  //const run = await this.openai.beta.threads.runs.retrieve(thread.id,run.id)
334
338
  const assistant = await this.openai.beta.assistants.retrieve("asst_qhk79F8wV9BDNuwfOI80TqzC")
335
339
  const thread = await this.openai.beta.threads.create()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "holosphere",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Holonic Geospatial Communication Infrastructure based on h3.js and gun.js",
5
5
  "main": "index.js",
6
6
  "type": "module",