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

feat(prompts): add commit message #508

Merged
merged 2 commits into from
Feb 10, 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
4 changes: 4 additions & 0 deletions integration-test/langfuse-integration-fetch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ describe("Langfuse (fetch)", () => {
name: promptName,
isActive: true,
prompt: "A {{animal}} usually has {{animal}} friends.",
commitMessage: "initial commit",
});

expect(createdPrompt.constructor.name).toBe("TextPromptClient");
Expand All @@ -464,6 +465,7 @@ describe("Langfuse (fetch)", () => {
expect(createdPrompt.constructor.name).toBe("TextPromptClient");
expect(fetchedPrompt.name).toEqual(promptName);
expect(fetchedPrompt.prompt).toEqual("A {{animal}} usually has {{animal}} friends.");
expect(fetchedPrompt.commitMessage).toBe("initial commit");
expect(fetchedPrompt.compile({ animal: "dog" })).toEqual("A dog usually has dog friends.");
});

Expand Down Expand Up @@ -529,6 +531,7 @@ describe("Langfuse (fetch)", () => {
type: "chat",
isActive: true,
prompt: [{ role: "system", content: "A {{animal}} usually has {{animal}} friends." }],
commitMessage: "initial commit",
});

expect(createdPrompt.constructor.name).toBe("ChatPromptClient");
Expand All @@ -543,6 +546,7 @@ describe("Langfuse (fetch)", () => {
expect(fetchedPrompt.compile({ animal: "dog" })).toEqual([
{ role: "system", content: "A dog usually has dog friends." },
]);
expect(fetchedPrompt.commitMessage).toBe("initial commit");
});

it("should not return fallback if fetch succeeds", async () => {
Expand Down
12 changes: 12 additions & 0 deletions langfuse-core/openapi-spec/openapi-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4523,6 +4523,10 @@ components:
type: string
nullable: true
description: List of tags to apply to all versions of this prompt.
commitMessage:
type: string
nullable: true
description: Commit message for this prompt version.
required:
- name
- prompt
Expand All @@ -4548,6 +4552,10 @@ components:
type: string
nullable: true
description: List of tags to apply to all versions of this prompt.
commitMessage:
type: string
nullable: true
description: Commit message for this prompt version.
required:
- name
- prompt
Expand Down Expand Up @@ -4597,6 +4605,10 @@ components:
description: >-
List of tags. Used to filter via UI and API. The same across
versions of a prompt.
commitMessage:
type: string
nullable: true
description: Commit message for this prompt version.
required:
- name
- version
Expand Down
6 changes: 6 additions & 0 deletions langfuse-core/src/openapi/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,8 @@ export interface components {
labels?: string[] | null;
/** @description List of tags to apply to all versions of this prompt. */
tags?: string[] | null;
/** @description Commit message for this prompt version. */
commitMessage?: string | null;
};
/** CreateTextPromptRequest */
CreateTextPromptRequest: {
Expand All @@ -1579,6 +1581,8 @@ export interface components {
labels?: string[] | null;
/** @description List of tags to apply to all versions of this prompt. */
tags?: string[] | null;
/** @description Commit message for this prompt version. */
commitMessage?: string | null;
};
/** Prompt */
Prompt:
Expand All @@ -1599,6 +1603,8 @@ export interface components {
labels: string[];
/** @description List of tags. Used to filter via UI and API. The same across versions of a prompt. */
tags: string[];
/** @description Commit message for this prompt version. */
commitMessage?: string | null;
};
/** ChatMessage */
ChatMessage: {
Expand Down
2 changes: 2 additions & 0 deletions langfuse-core/src/prompts/promptClients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ abstract class BasePromptClient {
public readonly isFallback: boolean;
public readonly type: "text" | "chat";
public readonly prompt: string | ChatMessage[];
public readonly commitMessage: string | null | undefined;

constructor(prompt: CreateLangfusePromptResponse, isFallback = false, type: "text" | "chat") {
this.name = prompt.name;
Expand All @@ -25,6 +26,7 @@ abstract class BasePromptClient {
this.isFallback = isFallback;
this.type = type;
this.prompt = prompt.prompt;
this.commitMessage = prompt.commitMessage;
}

abstract compile(variables?: Record<string, string>): string | ChatMessage[];
Expand Down
6 changes: 6 additions & 0 deletions langfuse/src/publicApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,8 @@ export interface ApiCreateChatPromptRequest {
labels?: string[] | null;
/** List of tags to apply to all versions of this prompt. */
tags?: string[] | null;
/** Commit message for this prompt version. */
commitMessage?: string | null;
}

/** CreateTextPromptRequest */
Expand All @@ -1088,6 +1090,8 @@ export interface ApiCreateTextPromptRequest {
labels?: string[] | null;
/** List of tags to apply to all versions of this prompt. */
tags?: string[] | null;
/** Commit message for this prompt version. */
commitMessage?: string | null;
}

/** Prompt */
Expand All @@ -1108,6 +1112,8 @@ export interface ApiBasePrompt {
labels: string[];
/** List of tags. Used to filter via UI and API. The same across versions of a prompt. */
tags: string[];
/** Commit message for this prompt version. */
commitMessage?: string | null;
}

/** ChatMessage */
Expand Down
Loading