|
2 | 2 | import {parseArgs} from "jsr:@std/cli/parse-args"
|
3 | 3 | import {runHelp} from "./help.ts"
|
4 | 4 | import {handleConfig} from "./config.ts"
|
5 |
| -import {getExamplesFile, getFiles, getTaskFile} from "./utils.ts" |
| 5 | +import {getApiGatewaySchemaFile, getExamplesFile, getFiles, getTaskFile} from "./utils.ts" |
6 | 6 | import {determineClient, listModels} from "./aiClients.ts"
|
7 | 7 | import OpenAI from "openai/mod.ts"
|
8 | 8 | import {generateCurl, generatePrompt} from "./prompt.ts"
|
@@ -111,16 +111,17 @@ if (import.meta.main) {
|
111 | 111 |
|
112 | 112 | const taskContent = getTaskFile(task)
|
113 | 113 | const filesContent = getFiles(files)
|
| 114 | + const apiGatewaySchemaContent = getApiGatewaySchemaFile(apiGatewaySchema) |
114 | 115 | const examplesContent = getExamplesFile(examples)
|
115 | 116 | if (globalThis.isVerbose) {
|
116 |
| - console.log({taskContent, files, filesContent, examplesContent, executeCommands}) |
| 117 | + console.log({taskContent, files, filesContent, examplesContent, apiGatewaySchemaContent, executeCommands}) |
117 | 118 | }
|
118 | 119 | if (!taskContent || !filesContent) {
|
119 | 120 | console.error("Task and files are required")
|
120 | 121 | Deno.exit(1)
|
121 | 122 | }
|
122 | 123 | await generateCurls(model, taskContent, filesContent,
|
123 |
| - apiGatewaySchema, apiKey, endpoint, examplesContent, requiresLogin, executeCommands) |
| 124 | + apiGatewaySchemaContent, apiKey, endpoint, examplesContent, requiresLogin, executeCommands) |
124 | 125 |
|
125 | 126 | // Add this line to print the results
|
126 | 127 | printCurlResults()
|
@@ -243,6 +244,11 @@ async function generateCurlsWithAnthropic(client: Anthropic, model: string, prom
|
243 | 244 | } else if (message.type === "tool_use") {
|
244 | 245 | const commands = message.input && typeof message.input === 'object' ? (message.input as {commands?: Array<{command: string, explanation: string, expected_success: boolean}>}).commands || [] : []
|
245 | 246 | toolUseId = message.id
|
| 247 | + if (!Array.isArray(commands)) { |
| 248 | + console.error("Commands should be an array") |
| 249 | + console.log({commands, input: message.input, type: typeof message.input}) |
| 250 | + Deno.exit(1) |
| 251 | + } |
246 | 252 | const transformedCommands = commands.map(cmd => ({command: cmd.command, expected_success: cmd.expected_success}))
|
247 | 253 | const response = await runCurlsAndReturnResult(transformedCommands, endpoint, apiKey, executeCommands)
|
248 | 254 | if (globalThis.isVerbose) {
|
|
0 commit comments