agency-lang 0.0.31 → 0.0.33
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.
|
@@ -291,7 +291,7 @@ export class AgencyGenerator extends BaseGenerator {
|
|
|
291
291
|
}
|
|
292
292
|
processReturnStatement(node) {
|
|
293
293
|
const valueCode = this.processNode(node.value).trim();
|
|
294
|
-
return this.indentStr(`return ${valueCode}
|
|
294
|
+
return this.indentStr(`return ${valueCode}`);
|
|
295
295
|
}
|
|
296
296
|
// Utility methods
|
|
297
297
|
processComment(node) {
|
|
@@ -337,7 +337,7 @@ export class AgencyGenerator extends BaseGenerator {
|
|
|
337
337
|
return this.indentStr(`+${node.toolName}`);
|
|
338
338
|
}
|
|
339
339
|
processSpecialVar(node) {
|
|
340
|
-
return this.indentStr(`@${node.name} = ${this.processNode(node.value).trim()}
|
|
340
|
+
return this.indentStr(`@${node.name} = ${this.processNode(node.value).trim()}`);
|
|
341
341
|
}
|
|
342
342
|
indentStr(str) {
|
|
343
343
|
return `${this.indent()}${str}`;
|
|
@@ -160,10 +160,10 @@ export class TypeScriptGenerator extends BaseGenerator {
|
|
|
160
160
|
functionArgs: interpolatedVars,
|
|
161
161
|
prompt: node,
|
|
162
162
|
});
|
|
163
|
-
this.generatedStatements.push(functionCode);
|
|
163
|
+
//this.generatedStatements.push(functionCode);
|
|
164
164
|
const argsStr = [...interpolatedVars, "__messages"].join(", ");
|
|
165
165
|
// Generate the function call
|
|
166
|
-
return
|
|
166
|
+
return `${functionCode}\nconst ${variableName} = await _${variableName}(${argsStr});` + "\n";
|
|
167
167
|
}
|
|
168
168
|
processTool(node) {
|
|
169
169
|
const { functionName, body, parameters } = node;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const template = "import { z } from \"zod\";\nimport * as readline from \"readline\";\nimport fs from \"fs\";\nimport { PieMachine, goToNode } from \"piemachine\";\nimport { StatelogClient } from \"statelog-client\";\nimport { nanoid } from \"nanoid\";\nimport { assistantMessage, getClient, userMessage, toolMessage } from \"smoltalk\";\n\nconst statelogHost = \"https://statelog.adit.io\";\nconst traceId = nanoid();\nconst statelogConfig = {\n host: statelogHost,\n traceId: traceId,\n apiKey: process.env.STATELOG_API_KEY || \"\",\n projectId: \"agency-lang\",\n debugMode: false,\n };\nconst statelogClient = new StatelogClient(statelogConfig);\nconst __model: ModelName = \"gpt-4o-mini\";\n\n\nconst getClientWithConfig = (config = {}) => {\n const defaultConfig = {\n openAiApiKey: process.env.OPENAI_API_KEY || \"\",\n googleApiKey: process.env.GEMINI_API_KEY || \"\",\n model: __model,\n logLevel: \"warn\",\n };\n\n return getClient({ ...defaultConfig, ...config });\n};\n\nlet __client = getClientWithConfig();\n\ntype State = {\n messages: string[];\n data: any;\n}\n\n// enable debug logging\nconst graphConfig = {\n debug: {\n log: true,\n logData: true,\n },\n statelog: statelogConfig,\n};\n\n// Define the names of the nodes in the graph\n// Useful for type safety\nconst __nodes = {{{nodes:string}}} as const;\ntype Node = (typeof __nodes)[number];\n\nconst graph = new PieMachine<State, Node>(__nodes, graphConfig);\n\n// builtins\n\nconst not = (val: any): boolean => !val;\nconst eq = (a: any, b: any): boolean => a === b;\nconst neq = (a: any, b: any): boolean => a !== b;\nconst lt = (a: any, b: any): boolean => a < b;\nconst lte = (a: any, b: any): boolean => a <= b;\nconst gt = (a: any, b: any): boolean => a > b;\nconst gte = (a: any, b: any): boolean => a >= b;\nconst and = (a: any, b: any): boolean => a && b;\nconst or = (a: any, b: any): boolean => a || b;\nconst head = <T>(arr: T[]): T | undefined => arr[0];\nconst tail = <T>(arr: T[]): T[] => arr.slice(1);";
|
|
1
|
+
export declare const template = "import { z } from \"zod\";\nimport * as readline from \"readline\";\nimport fs from \"fs\";\nimport { PieMachine, goToNode } from \"piemachine\";\nimport { StatelogClient } from \"statelog-client\";\nimport { nanoid } from \"nanoid\";\nimport { assistantMessage, getClient, userMessage, toolMessage } from \"smoltalk\";\n\nconst statelogHost = \"https://statelog.adit.io\";\nconst traceId = nanoid();\nconst statelogConfig = {\n host: statelogHost,\n traceId: traceId,\n apiKey: process.env.STATELOG_API_KEY || \"\",\n projectId: \"agency-lang\",\n debugMode: false,\n };\nconst statelogClient = new StatelogClient(statelogConfig);\nconst __model: ModelName = \"gpt-4o-mini\";\n\n\nconst getClientWithConfig = (config = {}) => {\n const defaultConfig = {\n openAiApiKey: process.env.OPENAI_API_KEY || \"\",\n googleApiKey: process.env.GEMINI_API_KEY || \"\",\n model: __model,\n logLevel: \"warn\",\n };\n\n return getClient({ ...defaultConfig, ...config });\n};\n\nlet __client = getClientWithConfig();\n\ntype State = {\n messages: string[];\n data: any;\n}\n\n// enable debug logging\nconst graphConfig = {\n debug: {\n log: true,\n logData: true,\n },\n statelog: statelogConfig,\n};\n\n// Define the names of the nodes in the graph\n// Useful for type safety\nconst __nodes = {{{nodes:string}}} as const;\ntype Node = (typeof __nodes)[number];\n\nconst graph = new PieMachine<State, Node>(__nodes, graphConfig);\n\n// builtins\n\nconst not = (val: any): boolean => !val;\nconst eq = (a: any, b: any): boolean => a === b;\nconst neq = (a: any, b: any): boolean => a !== b;\nconst lt = (a: any, b: any): boolean => a < b;\nconst lte = (a: any, b: any): boolean => a <= b;\nconst gt = (a: any, b: any): boolean => a > b;\nconst gte = (a: any, b: any): boolean => a >= b;\nconst and = (a: any, b: any): boolean => a && b;\nconst or = (a: any, b: any): boolean => a || b;\nconst head = <T>(arr: T[]): T | undefined => arr[0];\nconst tail = <T>(arr: T[]): T[] => arr.slice(1);\nconst empty = <T>(arr: T[]): boolean => arr.length === 0;";
|
|
2
2
|
export type TemplateType = {
|
|
3
3
|
nodes: string;
|
|
4
4
|
};
|
|
@@ -69,7 +69,8 @@ const gte = (a: any, b: any): boolean => a >= b;
|
|
|
69
69
|
const and = (a: any, b: any): boolean => a && b;
|
|
70
70
|
const or = (a: any, b: any): boolean => a || b;
|
|
71
71
|
const head = <T>(arr: T[]): T | undefined => arr[0];
|
|
72
|
-
const tail = <T>(arr: T[]): T[] => arr.slice(1)
|
|
72
|
+
const tail = <T>(arr: T[]): T[] => arr.slice(1);
|
|
73
|
+
const empty = <T>(arr: T[]): boolean => arr.length === 0;`;
|
|
73
74
|
const render = (args) => {
|
|
74
75
|
return apply(template, args);
|
|
75
76
|
};
|