-
Notifications
You must be signed in to change notification settings - Fork 338
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
Javascript SDK #876
Comments
@jverre Could you provide an update on the JavaScript SDK? Do you have an estimate of when it will be ready for use? Thank you! |
Hi @Bayesian4042, |
@jverre thanks for the update, I see the PR has been merged, is it possible to have a documentation on how to use it?. thank you |
@ferc is working on auto-generating the docs, should be ready in the next couple of days and will ping you here |
@jverre how is the progress going on ? I'm eager to integrate some evaluation tool in our application :) |
Hi, any ETA on this, this will save us so much time. |
Hi @JassimranK @Bayesian4042 , Sorry for the delays here, we are not moving as quickly as we were hoping but progress is being made. We have a PR open for adding batching to the Javascript SDK which is what we were waiting for to make the SDK public. Once that is merged, we will add the Javascript reference docs to the website. We are getting closer |
@JassimranK / @Bayesian4042 as @jverre mentioned we're currently making progress on it! May I ask you the exact use case that you expect to have in our JavaScript/TypeScript SDK? that would help us to prioritize properly the work here :) Currently you can install the alpha version of this SDK from NPM (not documented yet, as Jacques mentioned, it's still in an early phase): https://www.npmjs.com/package/opik Currently it supports logging spans and traces manually: import { Opik } from "opik";
// Create a new Opik client with your configuration
const client = new Opik({
apiKey: "<your-api-key>",
host: "https://www.comet.com/opik/api",
projectName: "<your-project-name>",
workspaceName: "<your-workspace-name>",
});
// Log 10 traces
for (let i = 0; i < 10; i++) {
const someTrace = client.trace({
name: `Trace ${i}`,
input: {
prompt: `Hello, world! ${i}`,
},
output: {
response: `Hello, world! ${i}`,
},
});
// For each trace, log 10 spans
for (let j = 0; j < 10; j++) {
const someSpan = someTrace.span({
name: `Span ${i}-${j}`,
type: "llm",
input: {
prompt: `Hello, world! ${i}:${j}`,
},
output: {
response: `Hello, world! ${i}:${j}`,
},
});
// Some LLM work
await new Promise((resolve) => setTimeout(resolve, 100));
// Mark the span as ended
someSpan.end();
}
// Mark the trace as ended
someTrace.end();
}
// Flush the client to send all traces and spans
await client.flush(); Also the Hope that helps! |
Good news everyone! The JavaScript PR has been merged, and we will be adding a specific doc page for it shortly. |
@dsblank thank you for the update, the given example is not very clear me, could you help me with actuall openai LLM call example, thank you |
Hello @Bayesian4042 as part of the TypeScript SDK work we introduced an integration with Vercel AI SDK: #1253 Therefore now it's possible to integrate Opik with any provider/model listed here: https://sdk.vercel.ai/docs/foundations/providers-and-models (including OpenAI models, Anthropic, Gemini and more) How to integrate Opik with it?
OPIK_API_KEY="your-api-key"
OPIK_HOST="https://www.comet.com/opik/api"
OPIK_PROJECT_NAME="your-project-name"
OPIK_WORKSPACE_NAME="your-workspace-name"
OPENAI_API_KEY="your-openai-key" Dependencies installation: npm install opik ai @ai-sdk/openai @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node import { openai } from "@ai-sdk/openai";
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
import { NodeSDK } from "@opentelemetry/sdk-node";
import { generateText } from "ai";
import { OpikExporter } from "opik/vercel";
const sdk = new NodeSDK({
traceExporter: new OpikExporter(),
instrumentations: [getNodeAutoInstrumentations()],
});
sdk.start();
const { text } = await generateText({
model: openai("gpt-4o-mini"),
prompt: "What is love? Describe it in 10 words or less.",
experimental_telemetry: OpikExporter.getSettings({
name: "ai-sdk-integration",
}),
});
await sdk.shutdown(); Depending on the environment where you're using it (develop or production monitoring), the code snippet could be defined in a better way, we're going to add soon the proper documentation for it If you are looking for a direct OpenAI wrapper, let us know and we can prioritize that work :) |
Proposal summary
We are currently working on a Javascript SDK, feel free to leave comments below on the functionality you would like us to add !
We are currently planning to release the SDK in different phases:
opik.Opik
class in Python which allows you to log traces manuallyopik.track
decoratorHallucination
,Relevance
, etc metricsMotivation
No response
The text was updated successfully, but these errors were encountered: