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: migrate to batch ingestion endpoint #58

Merged
merged 29 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
55e47ce
migrate to ingestion endpoint
maxdeichmann Dec 11, 2023
0687d76
stuff
maxdeichmann Dec 11, 2023
3f1d4c8
bug
maxdeichmann Dec 11, 2023
bc08b81
core tests
maxdeichmann Dec 11, 2023
09740ad
any typiing
maxdeichmann Dec 12, 2023
9eb14d0
push
maxdeichmann Dec 12, 2023
934dea7
Merge branch 'v2' into migrate-to-ingestion-endpoint
maxdeichmann Dec 12, 2023
dc2512e
improvements
maxdeichmann Dec 12, 2023
c219390
fix
maxdeichmann Dec 12, 2023
9ca6e75
Merge branch 'v2' into migrate-to-ingestion-endpoint
maxdeichmann Dec 13, 2023
385db26
post merge cleanup
maxdeichmann Dec 13, 2023
8c53ddb
versions
maxdeichmann Dec 13, 2023
61fc41b
Merge branch 'v2' into migrate-to-ingestion-endpoint
maxdeichmann Dec 13, 2023
a615840
add tests
maxdeichmann Dec 13, 2023
13cf706
add testing
maxdeichmann Dec 13, 2023
8f7e101
log level
maxdeichmann Dec 13, 2023
bf868e6
add usage tests
maxdeichmann Dec 13, 2023
57476b1
improvement
maxdeichmann Dec 13, 2023
2e2ec5a
fixes
maxdeichmann Dec 13, 2023
4784549
Merge branch 'v2' into migrate-to-ingestion-endpoint
maxdeichmann Dec 13, 2023
09e3df0
new api objects
maxdeichmann Dec 14, 2023
ebf5a76
push
maxdeichmann Dec 14, 2023
db837e9
push
maxdeichmann Dec 14, 2023
6554073
improvement
maxdeichmann Dec 14, 2023
f35f0e3
update
maxdeichmann Dec 15, 2023
810b880
remove unnecessary starttimes, minor edits
marcklingen Dec 16, 2023
03a6708
Merge branch 'v2' into migrate-to-ingestion-endpoint
maxdeichmann Dec 17, 2023
893537e
yarn
maxdeichmann Dec 17, 2023
b11d7b6
fix tests
maxdeichmann Dec 17, 2023
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: 2 additions & 2 deletions integration-test/langfuse-integration-datasets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ describe("Langfuse Node.js", () => {
for (const item of dataset.items) {
const generation = langfuse.generation({
id: "test-generation-id-" + projectNameRandom,
prompt: item.input,
completion: "Hello world generated",
input: item.input,
output: "Hello world generated",
});
await item.link(generation, "test-run-" + projectNameRandom);
generation.score({
Expand Down
14 changes: 7 additions & 7 deletions integration-test/langfuse-integration-fetch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ describe("Langfuse (fetch)", () => {
const trace = langfuse.trace({ name: "trace-name-generation-new" });
const generation = trace.generation({
name: "generation-name-new",
prompt: {
input: {
text: "prompt",
},
completion: {
output: {
foo: "bar",
},
});
Expand All @@ -180,12 +180,12 @@ describe("Langfuse (fetch)", () => {
const trace = langfuse.trace({ name: "trace-name-generation-new" });
const generation = trace.generation({
name: "generation-name-new",
prompt: [
input: [
{
text: "prompt",
},
],
completion: [
output: [
{
foo: "bar",
},
Expand Down Expand Up @@ -215,8 +215,8 @@ describe("Langfuse (fetch)", () => {
const trace = langfuse.trace({ name: "trace-name-generation-new" });
const generation = trace.generation({
name: "generation-name-new",
prompt: "prompt",
completion: "completion",
input: "prompt",
output: "completion",
});
await langfuse.flushAsync();
// check from get api if trace is created
Expand All @@ -239,7 +239,7 @@ describe("Langfuse (fetch)", () => {
completionStartTime: new Date("2020-01-01T00:00:00.000Z"),
});
generation.end({
completion: "Hello world",
output: "Hello world",
usage: {
promptTokens: 10,
completionTokens: 15,
Expand Down
17 changes: 0 additions & 17 deletions integration-test/langfuse-integration-langfuse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,5 @@ describe("Langfuse Langchain", () => {
});
expect(langfuse).toBeInstanceOf(Langfuse);
});

// it("exports the callback handler", async () => {
// const callbackHandler = new CallbackHandler({
// publicKey: LF_PUBLIC_KEY,
// secretKey: LF_SECRET_KEY,
// baseUrl: LF_HOST,
// });
// expect(callbackHandler).toBeInstanceOf(CallbackHandler);

// const llm = new OpenAI({
// openAIApiKey: "sk-...",
// streaming: true,
// });

// const res = await llm.call("Tell me a joke", undefined, [callbackHandler]);
// console.log(res);
// });
maxdeichmann marked this conversation as resolved.
Show resolved Hide resolved
});
});
5 changes: 4 additions & 1 deletion integration-test/langfuse-integration-modules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ describe("Test Different Module Conventions", () => {
cwd: join(__dirname, "modules"),
encoding: "utf-8",
});

console.log(result.output);
console.log(result.stdout);
console.log(result.stderr);
expect(result.status).toBe(0);
expect(result.stdout).toContain("Did construct objects and called them.");
expect(result.status).toBe(0);
}
Expand Down
66 changes: 59 additions & 7 deletions integration-test/langfuse-integration-node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ describe("Langfuse Node.js", () => {
const trace = langfuse.trace({ name: "trace-name-generation-new" });
const generation = trace.generation({
name: "generation-name-new",
prompt: {
input: {
text: "prompt",
},
completion: {
output: {
foo: "bar",
},
});
Expand All @@ -161,12 +161,12 @@ describe("Langfuse Node.js", () => {
const trace = langfuse.trace({ name: "trace-name-generation-new" });
const generation = trace.generation({
name: "generation-name-new",
prompt: [
input: [
{
text: "prompt",
},
],
completion: [
output: [
{
foo: "bar",
},
Expand Down Expand Up @@ -196,8 +196,8 @@ describe("Langfuse Node.js", () => {
const trace = langfuse.trace({ name: "trace-name-generation-new" });
const generation = trace.generation({
name: "generation-name-new",
prompt: "prompt",
completion: "completion",
input: "prompt",
output: "completion",
});
await langfuse.flushAsync();
// check from get api if trace is created
Expand All @@ -211,6 +211,58 @@ describe("Langfuse Node.js", () => {
});
});

it("create many objects", async () => {
const trace = langfuse.trace({ name: "trace-name-generation-new" });
const generation = trace.generation({
name: "generation-name-new",
input: "prompt",
output: "completion",
});
generation.update({
version: "1.0.0",
});
const span = generation.span({
name: "span-name",
input: "span-input",
output: "span-output",
});
span.end({ metadata: { foo: "bar" } });
generation.end({ metadata: { foo: "bar" } });

await langfuse.flushAsync();
// check from get api if trace is created
const returnedGeneration = await axios.get(`${LF_HOST}/api/public/observations/${generation.id}`, {
headers: getHeaders,
});
expect(returnedGeneration.data).toMatchObject({
id: generation.id,
name: "generation-name-new",
type: "GENERATION",
input: "prompt",
output: "completion",
version: "1.0.0",
endTime: expect.any(String),
metadata: {
foo: "bar",
},
});

const returnedSpan = await axios.get(`${LF_HOST}/api/public/observations/${span.id}`, {
headers: getHeaders,
});
expect(returnedSpan.data).toMatchObject({
id: span.id,
name: "span-name",
type: "SPAN",
input: "span-input",
output: "span-output",
endTime: expect.any(String),
metadata: {
foo: "bar",
},
});
});

it("update a generation", async () => {
const trace = langfuse.trace({
name: "test-trace",
Expand All @@ -220,7 +272,7 @@ describe("Langfuse Node.js", () => {
completionStartTime: new Date("2020-01-01T00:00:00.000Z"),
});
generation.end({
completion: "Hello world",
output: "Hello world",
usage: {
promptTokens: 10,
completionTokens: 15,
Expand Down
6 changes: 3 additions & 3 deletions integration-test/modules/node/commonjs.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ async function run() {
dotenv.config();

const secrets = {
baseUrl: String(process.env["LANGFUSE_URL"]),
publicKey: String(process.env["LANGFUSE_PK"]),
secretKey: String(process.env["LANGFUSE_SK"]),
baseUrl: String(process.env["LF_HOST"]),
publicKey: String(process.env["LF_PUBLIC_KEY"]),
secretKey: String(process.env["LF_SECRET_KEY"]),
};

const langfuse = new Langfuse(secrets);
Expand Down
6 changes: 3 additions & 3 deletions integration-test/modules/node/esm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export async function run() {
dotenv.config();

const langfuse = new Langfuse({
baseUrl: String(process.env["LANGFUSE_URL"]),
publicKey: String(process.env["LANGFUSE_PK"]),
secretKey: String(process.env["LANGFUSE_SK"]),
baseUrl: String(process.env["LF_HOST"]),
publicKey: String(process.env["LF_PUBLIC_KEY"]),
secretKey: String(process.env["LF_SECRET_KEY"]),
});

const trace = langfuse.trace({ userId: "user-id" });
Expand Down
4 changes: 2 additions & 2 deletions integration-test/modules/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "langfuse-integration-test-modules",
"version": "2.0.0-alpha.0",
"version": "2.0.0-alpha.2",
"private": true,
"description": "",
"main": "dist/main.js",
Expand All @@ -15,7 +15,7 @@
"dependencies": {
"dotenv": "^16.3.1",
"langchain": "^0.0.163",
"langfuse-langchain": "^2.0.0-alpha.0"
"langfuse-langchain": "^2.0.0-alpha.2"
},
"devDependencies": {
"tsx": "^4.6.2",
Expand Down
6 changes: 3 additions & 3 deletions integration-test/modules/ts-cjs/commonjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export async function run(): Promise<void> {
dotenv.config();

const secrets = {
baseUrl: String(process.env["LANGFUSE_URL"]),
publicKey: String(process.env["LANGFUSE_PK"]),
secretKey: String(process.env["LANGFUSE_SK"]),
baseUrl: String(process.env["LF_HOST"]),
publicKey: String(process.env["LF_PUBLIC_KEY"]),
secretKey: String(process.env["LF_SECRET_KEY"]),
};

const langfuse = new Langfuse(secrets);
Expand Down
6 changes: 3 additions & 3 deletions integration-test/modules/ts-nodenext/nodenext.mts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export async function run(): Promise<void> {
dotenv.config();

const langfuse = new Langfuse({
baseUrl: String(process.env["LANGFUSE_URL"]),
publicKey: String(process.env["LANGFUSE_PK"]),
secretKey: String(process.env["LANGFUSE_SK"]),
baseUrl: String(process.env["LF_HOST"]),
publicKey: String(process.env["LF_PUBLIC_KEY"]),
secretKey: String(process.env["LF_SECRET_KEY"]),
});

const trace = langfuse.trace({ userId: "user-id" });
Expand Down
10 changes: 1 addition & 9 deletions langfuse-core/openapi-spec/openapi-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ info:
paths:
/api/public/scores:
post:
description: Add a score to the database
description: Add a score to the database, upserts on id
operationId: score_create
tags:
- Score
Expand Down Expand Up @@ -59,8 +59,6 @@ components:
type: string
traceId:
type: string
traceIdType:
$ref: "#/components/schemas/TraceIdType"
name:
type: string
value:
Expand Down Expand Up @@ -100,12 +98,6 @@ components:
- name
- value
- timestamp
TraceIdType:
title: TraceIdType
type: string
enum:
- LANGFUSE
- EXTERNAL
securitySchemes:
BearerAuth:
type: http
Expand Down
Loading
Loading