aimyapi 0.2.1 → 1.0.3
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 +69 -310
- package/dist/index.cjs +332 -120
- package/dist/index.d.cts +32 -11
- package/dist/index.d.mts +32 -11
- package/dist/index.d.ts +32 -11
- package/dist/index.js +332 -120
- package/dist/index.mjs +332 -121
- package/example/example1.ts +11 -10
- package/example/example2.ts +32 -22
- package/example/example3.ts +26 -20
- package/example/ordering_api.md +21 -19
- package/example/ordering_api.ts +3 -2
- package/example/ordering_api_impl.ts +2 -1
- package/example/sales_api.md +3 -8
- package/example/sales_api.ts +2 -2
- package/example/sales_api_impl.ts +1 -1
- package/package.json +12 -10
- package/prompts/create-task-prompt.md +19 -21
- package/src/index.ts +325 -140
- package/src/sandbox.ts +119 -26
- package/tsconfig.json +1 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { ChatCompletionMessageParam } from 'openai/resources/index.mjs';
|
|
2
2
|
import { QuickJSWASMModule } from 'quickjs-emscripten';
|
|
3
|
+
import { ZodSchema } from 'zod';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
interface GlobalOption {
|
|
6
|
+
value: any;
|
|
7
|
+
whitelist?: string[];
|
|
8
|
+
}
|
|
9
|
+
interface Globals {
|
|
10
|
+
[key: string]: GlobalOption;
|
|
9
11
|
}
|
|
10
|
-
|
|
12
|
+
type SandboxLog = {
|
|
13
|
+
type: "log" | "error";
|
|
14
|
+
args: any[];
|
|
15
|
+
source: string;
|
|
16
|
+
};
|
|
17
|
+
type CodeRunResult = {
|
|
18
|
+
success: boolean;
|
|
19
|
+
logs: SandboxLog[];
|
|
20
|
+
};
|
|
21
|
+
|
|
11
22
|
interface AIMyAPIOptions {
|
|
12
23
|
apiObject: object;
|
|
13
24
|
apiExports: object;
|
|
@@ -18,19 +29,29 @@ interface AIMyAPIOptions {
|
|
|
18
29
|
apiDocsPath?: string;
|
|
19
30
|
debug?: boolean;
|
|
20
31
|
model?: string;
|
|
32
|
+
additionalModelOptions?: object;
|
|
33
|
+
hideLogsFromAgent?: boolean;
|
|
21
34
|
}
|
|
22
35
|
interface AIMyAPIInstance {
|
|
23
36
|
options: AIMyAPIOptions;
|
|
24
|
-
generateCode: (queryText: string, userChatHistory: ChatCompletionMessageParam[]) => Promise<GenerateCodeResult>;
|
|
25
|
-
runCode: (
|
|
26
|
-
|
|
37
|
+
generateCode: (queryText: string, userChatHistory: ChatCompletionMessageParam[]) => Promise<GenerateCodeResult | null>;
|
|
38
|
+
runCode: (code: string) => Promise<CodeRunResult>;
|
|
39
|
+
checkCode: (code: string) => Promise<CodeRunResult>;
|
|
40
|
+
processRequest: (userQuery: string, context?: object) => Promise<GenerateCodeResult | null>;
|
|
41
|
+
}
|
|
42
|
+
interface GenerateCodeResult {
|
|
43
|
+
code?: string;
|
|
44
|
+
comments?: string;
|
|
27
45
|
}
|
|
46
|
+
declare function zodParseJSON<T>(schema: ZodSchema<T>): (input: string) => T;
|
|
47
|
+
declare function createBasePrompt(apiFilePath: string, apiGlobalName: string, documentationPath?: string): string;
|
|
48
|
+
declare const generateCode: (instance: AIMyAPIInstance, queryText: string, userChatHistory: ChatCompletionMessageParam[], createTaskPrompt: string, debug?: boolean, hideLogsFromAgent?: boolean, model?: string, additionalModelOptions?: object) => Promise<GenerateCodeResult | null>;
|
|
28
49
|
interface AIMyAPIModuleExports {
|
|
29
50
|
createWithAPI: (options: AIMyAPIOptions) => Promise<AIMyAPIInstance>;
|
|
30
51
|
createBasePrompt: (apiFilePath: string, documentationPath: string) => string;
|
|
31
|
-
generateCode: (queryText: string, userChatHistory: ChatCompletionMessageParam[], createTaskPrompt: string, debug: boolean) => Promise<GenerateCodeResult>;
|
|
52
|
+
generateCode: (instance: AIMyAPIInstance, queryText: string, userChatHistory: ChatCompletionMessageParam[], createTaskPrompt: string, debug: boolean) => Promise<GenerateCodeResult | null>;
|
|
32
53
|
createSandbox: (QuickJS: QuickJSWASMModule, globals: any) => Promise<any>;
|
|
33
54
|
}
|
|
34
55
|
declare const AIMyAPI: AIMyAPIModuleExports;
|
|
35
56
|
|
|
36
|
-
export { AIMyAPI, type AIMyAPIInstance, type AIMyAPIModuleExports, type AIMyAPIOptions, type GenerateCodeResult, createBasePrompt, generateCode };
|
|
57
|
+
export { AIMyAPI, type AIMyAPIInstance, type AIMyAPIModuleExports, type AIMyAPIOptions, type CodeRunResult, type GenerateCodeResult, type GlobalOption, type Globals, type SandboxLog, createBasePrompt, generateCode, zodParseJSON };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { ChatCompletionMessageParam } from 'openai/resources/index.mjs';
|
|
2
2
|
import { QuickJSWASMModule } from 'quickjs-emscripten';
|
|
3
|
+
import { ZodSchema } from 'zod';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
interface GlobalOption {
|
|
6
|
+
value: any;
|
|
7
|
+
whitelist?: string[];
|
|
8
|
+
}
|
|
9
|
+
interface Globals {
|
|
10
|
+
[key: string]: GlobalOption;
|
|
9
11
|
}
|
|
10
|
-
|
|
12
|
+
type SandboxLog = {
|
|
13
|
+
type: "log" | "error";
|
|
14
|
+
args: any[];
|
|
15
|
+
source: string;
|
|
16
|
+
};
|
|
17
|
+
type CodeRunResult = {
|
|
18
|
+
success: boolean;
|
|
19
|
+
logs: SandboxLog[];
|
|
20
|
+
};
|
|
21
|
+
|
|
11
22
|
interface AIMyAPIOptions {
|
|
12
23
|
apiObject: object;
|
|
13
24
|
apiExports: object;
|
|
@@ -18,19 +29,29 @@ interface AIMyAPIOptions {
|
|
|
18
29
|
apiDocsPath?: string;
|
|
19
30
|
debug?: boolean;
|
|
20
31
|
model?: string;
|
|
32
|
+
additionalModelOptions?: object;
|
|
33
|
+
hideLogsFromAgent?: boolean;
|
|
21
34
|
}
|
|
22
35
|
interface AIMyAPIInstance {
|
|
23
36
|
options: AIMyAPIOptions;
|
|
24
|
-
generateCode: (queryText: string, userChatHistory: ChatCompletionMessageParam[]) => Promise<GenerateCodeResult>;
|
|
25
|
-
runCode: (
|
|
26
|
-
|
|
37
|
+
generateCode: (queryText: string, userChatHistory: ChatCompletionMessageParam[]) => Promise<GenerateCodeResult | null>;
|
|
38
|
+
runCode: (code: string) => Promise<CodeRunResult>;
|
|
39
|
+
checkCode: (code: string) => Promise<CodeRunResult>;
|
|
40
|
+
processRequest: (userQuery: string, context?: object) => Promise<GenerateCodeResult | null>;
|
|
41
|
+
}
|
|
42
|
+
interface GenerateCodeResult {
|
|
43
|
+
code?: string;
|
|
44
|
+
comments?: string;
|
|
27
45
|
}
|
|
46
|
+
declare function zodParseJSON<T>(schema: ZodSchema<T>): (input: string) => T;
|
|
47
|
+
declare function createBasePrompt(apiFilePath: string, apiGlobalName: string, documentationPath?: string): string;
|
|
48
|
+
declare const generateCode: (instance: AIMyAPIInstance, queryText: string, userChatHistory: ChatCompletionMessageParam[], createTaskPrompt: string, debug?: boolean, hideLogsFromAgent?: boolean, model?: string, additionalModelOptions?: object) => Promise<GenerateCodeResult | null>;
|
|
28
49
|
interface AIMyAPIModuleExports {
|
|
29
50
|
createWithAPI: (options: AIMyAPIOptions) => Promise<AIMyAPIInstance>;
|
|
30
51
|
createBasePrompt: (apiFilePath: string, documentationPath: string) => string;
|
|
31
|
-
generateCode: (queryText: string, userChatHistory: ChatCompletionMessageParam[], createTaskPrompt: string, debug: boolean) => Promise<GenerateCodeResult>;
|
|
52
|
+
generateCode: (instance: AIMyAPIInstance, queryText: string, userChatHistory: ChatCompletionMessageParam[], createTaskPrompt: string, debug: boolean) => Promise<GenerateCodeResult | null>;
|
|
32
53
|
createSandbox: (QuickJS: QuickJSWASMModule, globals: any) => Promise<any>;
|
|
33
54
|
}
|
|
34
55
|
declare const AIMyAPI: AIMyAPIModuleExports;
|
|
35
56
|
|
|
36
|
-
export { AIMyAPI, type AIMyAPIInstance, type AIMyAPIModuleExports, type AIMyAPIOptions, type GenerateCodeResult, createBasePrompt, generateCode };
|
|
57
|
+
export { AIMyAPI, type AIMyAPIInstance, type AIMyAPIModuleExports, type AIMyAPIOptions, type CodeRunResult, type GenerateCodeResult, type GlobalOption, type Globals, type SandboxLog, createBasePrompt, generateCode, zodParseJSON };
|