From 469c71b99d3b339adbe245ea165d79c6ffaf5251 Mon Sep 17 00:00:00 2001 From: Darshit Suratwala Date: Thu, 22 Aug 2024 12:44:52 +0530 Subject: [PATCH 1/2] feat: adding gemini ts support --- src/typescript/constants/common.ts | 4 ++++ src/typescript/constants/gemini.ts | 26 ++++++++++++++++++++++++++ src/typescript/index.ts | 4 +++- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/typescript/constants/gemini.ts diff --git a/src/typescript/constants/common.ts b/src/typescript/constants/common.ts index 316737c..8c83ae5 100644 --- a/src/typescript/constants/common.ts +++ b/src/typescript/constants/common.ts @@ -5,6 +5,7 @@ import { AnthropicFunctions, AnthropicFunctionNames } from './anthropic'; import { PgFunctionNames, PgFunctions } from './pg'; import { ChromadbFunctionNames, ChromadbFunctions } from './chroma'; import { CohereFunctionNames, CohereFunctions } from './cohere'; +import { GeminiFunctionNames, GeminiFunctions } from './gemini'; import { GroqFunctionNames, GroqFunctions } from './groq'; import { LlamaIndexFunctionNames, LlamaIndexFunctions } from './llamaindex'; import { OpenAIFunctionNames, OpenAIFunctions } from './openai'; @@ -27,6 +28,7 @@ export const Vendors = { OPENAI: 'openai', COHERE: 'cohere', ANTHROPIC: 'anthropic', + GEMINI: 'gemini', GROQ: 'groq', PINECONE: 'pinecone', LLAMAINDEX: 'llamaindex', @@ -53,6 +55,7 @@ interface VendorInstrumentationFunctions { openai: OpenAIFunctions[]; cohere: CohereFunctions[]; anthropic: AnthropicFunctions[]; + gemini: GeminiFunctions[]; groq: GroqFunctions[]; pinecone: PineConeFunctions[]; llamaindex: LlamaIndexFunctions[]; @@ -73,6 +76,7 @@ export const TracedFunctionsByVendor: VendorTracedFunctions = { pg: PgFunctionNames, chromadb: ChromadbFunctionNames, cohere: CohereFunctionNames, + gemini: GeminiFunctionNames, groq: GroqFunctionNames, llamaindex: LlamaIndexFunctionNames, openai: OpenAIFunctionNames, diff --git a/src/typescript/constants/gemini.ts b/src/typescript/constants/gemini.ts new file mode 100644 index 0000000..0052237 --- /dev/null +++ b/src/typescript/constants/gemini.ts @@ -0,0 +1,26 @@ +/* + * 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_CONTENT: { + METHOD: "gemini.GenerativeModel.generateContent", + }, + GENERATE_CONTENT_STREAM: { + METHOD: "gemini.GenerativeModel.generateContentStream", + }, +} as const; +export type GeminiFunctions = typeof APIS[keyof typeof APIS]['METHOD'] +export const GeminiFunctionNames: GeminiFunctions[] = Object.values(APIS).map((api) => api.METHOD) diff --git a/src/typescript/index.ts b/src/typescript/index.ts index bcdceb9..68e6050 100644 --- a/src/typescript/index.ts +++ b/src/typescript/index.ts @@ -6,6 +6,7 @@ import { APIS as AnthropicAPIS } from "./constants/anthropic"; import { APIS as PgAPIS } from "./constants/pg"; import { APIS as ChromadbAPIS } from "./constants/chroma"; import { APIS as CohereAPIS } from "./constants/cohere"; +import { APIS as GeminiAPIS } from "./constants/gemini"; import { APIS as GroqAPIS } from "./constants/groq"; import { APIS as LlamaIndexAPIS } from "./constants/llamaindex"; import { APIS as OpenAIAPIs } from "./constants/openai"; @@ -42,6 +43,7 @@ const APIS = { pg: PgAPIS, chromadb: ChromadbAPIS, cohere: CohereAPIS, + gemini: GeminiAPIS, groq: GroqAPIS, llamaindex: LlamaIndexAPIS, openai: OpenAIAPIs, @@ -64,4 +66,4 @@ export { APIS, TIKTOKEN_MODEL_MAPPING, queryTypeToFunctionToProps -} \ No newline at end of file +} From b201f3a595b4449762dff1f035a276c581bd3b50 Mon Sep 17 00:00:00 2001 From: Darshit Suratwala Date: Thu, 22 Aug 2024 12:46:28 +0530 Subject: [PATCH 2/2] chore: bump ts sdk version for gemini support --- src/typescript/package-lock.json | 4 ++-- src/typescript/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/typescript/package-lock.json b/src/typescript/package-lock.json index 8a85075..78c0128 100644 --- a/src/typescript/package-lock.json +++ b/src/typescript/package-lock.json @@ -1,12 +1,12 @@ { "name": "@langtrase/trace-attributes", - "version": "7.1.1", + "version": "7.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@langtrase/trace-attributes", - "version": "7.1.1", + "version": "7.2.0", "license": "MIT", "dependencies": { "js-tiktoken": "^1.0.14", diff --git a/src/typescript/package.json b/src/typescript/package.json index 08a4bf4..52d2021 100644 --- a/src/typescript/package.json +++ b/src/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@langtrase/trace-attributes", - "version": "7.1.2", + "version": "7.2.0", "description": "LangTrace - Trace Attributes", "main": "dist/index.js", "types": "dist/index.d.ts",