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
  • Loading branch information
pelikhan committed Sep 9, 2024
1 parent 471e9f2 commit 816cf0f
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

Check failure on line 226 in packages/core/src/chat.ts

View workflow job for this annotation

GitHub Actions / build

There is no error handling for the case when `output` is an object but does not have a `text` property. This could lead to unexpected behavior. Consider adding error handling or a default value. 😊
} else {
toolContent = YAMLStringify(output)
}

Check failure on line 229 in packages/core/src/chat.ts

View workflow job for this annotation

GitHub Actions / build

The `YAMLStringify` function is used to convert `output` to a string, but there is no check to ensure that `output` is a suitable type for this function. This could lead to runtime errors. Please ensure that `output` is of a type that can be correctly processed by `YAMLStringify`. 😊
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

Check failure on line 500 in packages/core/src/types/prompt_template.d.ts

View workflow job for this annotation

GitHub Actions / build

The type `undefined` is included in the `ToolCallOutput` union type. This could lead to unexpected behavior if not handled correctly in the code that uses this type. Please ensure that all code using `ToolCallOutput` is prepared to handle `undefined` values. 😊

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 816cf0f

Please sign in to comment.