aimyapi 0.1.4 → 0.1.5

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
@@ -13,6 +13,10 @@ Install the package
13
13
  ```
14
14
  npm i aimyapi --save
15
15
  ```
16
+ **Important:** create a .env file in the root of your project and add your OpenAI api key:
17
+ ```
18
+ OPENAI_API_KEY=XXXXXXXX
19
+ ```
16
20
 
17
21
  Simply define your strongly-typed typescript API:
18
22
 
@@ -5,6 +5,8 @@ import path from "path";
5
5
 
6
6
  // More complex fast food ordering example that uses chat history.
7
7
  // Fast food ordering example.
8
+
9
+ // IDEA: If the order history becomes too long, we could summarize it by listing the current order state and remove the rest.
8
10
  (async () => {
9
11
  const api = new OrderingAPI();
10
12
 
@@ -23,15 +23,16 @@ function getInput(query): Promise<string> {
23
23
  // Interactive version
24
24
  (async () => {
25
25
  const api = new OrderingAPI();
26
-
27
- const aimyapi = await AIMyAPI.createWithAPI({
26
+
27
+ const options = {
28
28
  apiObject: api,
29
29
  apiGlobalName: "orderingApi", // Should match whatever you declared as your global in your ordering api.
30
30
  apiExports: APIExports,
31
31
  apiDefFilePath: path.join(__dirname, "./ordering_api.ts"),
32
32
  apiDocsPath: path.join(__dirname, "./ordering_api.md"),
33
33
  debug: false,
34
- })
34
+ };
35
+ const aimyapi = await AIMyAPI.createWithAPI(options)
35
36
 
36
37
  async function runQuery(query:string) {
37
38
  console.log(`Query: ${query}`)
@@ -46,7 +47,7 @@ function getInput(query): Promise<string> {
46
47
  });
47
48
 
48
49
  api._addMessageToHistory({
49
- content: '```\n' + code + '\n```',
50
+ content: '```\n' + code.replace(options.apiDefFilePath, "./api.ts") + '\n```',
50
51
  role: "assistant",
51
52
  name: "assistant",
52
53
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aimyapi",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "AI My API! Use LLMs to create small programs that safely* run and make calls against your API.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",