Skip to content

Commit

Permalink
Update handling of outputs in runToolCalls and streamline `runPromp…
Browse files Browse the repository at this point in the history
…t` usage in tools (#702)
  • Loading branch information
pelikhan authored Sep 9, 2024
1 parent 471e9f2 commit 468c074
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docs/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/core/src/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ async function runToolCalls(
toolContent = `FILENAME: ${filename}
${fenceMD(content, " ")}
`
} else if (
typeof output === "object" &&
(output as RunPromptResult).text
) {
const { text } = output as RunPromptResult
toolContent = text
} else {
toolContent = YAMLStringify(output)
}
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/core/src/types/prompt_template.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ type ToolCallOutput =
| ToolCallContent
| ShellOutput
| WorkspaceFile
| RunPromptResult
| undefined

interface WorkspaceFileCache<K, V> {
/**
Expand Down
2 changes: 2 additions & 0 deletions packages/sample/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions packages/sample/genaisrc/nested-agents.genai.mts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ defTool(
description: "the prompt to be executed by the LLM",
},
},
async ({ prompt }) => {
const res = await env.generator.runPrompt(
async ({ prompt }) =>
await env.generator.runPrompt(
(_) => {
_.$`You are an AI assistant that can help with file system tasks.
Expand All @@ -31,8 +31,6 @@ defTool(
tools: "fs",
}
)
return res.text
}
)

/**
Expand All @@ -47,14 +45,12 @@ defTool(
description: "the python to be executed by the LLM",
},
},
async ({ code }) => {
const res = await env.generator.runPrompt(code, {
async ({ code }) =>
await env.generator.runPrompt(code, {
model: "openai:gpt-4o",
label: "llm-4o agent_fs",
tools: "python",
})
return res.text
}
)

// now as a question about the file system
Expand Down
2 changes: 2 additions & 0 deletions packages/sample/genaisrc/node/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/sample/genaisrc/python/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/sample/genaisrc/style/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/sample/src/aici/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/sample/src/errors/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/sample/src/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/sample/src/makecode/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/sample/src/tla/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/sample/src/vision/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions slides/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 468c074

Please sign in to comment.