Skip to content
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

breaking(js/ai): refactored prompts API, migrated to standalone dotpr… #1651

Merged
merged 12 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .github/workflows/bump-js-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,6 @@ jobs:
preid: ${{ inputs.preid }}
commit-message: 'chore: bump @genkit-ai/dev-local-vectorstore version to {{version}}'
tag-prefix: '@genkit-ai/dev-local-vectorstore@'
- name: 'js/plugins/dotprompt version bump'
uses: 'phips28/gh-action-bump-version@master'
env:
GITHUB_TOKEN: ${{ secrets.GENKIT_RELEASER_GITHUB_TOKEN }}
PACKAGEJSON_DIR: js/plugins/dotprompt
with:
default: ${{ inputs.releaseType }}
version-type: ${{ inputs.releaseType }}
preid: ${{ inputs.preid }}
commit-message: 'chore: bump @genkit-ai/dotprompt version to {{version}}'
tag-prefix: '@genkit-ai/dotprompt@'
- name: 'js/plugins/evaluators version bump'
uses: 'phips28/gh-action-bump-version@master'
env:
Expand Down
4 changes: 3 additions & 1 deletion js/ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"build": "npm-run-all build:clean check compile",
"build:watch": "tsup-node --watch",
"test": "node --import tsx --test ./tests/**/*_test.ts ./tests/*_test.ts",
"test:watch": "node --watch --import tsx --test ./tests/**/*_test.ts ./tests/*_test.ts",
"test:single": "node --import tsx --test"
},
"repository": {
Expand All @@ -33,7 +34,8 @@
"json5": "^2.2.3",
"node-fetch": "^3.3.2",
"partial-json": "^0.1.7",
"uuid": "^10.0.0"
"uuid": "^10.0.0",
"dotprompt": "^1.0.0-dev || ^1"
},
"devDependencies": {
"npm-run-all": "^4.1.5",
Expand Down
12 changes: 8 additions & 4 deletions js/ai/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ async function resolveFullToolName(
return `/tool/${name}`;
} else if (await registry.lookupAction(`/prompt/${name}`)) {
return `/prompt/${name}`;
} else if (await registry.lookupAction(`/prompt/dotprompt/${name}`)) {
return `/prompt/dotprompt/${name}`;
mbleigh marked this conversation as resolved.
Show resolved Hide resolved
mbleigh marked this conversation as resolved.
Show resolved Hide resolved
} else {
throw new Error(`Unable to determine type of of tool: ${name}`);
}
Expand All @@ -372,10 +374,12 @@ export function generateStream<
): GenerateStreamResponse<O> {
let channel = new Channel<GenerateResponseChunk>();

const generated = generate<O, CustomOptions>(registry, {
...options,
onChunk: (chunk) => channel.send(chunk),
});
const generated = Promise.resolve(options).then((resolvedOptions) =>
generate<O, CustomOptions>(registry, {
...resolvedOptions,
onChunk: (chunk) => channel.send(chunk),
})
);
mbleigh marked this conversation as resolved.
Show resolved Hide resolved
generated.then(
() => channel.close(),
(err) => channel.error(err)
Expand Down
6 changes: 4 additions & 2 deletions js/ai/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,15 @@ export {
type ToolResponsePart,
} from './model.js';
export {
defineHelper,
definePartial,
definePrompt,
isExecutablePrompt,
renderPrompt,
loadPromptFolder,
prompt,
type ExecutablePrompt,
type PromptAction,
type PromptConfig,
type PromptFn,
type PromptGenerateOptions,
} from './prompt.js';
export {
Expand Down
Loading
Loading