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

docs: add jsdoc across main methods of sdk #247

Open
wants to merge 90 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 80 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
efde2d7
docs: add jsdoc across main methods of sdk
RichardKruemmel Jun 17, 2024
a70e10d
push
RichardKruemmel Jun 17, 2024
0c7f3b6
chore: update js docs
RichardKruemmel Jun 17, 2024
97e51e7
feat: add docstring for methods to create events, spans, generations,…
RichardKruemmel Jun 17, 2024
821bedd
docs: add jsdoc
RichardKruemmel Jun 17, 2024
293a580
docs: add more docs
RichardKruemmel Jun 17, 2024
ff2f4cd
docs: cover interfaces in sdk reference (#252)
marcklingen Jun 18, 2024
f56744a
docs: add examples to low-level sdk methods
RichardKruemmel Jun 18, 2024
9171c60
chore: update CreateLangfuseTraceBody interface in types.ts
RichardKruemmel Jun 18, 2024
8501328
docs: add interfaces for CreateObjectBodies
RichardKruemmel Jun 18, 2024
f5fba10
docs: add CreateDataset documentation
RichardKruemmel Jun 18, 2024
35af26d
docs: add LangfuseCoreOption documentation
RichardKruemmel Jun 18, 2024
b5e75e8
chore: Update LangfuseCore constructor documentation and examples
RichardKruemmel Jun 18, 2024
a64af89
doc: Add createDatasetItem
RichardKruemmel Jun 18, 2024
ec4d16d
docs: add createDatasetRunItem
RichardKruemmel Jun 18, 2024
b4d5e35
docs: add dataset documentation
RichardKruemmel Jun 18, 2024
dc1b4a6
docs: add CreateLangfuseDatasetResponse
RichardKruemmel Jun 18, 2024
a5eef0a
docs: add CreateLangfuseDatasetRunItemResponse
RichardKruemmel Jun 18, 2024
dec6d0a
chore: Update LangfuseCore constructor documentation and examples
RichardKruemmel Jun 18, 2024
b2a7150
docs: Update Langfuse SDK constructor documentation and examples
RichardKruemmel Jun 18, 2024
091ec7f
Fix constructor type
RichardKruemmel Jun 18, 2024
e30c32e
Fix indent
RichardKruemmel Jun 18, 2024
cdff97e
docs: Update Langfuse SDK constructor documentation and examples
RichardKruemmel Jun 18, 2024
f09f07e
docs: add better documentation for docs
RichardKruemmel Jun 18, 2024
277497c
fix replace type
RichardKruemmel Jun 18, 2024
a56b616
fix type
RichardKruemmel Jun 18, 2024
802654e
chore: Refactor Langfuse SDK constructor to simplify parameter handling
RichardKruemmel Jun 18, 2024
f88d066
Refactor Langfuse SDK constructor to simplify parameter handling
RichardKruemmel Jun 18, 2024
bdf52a8
docs: add doc for TextPromptClient
RichardKruemmel Jun 19, 2024
c64cd08
docs: add docs for BasePromptClient
RichardKruemmel Jun 19, 2024
710022a
docs: improve docs of promptClient
RichardKruemmel Jun 19, 2024
e870df0
docs: add more pretty types
RichardKruemmel Jun 19, 2024
d1eecdf
docs: add new types for update and end methods
RichardKruemmel Jun 19, 2024
a66a83f
docs: replace with new types
RichardKruemmel Jun 19, 2024
4e88c6e
docs: update langchain callback documentation
RichardKruemmel Jun 19, 2024
35a64cf
feat: Add LangfuseWeb docs
RichardKruemmel Jun 20, 2024
fccb03a
docs: Update LangfuseWebOptions with new properties and defaults
RichardKruemmel Jun 20, 2024
0453a8c
feat: Update LangfuseWebOptions with new properties and defaults
RichardKruemmel Jun 20, 2024
68fccf1
docs: Update completionStartTime property in types.ts
RichardKruemmel Jun 20, 2024
b9cb86f
chore: Update LangfusePromptClient type definition
RichardKruemmel Jun 20, 2024
a9fde33
feat: Add Langfuse callback handler documentation
RichardKruemmel Jun 20, 2024
ef2d282
Update LangfuseCore to use CreateLangfuseGenerationWithoutParent inst…
RichardKruemmel Jun 20, 2024
c7c3d57
chore: Update LangfusePromptClient and ChatPromptClient compile metho…
RichardKruemmel Jun 20, 2024
717ae36
Merge branch 'main' into jsdoc-across-sdk
RichardKruemmel Jun 20, 2024
3ba44fc
fix body types
RichardKruemmel Jun 20, 2024
a5510b5
fix merge from main
RichardKruemmel Jun 20, 2024
0f9e374
Fix constructor
RichardKruemmel Jun 20, 2024
5032a30
Merge branch 'main' into jsdoc-across-sdk
RichardKruemmel Jul 24, 2024
8faf86a
feat: Add fetchTraces, fetchTrace, fetchObservations, fetchObservatio…
RichardKruemmel Jul 24, 2024
c99fc0b
chore: Add isFallback property to promptClients.ts
RichardKruemmel Jul 24, 2024
d0888a3
chore: Update dataset creation method documentation
RichardKruemmel Jul 24, 2024
23e16c4
feat: Update dataset creation method documentation
RichardKruemmel Jul 25, 2024
950d576
Add documentation to FixTypes
RichardKruemmel Jul 25, 2024
24cb9cb
Add PromptBody documentation
RichardKruemmel Jul 25, 2024
a787297
chore: Add name property to CallbackHandler
RichardKruemmel Jul 25, 2024
2a6e2e3
chore: Add CreateLangfusePromptBody interface
RichardKruemmel Jul 25, 2024
d07bd41
chore: Update LangfuseConfig with additional properties
RichardKruemmel Jul 25, 2024
0e20ce5
chore: Refactor LangfuseParent interface and update LangfuseConfig
RichardKruemmel Jul 25, 2024
4775bb7
Revert changes
RichardKruemmel Jul 25, 2024
e19f9ce
chore: Add GetLangfuseObservationsQuery interface
RichardKruemmel Jul 26, 2024
58c9955
Refactor GetLangfuseObservationsQuery interface
RichardKruemmel Jul 26, 2024
85ea7dd
Refactor GetLangfuseObservationsQuery interface
RichardKruemmel Jul 26, 2024
4f844af
Refactor GetLangfuseObservationsQuery interface
RichardKruemmel Jul 26, 2024
7e26c29
chore: Refactor GetLangfuseObservationsQuery interface and update typ…
RichardKruemmel Jul 26, 2024
1c0a771
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 26, 2024
5018b31
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 26, 2024
4b65504
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 26, 2024
888046f
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 26, 2024
9131f3c
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 26, 2024
8c0785c
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 26, 2024
6a45986
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 26, 2024
fa81c9b
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 26, 2024
a154ead
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 26, 2024
365e845
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 26, 2024
d5af2b3
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 26, 2024
0fc8ed7
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 26, 2024
24e5a93
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 26, 2024
118f681
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 26, 2024
da630ce
Add fetch for Sessions
RichardKruemmel Jul 26, 2024
36bc185
chore: Refactor GetLangfuseObservationsQuery interface and update typ…
RichardKruemmel Jul 29, 2024
f833638
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 29, 2024
a99d948
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 29, 2024
6ca74c0
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 29, 2024
9de89d4
Refactor GetLangfuseObservationsQuery interface and update types.ts
RichardKruemmel Jul 29, 2024
e8b8816
move descriptions to openapi spec and update spec
marcklingen Jul 29, 2024
bdf1bfe
add missing
marcklingen Jul 29, 2024
88953d9
yarn lock
marcklingen Jul 29, 2024
b28b1e0
Merge branch 'main' into jsdoc-across-sdk
RichardKruemmel Aug 2, 2024
1cec5cb
remove duplicated props
marcklingen Aug 2, 2024
1cd4c4d
remove unnecessary jsdoc
marcklingen Aug 5, 2024
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
743 changes: 709 additions & 34 deletions langfuse-core/src/index.ts

Large diffs are not rendered by default.

55 changes: 54 additions & 1 deletion langfuse-core/src/prompts/promptClients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ mustache.escape = function (text) {
return text;
};

/**
* BasePromptClient - A base class for handling prompts.
*
* @class
* @property {string} name - The name of the prompt.
* @property {number} version - The version of the prompt.
* @property {unknown} config - The config of the prompt.
* @property {string[]} labels - The labels of the prompt.
* @property {boolean} isFallback - Whether the prompt is a fallback prompt.
* @method compile - Compiles the prompt content.
* @method getLangchainPrompt - Converts the prompt content to a Langchain-compatible format.
*/
abstract class BasePromptClient {
public readonly name: string;
public readonly version: number;
Expand All @@ -29,7 +41,14 @@ abstract class BasePromptClient {
return content.replace(/\{\{(.*?)\}\}/g, "{$1}");
}
}

/**
* TextPromptClient - A client for handling text-based prompts.
*
* @class
* @extends BasePromptClient
* @property {TextPrompt} promptResponse - The prompt response object.
* @property {string} prompt - The prompt content.
*/
export class TextPromptClient extends BasePromptClient {
public readonly promptResponse: TextPrompt;
public readonly prompt: string;
Expand All @@ -40,10 +59,20 @@ export class TextPromptClient extends BasePromptClient {
this.prompt = prompt.prompt;
}

/**
* Compiles the prompt content.
* @param {Record<string, string>} variables - The variables to be used in the prompt.
* @returns {string} The compiled prompt content.
*/
compile(variables?: Record<string, string>): string {
return mustache.render(this.promptResponse.prompt, variables ?? {});
}

/**
* Converts Langfuse prompt into string compatible with Langchain PromptTemplate.
*
* @returns {string} The string that can be plugged into Langchain's PromptTemplate.
*/
public getLangchainPrompt(): string {
/**
* Converts Langfuse prompt into string compatible with Langchain PromptTemplate.
Expand All @@ -57,6 +86,14 @@ export class TextPromptClient extends BasePromptClient {
}
}

/**
* ChatPromptClient - A client for handling chat-based prompts.
*
* @class
* @extends BasePromptClient
* @property {ChatPrompt} promptResponse - The prompt response object.
* @property {ChatMessage[]} prompt - The prompt content.
*/
export class ChatPromptClient extends BasePromptClient {
public readonly promptResponse: ChatPrompt;
public readonly prompt: ChatMessage[];
Expand All @@ -67,13 +104,23 @@ export class ChatPromptClient extends BasePromptClient {
this.prompt = prompt.prompt;
}

/**
* Compiles the prompt content.
* @param {Record<string, string>} variables - The variables to be used in the prompt.
* @returns {ChatMessage[]} The compiled prompt content.
*/
compile(variables?: Record<string, string>): ChatMessage[] {
return this.prompt.map<ChatMessage>((chatMessage) => ({
...chatMessage,
content: mustache.render(chatMessage.content, variables ?? {}),
}));
}

/**
* Converts Langfuse prompt into string compatible with Langchain PromptTemplate.
*
* @returns {ChatMessage[]} Chat messages with variables that can be plugged into Langchain's ChatPromptTemplate.
*/
public getLangchainPrompt(): ChatMessage[] {
/**
* Converts Langfuse prompt into string compatible with Langchain PromptTemplate.
Expand Down Expand Up @@ -101,4 +148,10 @@ export class ChatPromptClient extends BasePromptClient {
}
}

/**
* LangfusePromptClient - A client for handling prompts.
* It can be either a TextPromptClient or a ChatPromptClient.
*
* @type {TextPromptClient | ChatPromptClient}
*/
export type LangfusePromptClient = TextPromptClient | ChatPromptClient;
567 changes: 531 additions & 36 deletions langfuse-core/src/types.ts

Large diffs are not rendered by default.

Loading
Loading