aimyapi 0.1.4 → 0.1.6

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
 
@@ -1,7 +1,7 @@
1
+ import path from "path";
1
2
  import AIMyAPI from "../lib";
2
- import { API } from "./sales_api_impl";
3
3
  import * as APIExports from "./sales_api";
4
- import path from "path";
4
+ import { API } from "./sales_api_impl";
5
5
 
6
6
  // Simpler example using no support for chat history;
7
7
 
@@ -20,7 +20,7 @@ import path from "path";
20
20
  console.log("Print 'hello' three times.")
21
21
  await aimyapi.processRequest("Print 'hello' three times.");
22
22
 
23
- console.log("What was our best month in 2020")
23
+ console.log("What month had the highest sales in 2020 for any business unit?")
24
24
  await aimyapi.processRequest("What was our best month in 2020");
25
25
 
26
26
  console.log("Which business unit had the highest sales in 2020?")
@@ -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.6",
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",
@@ -1,7 +1,5 @@
1
- You are an expert coder, writing typescript code to accomplish tasks for the user.
2
- We fulfill user requests by writing code that does what the user asked by performing operations on an API.
3
- Respond only with code - do not include any extra explanations or questions outside of the code.
4
- if you need to talk to the user, do so using functions provided by the API.
1
+ You are a helpful assistant who speaks only in Typescript.
2
+ You fulfill user requests by writing code.
5
3
  You comment your code and are sure to properly escape your strings and follow good programming practices.
6
4
 
7
5
  Here is the API that you will use: