Skip to content

Commit

Permalink
chore: rename 'prompt' to 'preamble' in chat (#1190)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelgj authored Nov 7, 2024
1 parent deebe4c commit eca6631
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion js/genkit/src/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export type ChatGenerateOptions<
> = GenerateOptions<O, CustomOptions>;

export interface PromptRenderOptions<I> {
prompt: ExecutablePrompt<I>;
preamble: ExecutablePrompt<I>;
input?: I;
}

Expand Down
4 changes: 2 additions & 2 deletions js/genkit/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ export class Session<S = any> {
}
}
let requestBase: Promise<BaseGenerateOptions>;
if (!!(options as PromptRenderOptions<I>)?.prompt?.render) {
if (!!(options as PromptRenderOptions<I>)?.preamble?.render) {
const renderOptions = options as PromptRenderOptions<I>;
requestBase = renderOptions.prompt
requestBase = renderOptions.preamble
.render({
input: renderOptions.input,
})
Expand Down
6 changes: 3 additions & 3 deletions js/genkit/tests/chat_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ describe('chat', () => {
});

it('can start chat from a prompt', async () => {
const prompt = ai.definePrompt(
const preamble = ai.definePrompt(
{ name: 'hi', config: { version: 'abc' } },
'hi {{ name }} from template'
);
const session = await ai.chat({
prompt,
preamble,
input: { name: 'Genkit' },
});
const response = await session.send('send it');
Expand Down Expand Up @@ -208,7 +208,7 @@ describe('preabmle', () => {
};

const session = ai.chat({
prompt: agentA,
preamble: agentA,
});
let { text } = await session.send('hi');
assert.strictEqual(text, 'hi from agent a');
Expand Down
2 changes: 1 addition & 1 deletion js/genkit/tests/session_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ describe('session', () => {
foo: 'bar',
},
});
const chat = session.chat({ prompt: agent });
const chat = session.chat({ preamble: agent });
const respose = await chat.send('hi');
assert.deepStrictEqual(respose.messages, [
{
Expand Down
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"pack:ai": "cd ai && pnpm pack --pack-destination ../../dist",
"pack:genkit": "cd genkit && pnpm pack --pack-destination ../../dist",
"pack:plugins": "for i in plugins/*/; do cd $i && pnpm pack --pack-destination ../../../dist && cd ../..; done",
"test:all": "pnpm -r --workspace-concurrency 0 -F \"./(ai|core|plugins)/**\" test"
"test:all": "pnpm -r --workspace-concurrency 0 -F \"./(ai|core|plugins|genkit)/**\" test"
},
"devDependencies": {
"npm-run-all": "^4.1.5",
Expand Down

0 comments on commit eca6631

Please sign in to comment.