-
Notifications
You must be signed in to change notification settings - Fork 153
feat: setup langwatch managed prompts in the mastra example #10
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { trace } from "@opentelemetry/api"; | ||
|
|
||
| const tracer = trace.getTracer("langwatch.prompts", "0.0.1"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be nice to get some comments/documentation on this file, assuming people aren't otel experts?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but otel is so simple, how could people not understand |
||
|
|
||
| export interface LangWatchPrompt { | ||
| id: string; | ||
| name: string; | ||
| version: number; | ||
| versionId: string; | ||
| versionCreatedAt: string; | ||
| model: string; | ||
| prompt: string; | ||
| updatedAt: string; | ||
| messages: Message[]; | ||
| response_format: any; | ||
| } | ||
|
|
||
| export interface Message { | ||
| role: string; | ||
| content: string; | ||
| } | ||
|
|
||
| export async function getPrompt(id: string): Promise<LangWatchPrompt> { | ||
| return await tracer.startActiveSpan("langwatch.get_prompt", async (span) => { | ||
| span.setAttribute("langwatch.prompt.id", id); | ||
|
|
||
| const options = { | ||
| method: "GET", | ||
| headers: { "X-Auth-Token": process.env.LANGWATCH_API_KEY ?? "" }, | ||
| }; | ||
|
|
||
| const response = await fetch(`https://app.langwatch.ai/api/prompts/${id}`, options); | ||
| const prompt = await response.json() as LangWatchPrompt; | ||
|
|
||
| span.setAttribute("langwatch.prompt.version.id", prompt.versionId); | ||
| span.setAttribute("langwatch.prompt.version.number", prompt.version); | ||
|
|
||
| span.end(); | ||
| return prompt; | ||
| }); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to make another example for using this with the prompt fetch? Most people won't understand this/have langwatch integrated already maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate? I'm confused here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@0xdeafcafe this comment only makes sense if we're going to merge it in for general consumption
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we do merge it, it should be it's own example maybe? As it has a few additional dependencies.