chore(telemetry): disable compare test (#228)
This commit is contained in:
1 parent
493a088844
commit
7e315ddc7a
4 files changed
+152
-154
No files matched your search
@@ -2,8 +2,8 @@ import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'
|
||||
|
||||
import { InMemorySpanExporter, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base'
|
||||
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'
|
||||
import { generateText as aiGenerateText, tool as aiTool, stepCountIs } from 'ai'
|
||||
import { ollama } from 'ollama-ai-provider-v2'
|
||||
// import { generateText as aiGenerateText, tool as aiTool, stepCountIs } from 'ai'
|
||||
// import { ollama } from 'ollama-ai-provider-v2'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { tool } from 'xsai'
|
||||
import { z } from 'zod/v4'
|
||||
@@ -55,56 +55,56 @@ describe.sequential('generateText with tools', () => {
|
||||
expect(spans).toMatchSnapshot()
|
||||
}, 120_000)
|
||||
|
||||
it('basic/ai', async () => {
|
||||
const add = aiTool({
|
||||
description: 'Adds two numbers',
|
||||
// @ts-expect-error wrong types
|
||||
execute: ({ a, b }) => (Number.parseInt(a) + Number.parseInt(b)).toString(),
|
||||
// @ts-expect-error wrong types
|
||||
inputSchema: z.object({
|
||||
a: z.string()
|
||||
.describe('First number'),
|
||||
b: z.string()
|
||||
.describe('Second number'),
|
||||
}),
|
||||
name: 'add',
|
||||
})
|
||||
// it('basic/ai', async () => {
|
||||
// const add = aiTool({
|
||||
// description: 'Adds two numbers',
|
||||
// // @ts-expect-error wrong types
|
||||
// execute: ({ a, b }) => (Number.parseInt(a) + Number.parseInt(b)).toString(),
|
||||
// // @ts-expect-error wrong types
|
||||
// inputSchema: z.object({
|
||||
// a: z.string()
|
||||
// .describe('First number'),
|
||||
// b: z.string()
|
||||
// .describe('Second number'),
|
||||
// }),
|
||||
// name: 'add',
|
||||
// })
|
||||
|
||||
const { text } = await aiGenerateText({
|
||||
experimental_telemetry: { isEnabled: true },
|
||||
model: ollama('qwen3:0.6b'),
|
||||
prompt: 'How many times does 114514 plus 1919810 equal? Please try to call the `add` tool to solve the problem.',
|
||||
seed: 114514,
|
||||
stopWhen: stepCountIs(5),
|
||||
tools: { add },
|
||||
})
|
||||
// const { text } = await aiGenerateText({
|
||||
// experimental_telemetry: { isEnabled: true },
|
||||
// model: ollama('qwen3:0.6b'),
|
||||
// prompt: 'How many times does 114514 plus 1919810 equal? Please try to call the `add` tool to solve the problem.',
|
||||
// seed: 114514,
|
||||
// stopWhen: stepCountIs(5),
|
||||
// tools: { add },
|
||||
// })
|
||||
|
||||
const spans = memoryExporter.getFinishedSpans().slice(4).map(getAttributes)
|
||||
// const spans = memoryExporter.getFinishedSpans().slice(4).map(getAttributes)
|
||||
|
||||
expect(text).toMatchSnapshot()
|
||||
expect(spans).toMatchSnapshot()
|
||||
}, 120_000)
|
||||
// expect(text).toMatchSnapshot()
|
||||
// expect(spans).toMatchSnapshot()
|
||||
// }, 120_000)
|
||||
|
||||
it('basic/compare', () => {
|
||||
const extractAttributeKeys = (span: ReadableSpan) => Object.keys(span.attributes)
|
||||
// eslint-disable-next-line sonarjs/no-nested-functions
|
||||
.filter(key => ['ai.settings'].every(prefix => !key.startsWith(prefix)))
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
// it('basic/compare', () => {
|
||||
// const extractAttributeKeys = (span: ReadableSpan) => Object.keys(span.attributes)
|
||||
// // eslint-disable-next-line sonarjs/no-nested-functions
|
||||
// .filter(key => ['ai.settings'].every(prefix => !key.startsWith(prefix)))
|
||||
// .sort((a, b) => a.localeCompare(b))
|
||||
|
||||
const spans = memoryExporter.getFinishedSpans()
|
||||
const xsaiSpans = spans.slice(0, 4)
|
||||
const aiSpans = spans.slice(4)
|
||||
// const spans = memoryExporter.getFinishedSpans()
|
||||
// const xsaiSpans = spans.slice(0, 4)
|
||||
// const aiSpans = spans.slice(4)
|
||||
|
||||
const xsaiIds = xsaiSpans.map(span => span.attributes['ai.operationId'])
|
||||
const aiIds = aiSpans.map(span => span.attributes['ai.operationId'])
|
||||
// const xsaiIds = xsaiSpans.map(span => span.attributes['ai.operationId'])
|
||||
// const aiIds = aiSpans.map(span => span.attributes['ai.operationId'])
|
||||
|
||||
expect(xsaiIds).toStrictEqual(aiIds)
|
||||
// expect(xsaiIds).toStrictEqual(aiIds)
|
||||
|
||||
const xsaiKeys = xsaiSpans.map(extractAttributeKeys)
|
||||
const aiKeys = aiSpans.map(extractAttributeKeys)
|
||||
// const xsaiKeys = xsaiSpans.map(extractAttributeKeys)
|
||||
// const aiKeys = aiSpans.map(extractAttributeKeys)
|
||||
|
||||
xsaiKeys.forEach((attributes, i) => {
|
||||
expect(attributes).toStrictEqual(aiKeys[i])
|
||||
})
|
||||
})
|
||||
// xsaiKeys.forEach((attributes, i) => {
|
||||
// expect(attributes).toStrictEqual(aiKeys[i])
|
||||
// })
|
||||
// })
|
||||
})
|
||||
@@ -2,8 +2,8 @@ import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'
|
||||
|
||||
import { InMemorySpanExporter, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base'
|
||||
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'
|
||||
import { generateText as aiGenerateText } from 'ai'
|
||||
import { ollama } from 'ollama-ai-provider-v2'
|
||||
// import { generateText as aiGenerateText } from 'ai'
|
||||
// import { ollama } from 'ollama-ai-provider-v2'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { generateText } from '../src'
|
||||
@@ -46,38 +46,38 @@ describe.sequential('generateText', () => {
|
||||
expect(spans).toMatchSnapshot()
|
||||
}, 120_000)
|
||||
|
||||
it('basic/ai', async () => {
|
||||
const { text } = await aiGenerateText({
|
||||
experimental_telemetry: {
|
||||
isEnabled: true,
|
||||
metadata: {
|
||||
agentId: 'weather-assistant',
|
||||
instructions: 'You are a helpful weather assistant',
|
||||
},
|
||||
},
|
||||
model: ollama('qwen3:0.6b'),
|
||||
prompt: 'Why is the sky blue?',
|
||||
seed: 114514,
|
||||
})
|
||||
// it('basic/ai', async () => {
|
||||
// const { text } = await aiGenerateText({
|
||||
// experimental_telemetry: {
|
||||
// isEnabled: true,
|
||||
// metadata: {
|
||||
// agentId: 'weather-assistant',
|
||||
// instructions: 'You are a helpful weather assistant',
|
||||
// },
|
||||
// },
|
||||
// model: ollama('qwen3:0.6b'),
|
||||
// prompt: 'Why is the sky blue?',
|
||||
// seed: 114514,
|
||||
// })
|
||||
|
||||
const spans = memoryExporter.getFinishedSpans().slice(2).map(getAttributes)
|
||||
// const spans = memoryExporter.getFinishedSpans().slice(2).map(getAttributes)
|
||||
|
||||
expect(text).toMatchSnapshot()
|
||||
expect(spans).toMatchSnapshot()
|
||||
}, 120_000)
|
||||
// expect(text).toMatchSnapshot()
|
||||
// expect(spans).toMatchSnapshot()
|
||||
// }, 120_000)
|
||||
|
||||
it('basic/compare', () => {
|
||||
const extractAttributeKeys = (span: ReadableSpan) => Object.keys(span.attributes)
|
||||
// eslint-disable-next-line sonarjs/no-nested-functions
|
||||
.filter(key => ['ai.settings'].every(prefix => !key.startsWith(prefix)))
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
// it('basic/compare', () => {
|
||||
// const extractAttributeKeys = (span: ReadableSpan) => Object.keys(span.attributes)
|
||||
// // eslint-disable-next-line sonarjs/no-nested-functions
|
||||
// .filter(key => ['ai.settings'].every(prefix => !key.startsWith(prefix)))
|
||||
// .sort((a, b) => a.localeCompare(b))
|
||||
|
||||
const spans = memoryExporter.getFinishedSpans()
|
||||
const xsai = spans.slice(0, 2).map(extractAttributeKeys)
|
||||
const ai = spans.slice(2).map(extractAttributeKeys)
|
||||
// const spans = memoryExporter.getFinishedSpans()
|
||||
// const xsai = spans.slice(0, 2).map(extractAttributeKeys)
|
||||
// const ai = spans.slice(2).map(extractAttributeKeys)
|
||||
|
||||
xsai.forEach((attributes, i) => {
|
||||
expect(attributes).toStrictEqual(ai[i])
|
||||
})
|
||||
})
|
||||
// xsai.forEach((attributes, i) => {
|
||||
// expect(attributes).toStrictEqual(ai[i])
|
||||
// })
|
||||
// })
|
||||
})
|
||||
@@ -3,8 +3,8 @@ import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'
|
||||
|
||||
import { InMemorySpanExporter, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base'
|
||||
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'
|
||||
import { streamText as aiStreamText, tool as aiTool, stepCountIs } from 'ai'
|
||||
import { ollama } from 'ollama-ai-provider-v2'
|
||||
// import { streamText as aiStreamText, tool as aiTool, stepCountIs } from 'ai'
|
||||
// import { ollama } from 'ollama-ai-provider-v2'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { tool } from 'xsai'
|
||||
import { z } from 'zod/v4'
|
||||
@@ -83,57 +83,55 @@ describe.sequential('streamText with tools', () => {
|
||||
}
|
||||
}, 120_000)
|
||||
|
||||
it('basic/ai', async () => {
|
||||
const add = aiTool({
|
||||
description: 'Adds two numbers',
|
||||
// @ts-expect-error wrong types
|
||||
execute: ({ a, b }) => (Number.parseInt(a) + Number.parseInt(b)).toString(),
|
||||
// @ts-expect-error wrong types
|
||||
inputSchema: z.object({
|
||||
a: z.string()
|
||||
.describe('First number'),
|
||||
b: z.string()
|
||||
.describe('Second number'),
|
||||
}),
|
||||
name: 'add',
|
||||
})
|
||||
// it('basic/ai', async () => {
|
||||
// const add = aiTool({
|
||||
// description: 'Adds two numbers',
|
||||
// execute: ({ a, b }) => (Number.parseInt(a) + Number.parseInt(b)).toString(),
|
||||
// inputSchema: z.object({
|
||||
// a: z.string()
|
||||
// .describe('First number'),
|
||||
// b: z.string()
|
||||
// .describe('Second number'),
|
||||
// }),
|
||||
// name: 'add',
|
||||
// })
|
||||
|
||||
const { text } = aiStreamText({
|
||||
experimental_telemetry: { isEnabled: true },
|
||||
model: ollama('qwen3:0.6b'),
|
||||
prompt: 'How many times does 114514 plus 1919810 equal? Please try to call the `add` tool to solve the problem.',
|
||||
seed: 114514,
|
||||
stopWhen: stepCountIs(5),
|
||||
tools: { add },
|
||||
})
|
||||
// const { text } = aiStreamText({
|
||||
// experimental_telemetry: { isEnabled: true },
|
||||
// model: ollama('qwen3:0.6b'),
|
||||
// prompt: 'How many times does 114514 plus 1919810 equal? Please try to call the `add` tool to solve the problem.',
|
||||
// seed: 114514,
|
||||
// stopWhen: stepCountIs(5),
|
||||
// tools: { add },
|
||||
// })
|
||||
|
||||
const fullText = await text
|
||||
const spans = memoryExporter.getFinishedSpans().slice(4).map(getAttributes)
|
||||
// const fullText = await text
|
||||
// const spans = memoryExporter.getFinishedSpans().slice(4).map(getAttributes)
|
||||
|
||||
expect(fullText).toMatchSnapshot()
|
||||
expect(spans).toMatchSnapshot()
|
||||
}, 120_000)
|
||||
// expect(fullText).toMatchSnapshot()
|
||||
// expect(spans).toMatchSnapshot()
|
||||
// }, 120_000)
|
||||
|
||||
it('basic/compare', () => {
|
||||
const extractAttributeKeys = (span: ReadableSpan) => Object.keys(span.attributes)
|
||||
// eslint-disable-next-line sonarjs/no-nested-functions
|
||||
.filter(key => ['ai.settings'].every(prefix => !key.startsWith(prefix)))
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
// it('basic/compare', () => {
|
||||
// const extractAttributeKeys = (span: ReadableSpan) => Object.keys(span.attributes)
|
||||
// // eslint-disable-next-line sonarjs/no-nested-functions
|
||||
// .filter(key => ['ai.settings'].every(prefix => !key.startsWith(prefix)))
|
||||
// .sort((a, b) => a.localeCompare(b))
|
||||
|
||||
const spans = memoryExporter.getFinishedSpans()
|
||||
const xsaiSpans = spans.slice(0, 4)
|
||||
const aiSpans = spans.slice(4)
|
||||
// const spans = memoryExporter.getFinishedSpans()
|
||||
// const xsaiSpans = spans.slice(0, 4)
|
||||
// const aiSpans = spans.slice(4)
|
||||
|
||||
const xsaiIds = xsaiSpans.map(span => span.attributes['ai.operationId'])
|
||||
const aiIds = aiSpans.map(span => span.attributes['ai.operationId'])
|
||||
// const xsaiIds = xsaiSpans.map(span => span.attributes['ai.operationId'])
|
||||
// const aiIds = aiSpans.map(span => span.attributes['ai.operationId'])
|
||||
|
||||
expect(xsaiIds).toStrictEqual(aiIds)
|
||||
// expect(xsaiIds).toStrictEqual(aiIds)
|
||||
|
||||
const xsaiKeys = xsaiSpans.map(extractAttributeKeys)
|
||||
const aiKeys = aiSpans.map(extractAttributeKeys)
|
||||
// const xsaiKeys = xsaiSpans.map(extractAttributeKeys)
|
||||
// const aiKeys = aiSpans.map(extractAttributeKeys)
|
||||
|
||||
xsaiKeys.forEach((attributes, i) => {
|
||||
expect(attributes).toStrictEqual(aiKeys[i])
|
||||
})
|
||||
})
|
||||
// xsaiKeys.forEach((attributes, i) => {
|
||||
// expect(attributes).toStrictEqual(aiKeys[i])
|
||||
// })
|
||||
// })
|
||||
})
|
||||
@@ -3,8 +3,8 @@ import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'
|
||||
|
||||
import { InMemorySpanExporter, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base'
|
||||
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'
|
||||
import { streamText as aiStreamText } from 'ai'
|
||||
import { ollama } from 'ollama-ai-provider-v2'
|
||||
// import { streamText as aiStreamText } from 'ai'
|
||||
// import { ollama } from 'ollama-ai-provider-v2'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { streamText } from '../src'
|
||||
@@ -71,39 +71,39 @@ describe.sequential('streamText', () => {
|
||||
}
|
||||
}, 120_000)
|
||||
|
||||
it('basic/ai', async () => {
|
||||
const { text } = aiStreamText({
|
||||
experimental_telemetry: {
|
||||
isEnabled: true,
|
||||
metadata: {
|
||||
agentId: 'weather-assistant',
|
||||
instructions: 'You are a helpful weather assistant',
|
||||
},
|
||||
},
|
||||
model: ollama('qwen3:0.6b'),
|
||||
prompt: 'Why is the sky blue?',
|
||||
seed: 114514,
|
||||
})
|
||||
// it('basic/ai', async () => {
|
||||
// const { text } = aiStreamText({
|
||||
// experimental_telemetry: {
|
||||
// isEnabled: true,
|
||||
// metadata: {
|
||||
// agentId: 'weather-assistant',
|
||||
// instructions: 'You are a helpful weather assistant',
|
||||
// },
|
||||
// },
|
||||
// model: ollama('qwen3:0.6b'),
|
||||
// prompt: 'Why is the sky blue?',
|
||||
// seed: 114514,
|
||||
// })
|
||||
|
||||
const fullText = await text
|
||||
const spans = memoryExporter.getFinishedSpans().slice(2).map(getAttributes)
|
||||
// const fullText = await text
|
||||
// const spans = memoryExporter.getFinishedSpans().slice(2).map(getAttributes)
|
||||
|
||||
expect(fullText).toMatchSnapshot()
|
||||
expect(spans).toMatchSnapshot()
|
||||
}, 120_000)
|
||||
// expect(fullText).toMatchSnapshot()
|
||||
// expect(spans).toMatchSnapshot()
|
||||
// }, 120_000)
|
||||
|
||||
it('basic/compare', () => {
|
||||
const extractAttributeKeys = (span: ReadableSpan) => Object.keys(span.attributes)
|
||||
// eslint-disable-next-line sonarjs/no-nested-functions
|
||||
.filter(key => ['ai.settings'].every(prefix => !key.startsWith(prefix)))
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
// it('basic/compare', () => {
|
||||
// const extractAttributeKeys = (span: ReadableSpan) => Object.keys(span.attributes)
|
||||
// // eslint-disable-next-line sonarjs/no-nested-functions
|
||||
// .filter(key => ['ai.settings'].every(prefix => !key.startsWith(prefix)))
|
||||
// .sort((a, b) => a.localeCompare(b))
|
||||
|
||||
const spans = memoryExporter.getFinishedSpans()
|
||||
const xsai = spans.slice(0, 2).map(extractAttributeKeys)
|
||||
const ai = spans.slice(2).map(extractAttributeKeys)
|
||||
// const spans = memoryExporter.getFinishedSpans()
|
||||
// const xsai = spans.slice(0, 2).map(extractAttributeKeys)
|
||||
// const ai = spans.slice(2).map(extractAttributeKeys)
|
||||
|
||||
xsai.forEach((attributes, i) => {
|
||||
expect(attributes).toStrictEqual(ai[i])
|
||||
})
|
||||
})
|
||||
// xsai.forEach((attributes, i) => {
|
||||
// expect(attributes).toStrictEqual(ai[i])
|
||||
// })
|
||||
// })
|
||||
})
|
||||
Reference in new issue
Block a user