aimyapi 0.1.14 → 0.1.15

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/README.md CHANGED
@@ -68,7 +68,7 @@ api.print("I'm great, thanks for asking!");
68
68
  Instantiate your api and AIMyAPI. AIMyAPI will wrap your API so that it can be called from within the QuickJS sandbox.
69
69
 
70
70
  ```
71
- import AIMyAPI from "aimyapi"
71
+ import { AIMyAPI } from "aimyapi"
72
72
 
73
73
  const api = new API();
74
74
 
@@ -184,7 +184,7 @@ npm run example1
184
184
  ```
185
185
 
186
186
  ```
187
- import AIMyAPI from "../lib";
187
+ import { AIMyAPI } from "../lib";
188
188
  import { API } from "./sales_api_impl";
189
189
  import * as APIExports from "./sales_api";
190
190
  import path from "path";
@@ -253,7 +253,7 @@ npm run example2
253
253
 
254
254
  Code:
255
255
  ```
256
- import AIMyAPI from "../lib";
256
+ import { AIMyAPI } from "../lib";
257
257
  import { OrderingAPI } from "./ordering_api_impl";
258
258
  import * as APIExports from "./ordering_api";
259
259
  import path from "path";
package/dist/index.cjs CHANGED
@@ -478,7 +478,7 @@ async function createWithAPI(options) {
478
478
  }
479
479
  };
480
480
  }
481
- const aimyapi = {
481
+ const AIMyAPI = {
482
482
  // Standard way of using the library
483
483
  createWithAPI,
484
484
  // functions for customized usage
@@ -487,6 +487,6 @@ const aimyapi = {
487
487
  createSandbox
488
488
  };
489
489
 
490
- exports.aimyapi = aimyapi;
490
+ exports.AIMyAPI = AIMyAPI;
491
491
  exports.createBasePrompt = createBasePrompt;
492
492
  exports.generateCode = generateCode;
package/dist/index.d.cts CHANGED
@@ -31,6 +31,6 @@ interface AIMyAPIModuleExports {
31
31
  generateCode: (queryText: string, userChatHistory: ChatCompletionMessageParam[], createTaskPrompt: string, apiPath: string, debug: boolean) => Promise<GenerateCodeResult>;
32
32
  createSandbox: (QuickJS: QuickJSWASMModule, globals: any) => Promise<any>;
33
33
  }
34
- declare const aimyapi: AIMyAPIModuleExports;
34
+ declare const AIMyAPI: AIMyAPIModuleExports;
35
35
 
36
- export { type AIMyAPIInstance, type AIMyAPIModuleExports, type AIMyAPIOptions, type GenerateCodeResult, aimyapi, createBasePrompt, generateCode };
36
+ export { AIMyAPI, type AIMyAPIInstance, type AIMyAPIModuleExports, type AIMyAPIOptions, type GenerateCodeResult, createBasePrompt, generateCode };
package/dist/index.d.mts CHANGED
@@ -31,6 +31,6 @@ interface AIMyAPIModuleExports {
31
31
  generateCode: (queryText: string, userChatHistory: ChatCompletionMessageParam[], createTaskPrompt: string, apiPath: string, debug: boolean) => Promise<GenerateCodeResult>;
32
32
  createSandbox: (QuickJS: QuickJSWASMModule, globals: any) => Promise<any>;
33
33
  }
34
- declare const aimyapi: AIMyAPIModuleExports;
34
+ declare const AIMyAPI: AIMyAPIModuleExports;
35
35
 
36
- export { type AIMyAPIInstance, type AIMyAPIModuleExports, type AIMyAPIOptions, type GenerateCodeResult, aimyapi, createBasePrompt, generateCode };
36
+ export { AIMyAPI, type AIMyAPIInstance, type AIMyAPIModuleExports, type AIMyAPIOptions, type GenerateCodeResult, createBasePrompt, generateCode };
package/dist/index.d.ts CHANGED
@@ -31,6 +31,6 @@ interface AIMyAPIModuleExports {
31
31
  generateCode: (queryText: string, userChatHistory: ChatCompletionMessageParam[], createTaskPrompt: string, apiPath: string, debug: boolean) => Promise<GenerateCodeResult>;
32
32
  createSandbox: (QuickJS: QuickJSWASMModule, globals: any) => Promise<any>;
33
33
  }
34
- declare const aimyapi: AIMyAPIModuleExports;
34
+ declare const AIMyAPI: AIMyAPIModuleExports;
35
35
 
36
- export { type AIMyAPIInstance, type AIMyAPIModuleExports, type AIMyAPIOptions, type GenerateCodeResult, aimyapi, createBasePrompt, generateCode };
36
+ export { AIMyAPI, type AIMyAPIInstance, type AIMyAPIModuleExports, type AIMyAPIOptions, type GenerateCodeResult, createBasePrompt, generateCode };
package/dist/index.js CHANGED
@@ -478,7 +478,7 @@ async function createWithAPI(options) {
478
478
  }
479
479
  };
480
480
  }
481
- const aimyapi = {
481
+ const AIMyAPI = {
482
482
  // Standard way of using the library
483
483
  createWithAPI,
484
484
  // functions for customized usage
@@ -487,6 +487,6 @@ const aimyapi = {
487
487
  createSandbox
488
488
  };
489
489
 
490
- exports.aimyapi = aimyapi;
490
+ exports.AIMyAPI = AIMyAPI;
491
491
  exports.createBasePrompt = createBasePrompt;
492
492
  exports.generateCode = generateCode;
package/dist/index.mjs CHANGED
@@ -456,7 +456,7 @@ async function createWithAPI(options) {
456
456
  }
457
457
  };
458
458
  }
459
- const aimyapi = {
459
+ const AIMyAPI = {
460
460
  // Standard way of using the library
461
461
  createWithAPI,
462
462
  // functions for customized usage
@@ -465,4 +465,4 @@ const aimyapi = {
465
465
  createSandbox
466
466
  };
467
467
 
468
- export { aimyapi, createBasePrompt, generateCode };
468
+ export { AIMyAPI, createBasePrompt, generateCode };
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import AIMyAPI from "../src";
2
+ import { AIMyAPI } from "../src";
3
3
  import * as APIExports from "./sales_api";
4
4
  import { API } from "./sales_api_impl";
5
5
 
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import AIMyAPI, { GenerateCodeResult } from "../src";
2
+ import { AIMyAPI, GenerateCodeResult } from "../src";
3
3
  import * as APIExports from "./ordering_api";
4
4
  import { OrderingAPI } from "./ordering_api_impl";
5
5
 
@@ -1,6 +1,6 @@
1
1
 
2
2
  import path from "path";
3
- import AIMyAPI from "../src";
3
+ import { AIMyAPI } from "../src";
4
4
  import * as APIExports from "./ordering_api";
5
5
  import { OrderingAPI } from "./ordering_api_impl";
6
6
 
@@ -38,7 +38,7 @@ function getInput(query): Promise<string> {
38
38
  console.log(`Query: ${query}`)
39
39
 
40
40
  // generate the code for this query
41
- const code = await aimyapi.generateCode(query, api._getHistory());
41
+ const result = await aimyapi.generateCode(query, api._getHistory());
42
42
 
43
43
  api._addMessageToHistory({
44
44
  content: query,
@@ -47,13 +47,13 @@ function getInput(query): Promise<string> {
47
47
  });
48
48
 
49
49
  api._addMessageToHistory({
50
- content: '```\n' + code.replace(options.apiDefFilePath, "./api.ts") + '\n```',
50
+ content: '```\n' + result.code.replace(options.apiDefFilePath, "./api.ts") + '\n```',
51
51
  role: "assistant",
52
52
  name: "assistant",
53
53
  });
54
54
 
55
55
  // run the code in the sandbox
56
- await aimyapi.runCode(code);
56
+ await aimyapi.runCode(result.code);
57
57
  }
58
58
 
59
59
  console.log("Welcome to the restaurant. You can ask to hear the menu or order something. What would you like to do?");
@@ -1,10 +1,10 @@
1
- import { ChatCompletionRequestMessage } from "openai";
1
+ import { ChatCompletionMessageParam } from "openai/resources/index.mjs";
2
2
  import { delay } from "../src/utils";
3
3
  import {
4
- Customization,
5
- Menu,
6
- MenuItemBase,
7
- OrderingAPIInterface,
4
+ Customization,
5
+ Menu,
6
+ MenuItemBase,
7
+ OrderingAPIInterface,
8
8
  } from "./ordering_api";
9
9
 
10
10
  // TODO: make functions to print out an item, and print out the current order with the price totals.
@@ -14,7 +14,7 @@ export class OrderingAPI implements OrderingAPIInterface {
14
14
  private _lastOrderIdNumber: number = 0;
15
15
  public _isCompleted:boolean = false;
16
16
 
17
- private _history: ChatCompletionRequestMessage[] = [];
17
+ private _history: ChatCompletionMessageParam[] = [];
18
18
 
19
19
  // Mock implementation, doesn't actually send an email
20
20
  sendEmail(to: string, subject: string, body: string): Promise<void> {
@@ -194,11 +194,11 @@ export class OrderingAPI implements OrderingAPIInterface {
194
194
  this.respondToUser(`--\tTotal:\t\t$${this.getOrderTotal().toFixed(2)}`);
195
195
  }
196
196
 
197
- _addMessageToHistory(message: ChatCompletionRequestMessage) {
197
+ _addMessageToHistory(message: ChatCompletionMessageParam) {
198
198
  this._history.push(message);
199
199
  }
200
200
 
201
- _getHistory(): ChatCompletionRequestMessage[] {
201
+ _getHistory(): ChatCompletionMessageParam[] {
202
202
  return this._history;
203
203
  }
204
204
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aimyapi",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "AI My API! Use LLMs to create small programs that safely* run and make calls against your API. Similar to ChatGPT's Code Interpreter.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -232,7 +232,7 @@ export interface AIMyAPIModuleExports {
232
232
  createSandbox: (QuickJS:QuickJSWASMModule, globals: any) => Promise<any>;
233
233
  }
234
234
 
235
- export const aimyapi:AIMyAPIModuleExports = {
235
+ export const AIMyAPI:AIMyAPIModuleExports = {
236
236
  // Standard way of using the library
237
237
  createWithAPI,
238
238
 
@@ -240,4 +240,4 @@ export const aimyapi:AIMyAPIModuleExports = {
240
240
  createBasePrompt,
241
241
  generateCode,
242
242
  createSandbox,
243
- }
243
+ }