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 example notebook for the JS SDK #1067

Merged
merged 17 commits into from
Dec 4, 2024
28 changes: 28 additions & 0 deletions components-mdx/get-started-js-sdk.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
```ts filename="server.ts"
import { Langfuse } from "langfuse";

const langfuse = new Langfuse();

const trace = langfuse.trace({
name: "my-AI-application-endpoint",
});

// Example generation creation
const generation = trace.generation({
name: "chat-completion",
model: "gpt-3.5-turbo",
modelParameters: {
temperature: 0.9,
maxTokens: 2000,
},
input: messages,
});

// Application code
const chatCompletion = await llm.respond(prompt);

// End generation - sets endTime
generation.end({
output: chatCompletion,
});
```
4 changes: 4 additions & 0 deletions cookbook/_routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,9 @@
{
"notebook": "example_query_data_via_sdk.ipynb",
"docsPath": null
},
{
"notebook": "js_langfuse_sdk.ipynb",
"docsPath": "docs/sdk/typescript/example-notebook"
}
]
Loading
Loading