Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

[Fix]: typescript compile error which throws error in user's application (#603)

Aman Agarwal727edee99916
diff --git a/sdk/typescript/package-lock.json b/sdk/typescript/package-lock.json
index dd000f77..8f9dbe44 100644
--- a/sdk/typescript/package-lock.json
+++ b/sdk/typescript/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "openlit",
- "version": "1.3.1",
+ "version": "1.4.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "openlit",
- "version": "1.3.1",
+ "version": "1.4.0",
"license": "ISC",
"dependencies": {
"@anthropic-ai/sdk": "^0.25.0",
diff --git a/sdk/typescript/package.json b/sdk/typescript/package.json
index 4ad45da5..8117b383 100644
--- a/sdk/typescript/package.json
+++ b/sdk/typescript/package.json
@@ -1,6 +1,6 @@
{
"name": "openlit",
- "version": "1.3.1",
+ "version": "1.4.0",
"homepage": "https://github.com/openlit/openlit#readme",
"bugs": {
"url": "https://github.com/openlit/openlit/issues",
@@ -10,8 +10,19 @@
"type": "git",
"url": "https://github.com/openlit/openlit"
},
+ "scripts": {
+ "build": "tsc --build",
+ "postinstall": "npm run build"
+ },
+ "files": [
+ "dist",
+ "README.md",
+ "LICENSE",
+ "package.json"
+ ],
"description": "OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications, facilitating the integration of observability into your GenAI-driven projects",
- "main": "src/index.ts",
+ "main": "dist/index.js",
+ "types": "dist/index.d.ts",
"keywords": [
"OpenTelemetry",
"otel",
diff --git a/sdk/typescript/src/config.ts b/sdk/typescript/src/config.ts
index e69bd7d1..8a8f00b5 100644
--- a/sdk/typescript/src/config.ts
+++ b/sdk/typescript/src/config.ts
@@ -1,4 +1,3 @@
-import { Tracer } from '@opentelemetry/api';
import OpenLitHelper from './helpers';
import { OpenlitConfigInterface, PricingObject } from './types';
diff --git a/sdk/typescript/src/features/prompt-hub.ts b/sdk/typescript/src/features/prompt-hub.ts
index 8c1b084d..6d2cb5ad 100644
--- a/sdk/typescript/src/features/prompt-hub.ts
+++ b/sdk/typescript/src/features/prompt-hub.ts
@@ -37,7 +37,7 @@ export default class PromptHub {
Authorization: `Bearer ${apiKey}`,
},
})
- .then(async (response) => {
+ .then(async (response: any) => {
if (!response.ok) {
return {
err: `Openlit Error : HTTP error! Status: ${response.status}`,
diff --git a/sdk/typescript/src/features/vault.ts b/sdk/typescript/src/features/vault.ts
index fac52e83..497a5aef 100644
--- a/sdk/typescript/src/features/vault.ts
+++ b/sdk/typescript/src/features/vault.ts
@@ -25,7 +25,7 @@ export default class Vault {
Authorization: `Bearer ${apiKey}`,
},
})
- .then(async (response) => {
+ .then(async (response: any) => {
if (!response.ok) {
return {
err: `Openlit Error : HTTP error! Status: ${response.status}`,
diff --git a/sdk/typescript/src/instrumentation/anthropic/wrapper.ts b/sdk/typescript/src/instrumentation/anthropic/wrapper.ts
index bd107f10..18e9275c 100644
--- a/sdk/typescript/src/instrumentation/anthropic/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/anthropic/wrapper.ts
@@ -17,7 +17,7 @@ export default class AnthropicWrapper extends BaseWrapper {
.with(trace.setSpan(context.active(), span), async () => {
return originalMethod.apply(this, args);
})
- .then((response) => {
+ .then((response: any) => {
if (!!stream) {
return OpenLitHelper.createStreamProxy(
response,
diff --git a/sdk/typescript/src/instrumentation/cohere/wrapper.ts b/sdk/typescript/src/instrumentation/cohere/wrapper.ts
index 61e1eb69..7842a3a7 100644
--- a/sdk/typescript/src/instrumentation/cohere/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/cohere/wrapper.ts
@@ -84,7 +84,7 @@ export default class CohereWrapper extends BaseWrapper {
.with(trace.setSpan(context.active(), span), async () => {
return originalMethod.apply(this, args);
})
- .then((response) => {
+ .then((response: any) => {
return CohereWrapper._chat({ args, genAIEndpoint, response, span });
})
.catch((e: any) => {
@@ -104,7 +104,7 @@ export default class CohereWrapper extends BaseWrapper {
.with(trace.setSpan(context.active(), span), async () => {
return originalMethod.apply(this, args);
})
- .then((response) => {
+ .then((response: any) => {
return OpenLitHelper.createStreamProxy(
response,
CohereWrapper._chatGenerator({
diff --git a/sdk/typescript/src/instrumentation/ollama/wrapper.ts b/sdk/typescript/src/instrumentation/ollama/wrapper.ts
index f92568a9..879a4d61 100644
--- a/sdk/typescript/src/instrumentation/ollama/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/ollama/wrapper.ts
@@ -35,7 +35,7 @@ export default class OllamaWrapper {
.with(trace.setSpan(context.active(), span), async () => {
return originalMethod.apply(this, args);
})
- .then((response) => {
+ .then((response: any) => {
if (!!stream) {
return OpenLitHelper.createStreamProxy(
response,
diff --git a/sdk/typescript/src/instrumentation/openai/wrapper.ts b/sdk/typescript/src/instrumentation/openai/wrapper.ts
index e1d6a4f8..fa6d5b77 100644
--- a/sdk/typescript/src/instrumentation/openai/wrapper.ts
+++ b/sdk/typescript/src/instrumentation/openai/wrapper.ts
@@ -15,7 +15,7 @@ export default class OpenAIWrapper extends BaseWrapper {
.with(trace.setSpan(context.active(), span), async () => {
return originalMethod.apply(this, args);
})
- .then((response) => {
+ .then((response: any) => {
const { stream = false } = args[0];
if (!!stream) {
diff --git a/sdk/typescript/src/prompt-hub.ts b/sdk/typescript/src/prompt-hub.ts
index 8ce05a1d..f42ba106 100644
--- a/sdk/typescript/src/prompt-hub.ts
+++ b/sdk/typescript/src/prompt-hub.ts
@@ -37,7 +37,7 @@ export default class PromptHub {
Authorization: `Bearer ${apiKey}`,
},
})
- .then(async (response) => {
+ .then(async (response: any) => {
if (!response.ok) {
return {
err: `Openlit Error : HTTP error! Status: ${response.status}`,
diff --git a/sdk/typescript/tsconfig.json b/sdk/typescript/tsconfig.json
index 1d1330cb..8af3fc88 100644
--- a/sdk/typescript/tsconfig.json
+++ b/sdk/typescript/tsconfig.json
@@ -1,15 +1,22 @@
{
"compilerOptions": {
- "target": "es2016",
- "module": "commonjs",
- "resolveJsonModule": true,
- "outDir": "./dist",
- "esModuleInterop": true,
- "forceConsistentCasingInFileNames": true,
- "paths": {
- "@/*": ["./src/*"]
- },
- "strict": true,
- "skipLibCheck": true
- }
+ "target": "ES2020",
+ "module": "CommonJS",
+ "outDir": "./dist",
+ "strict": true,
+ "esModuleInterop": true,
+ "declaration": true,
+ "skipLibCheck": true,
+ "sourceMap": true,
+ "forceConsistentCasingInFileNames": true,
+ "baseUrl": "./src",
+ "rootDir": "./src",
+ },
+ "include": [
+ "src/**/*"
+ ],
+ "exclude": [
+ "node_modules",
+ "**/*.spec.ts"
+ ]
}