Skip to content

Commit

Permalink
patch: push existing prompt without specifying any other options
Browse files Browse the repository at this point in the history
  • Loading branch information
madams0013 committed Aug 1, 2024
1 parent 6ba2489 commit e0047ad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
14 changes: 8 additions & 6 deletions js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3417,12 +3417,14 @@ export class Client {
): Promise<string> {
// Create or update prompt metadata
if (await this.promptExists(promptIdentifier)) {
await this.updatePrompt(promptIdentifier, {
description: options?.description,
readme: options?.readme,
tags: options?.tags,
isPublic: options?.isPublic,
});
if (options && Object.keys(options).some((key) => key !== "object")) {
await this.updatePrompt(promptIdentifier, {
description: options?.description,
readme: options?.readme,
tags: options?.tags,
isPublic: options?.isPublic,
});
}
} else {
await this.createPrompt(promptIdentifier, {
description: options?.description,
Expand Down
12 changes: 12 additions & 0 deletions js/src/tests/client.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,13 @@ test("Test push and pull prompt", async () => {
],
{ templateFormat: "mustache" }
);
const template2 = ChatPromptTemplate.fromMessages(
[
new SystemMessage({ content: "System message" }),
new HumanMessage({ content: "My question is: {{question}}" }),
],
{ templateFormat: "mustache" }
);

await client.pushPrompt(promptName, {
object: template,
Expand All @@ -1005,6 +1012,11 @@ test("Test push and pull prompt", async () => {
tags: ["test", "tag"],
});

// test you can push an updated manifest
await client.pushPrompt(promptName, {
object: template2,
});

const pulledPrompt = await client._pullPrompt(promptName);
expect(pulledPrompt).toBeDefined();

Expand Down

0 comments on commit e0047ad

Please sign in to comment.