Skip to content

Commit

Permalink
breaking(js/ai): refactored prompts API, migrated to standalone dotpr… (
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelgj authored Jan 25, 2025
1 parent 378fc08 commit a828083
Show file tree
Hide file tree
Showing 59 changed files with 2,242 additions and 4,047 deletions.
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}`;
} 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),
})
);
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

0 comments on commit a828083

Please sign in to comment.