diff --git a/src/typescript/constants/ai.ts b/src/typescript/constants/ai.ts new file mode 100644 index 0000000..53391fd --- /dev/null +++ b/src/typescript/constants/ai.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Scale3 Labs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const APIS = { + GENERATE_TEXT: { + METHOD: 'ai.generateText', + }, + STREAM_TEXT: { + METHOD: 'ai.streamText', + }, + EMBED: { + METHOD: 'ai.embed', + }, + EMBED_MANY: { + METHOD: 'ai.embedMany', + } +} as const +export type VercelAIFunctions = typeof APIS[keyof typeof APIS]['METHOD'] +export const VercelAIFunctionNames: VercelAIFunctions[] = Object.values(APIS).map((api) => api.METHOD) diff --git a/src/typescript/constants/common.ts b/src/typescript/constants/common.ts index b3837ee..1fe1eaf 100644 --- a/src/typescript/constants/common.ts +++ b/src/typescript/constants/common.ts @@ -13,6 +13,7 @@ import { QdrantFunctionNames, QdrantFunctions } from './qdrant' import { WeaviateFunctionNames, WeaviateFunctions } from './weaviate' import { TiktokenModel, TiktokenEncoding } from 'tiktoken' import { OllamaFunctionNames, OllamaFunctions } from './ollama' +import { VercelAIFunctionNames, VercelAIFunctions } from './ai' export const LLMSpanAttributeNames: Array = Object.keys(LLMSpanAttributesObj) as Array export const DatabaseSpanAttributeNames: Array = Object.keys(DatabaseSpanAttributesObj) as Array @@ -30,6 +31,7 @@ export const Vendors = { QDRANT: 'qdrant', WEAVIATE: 'weaviate', PG: 'pg', + VERCEL: 'ai', OLLAMA: 'ollama' } as const @@ -55,6 +57,7 @@ interface VendorInstrumentationFunctions { qdrant: QdrantFunctions[] weaviate: WeaviateFunctions[] pg: PgFunctions[], + ai: VercelAIFunctions[], ollama: OllamaFunctions[] } @@ -75,6 +78,7 @@ export const TracedFunctionsByVendor: VendorTracedFunctions = { pinecone: PineConeFunctionNames, qdrant: QdrantFunctionNames, weaviate: WeaviateFunctionNames, + ai: VercelAIFunctionNames, ollama: OllamaFunctionNames } as const diff --git a/src/typescript/index.ts b/src/typescript/index.ts index 1a04b1e..bcdceb9 100644 --- a/src/typescript/index.ts +++ b/src/typescript/index.ts @@ -11,6 +11,7 @@ import { APIS as LlamaIndexAPIS } from "./constants/llamaindex"; import { APIS as OpenAIAPIs } from "./constants/openai"; import { APIS as PineConeAPIS } from "./constants/pinecone"; import { APIS as QdrantAPIS } from "./constants/qdrant"; +import { APIS as vercelAIAPIS } from "./constants/ai"; import { APIS as ollamaAPIS } from "./constants/ollama"; import { queryTypeToFunctionToProps } from "./constants/weaviate"; import { TIKTOKEN_MODEL_MAPPING } from "./constants/common"; @@ -46,6 +47,7 @@ const APIS = { openai: OpenAIAPIs, pinecone: PineConeAPIS, qdrant: QdrantAPIS, + ai: vercelAIAPIS, ollama: ollamaAPIS } export { diff --git a/src/typescript/package-lock.json b/src/typescript/package-lock.json index 6f0eccb..d59462f 100644 --- a/src/typescript/package-lock.json +++ b/src/typescript/package-lock.json @@ -1,12 +1,12 @@ { "name": "@langtrase/trace-attributes", - "version": "6.0.4", + "version": "6.0.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@langtrase/trace-attributes", - "version": "6.0.4", + "version": "6.0.6", "license": "MIT", "dependencies": { "json-schema-to-typescript": "^14.1.0", diff --git a/src/typescript/package.json b/src/typescript/package.json index 36a50d4..bb24627 100644 --- a/src/typescript/package.json +++ b/src/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@langtrase/trace-attributes", - "version": "6.0.5", + "version": "6.0.6", "description": "LangTrace - Trace Attributes", "main": "dist/index.js", "types": "dist/index.d.ts",