-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blog ideation #643
Blog ideation #643
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
"sysr", | ||
"treesitter", | ||
"typecheck", | ||
"unfence", | ||
"vsix", | ||
"xpai" | ||
], | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,8 +119,8 @@ | |
Commands: | ||
list List all available scripts in workspace | ||
create <name> Create a new script | ||
fix fix all definition files | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usage description for 'compile' command is inconsistent with the updated usage syntax.
|
||
compile Compile all script in workspace | ||
compile [folders...] Compile all script in workspace | ||
model [options] [script] List model connection information for scripts | ||
help [command] display help for command | ||
``` | ||
|
@@ -164,10 +164,13 @@ | |
### `scripts compile` | ||
|
||
``` | ||
Usage: genaiscript scripts compile [options] | ||
Usage: genaiscript scripts compile [options] [folders...] | ||
|
||
Compile all script in workspace | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There seems to be a typo here. It should be "Compile all scripts in workspace" instead of "Compile all script in workspace".
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Description for 'compile' command is incomplete, missing the explanation for the new '[folders...]' argument.
|
||
|
||
Arguments: | ||
folders Pattern to match files | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The description "Pattern to match files" for the argument 'folders' is unclear. It should specify that 'folders' is a pattern to match directories containing scripts to compile.
|
||
|
||
Options: | ||
-h, --help display help for command | ||
``` | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,10 +145,13 @@ | |
.option("-cs, --csv-separator <string>", "csv separator", "\t") | ||
.option("-ae, --apply-edits", "apply file edits") | ||
.option( | ||
"--vars <namevalue...>", | ||
"variables, as name=value, stored in env.vars" | ||
) | ||
.option("-rr, --run-retry <number>", "number of retries for the entire run") | ||
.option( | ||
"-rr, --run-retry <number>", | ||
"number of retries for the entire run" | ||
) | ||
Check failure on line 154 in packages/cli/src/cli.ts GitHub Actions / build
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing semicolon
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function
|
||
.action(runScriptWithExitCode) | ||
|
||
const test = program.command("test") | ||
|
@@ -205,6 +208,7 @@ | |
scripts | ||
.command("compile") | ||
.description("Compile all script in workspace") | ||
.argument("[folders...]", "Pattern to match files") | ||
.action(compileScript) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing semicolon
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function
|
||
scripts | ||
.command("model") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,18 +24,25 @@ export async function createScript(name: string) { | |
const t = coreCreateScript(name) | ||
const pr = await copyPrompt(t, { fork: false, name }) | ||
console.log(`created script at ${pr}`) | ||
await compileScript() | ||
await compileScript([]) | ||
} | ||
|
||
export async function fixScripts() { | ||
const project = await buildProject() | ||
await fixPromptDefinitions(project) | ||
} | ||
|
||
export async function compileScript() { | ||
export async function compileScript(folders: string[]) { | ||
const project = await buildProject() | ||
await fixPromptDefinitions(project) | ||
for (const folder of project.folders()) { | ||
const scriptFolders = project.folders() | ||
const foldersToCompile = ( | ||
folders?.length ? folders : project.folders().map((f) => f.dirname) | ||
) | ||
.map((f) => scriptFolders.find((sf) => sf.dirname === f)) | ||
.filter((f) => f) | ||
|
||
for (const folder of foldersToCompile) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no error handling for the case when the
|
||
const { dirname, js, ts } = folder | ||
logVerbose(`compiling ${dirname}`) | ||
if (js) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import { | |
checkCancelled, | ||
} from "./cancellation" | ||
import { assert, logError, logVerbose } from "./util" | ||
import { extractFenced, findFirstDataFence } from "./fence" | ||
import { extractFenced, findFirstDataFence, unfence } from "./fence" | ||
import { | ||
toStrictJSONSchema, | ||
validateFencesWithSchema, | ||
|
@@ -330,13 +330,21 @@ Repair the DATA_FORMAT_ISSUES. THIS IS IMPORTANT.` | |
return true | ||
} | ||
|
||
function assistantText(messages: ChatCompletionMessageParam[]) { | ||
function assistantText( | ||
messages: ChatCompletionMessageParam[], | ||
responseType?: PromptTemplateResponseType | ||
) { | ||
let text = "" | ||
for (let i = messages.length - 1; i >= 0; i--) { | ||
const msg = messages[i] | ||
if (msg.role !== "assistant") break | ||
text = msg.content + text | ||
} | ||
|
||
if (responseType === undefined) { | ||
text = unfence(text, "(markdown|md)") | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function
|
||
|
||
return text | ||
} | ||
|
||
|
@@ -352,7 +360,7 @@ function structurifyChatSession( | |
): RunPromptResult { | ||
const { trace, responseType, responseSchema } = options | ||
const { resp, err } = others || {} | ||
const text = assistantText(messages) | ||
const text = assistantText(messages, responseType) | ||
const annotations = parseAnnotations(text) | ||
const finishReason = isCancelError(err) | ||
? "cancel" | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -323,6 +323,7 @@ export async function runTemplate( | |
trace.detailsFenced(`π file ${fn}`, content) | ||
const fileEdit = await getFileEdit(fn) | ||
fileEdit.after = content | ||
fileEdit.validation = { valid: true } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
|
||
} | ||
if (oannotations) annotations = oannotations.slice(0) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The usage of the 'compile' command has been updated to include '<folders...>' but the description 'Compile all script in workspace' has not been updated to reflect the change in usage. Consider revising the description to indicate that the command now accepts specific folder patterns as arguments.