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

Add ollama and add more event types #65

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 9 additions & 3 deletions src/typescript/constants/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { PineConeFunctionNames, PineConeFunctions } from './pinecone'
import { QdrantFunctionNames, QdrantFunctions } from './qdrant'
import { WeaviateFunctionNames, WeaviateFunctions } from './weaviate'
import { TiktokenModel, TiktokenEncoding } from 'tiktoken'
import { OllamaFunctionNames, OllamaFunctions } from './ollama'

export const LLMSpanAttributeNames: Array<keyof typeof LLMSpanAttributesObj> = Object.keys(LLMSpanAttributesObj) as Array<keyof typeof LLMSpanAttributesObj>
export const DatabaseSpanAttributeNames: Array<keyof typeof DatabaseSpanAttributesObj> = Object.keys(DatabaseSpanAttributesObj) as Array<keyof typeof DatabaseSpanAttributesObj>
Expand All @@ -28,14 +29,17 @@ export const Vendors = {
CHROMADB: 'chromadb',
QDRANT: 'qdrant',
WEAVIATE: 'weaviate',
PG: 'pg'
PG: 'pg',
OLLAMA: 'ollama'
} as const

export enum Event {
STREAM_START = 'stream.start',
STREAM_OUTPUT = 'stream.output',
STREAM_END = 'stream.end',
RESPONSE = 'response',
GEN_AI_COMPLETION = 'gen_ai.content.completion',
GEN_AI_PROMPT = 'gen_ai.content.prompt',
}
export type Vendor = typeof Vendors[keyof typeof Vendors]

Expand All @@ -49,7 +53,8 @@ interface VendorInstrumentationFunctions {
chromadb: ChromadbFunctions[]
qdrant: QdrantFunctions[]
weaviate: WeaviateFunctions[]
pg: PgFunctions[]
pg: PgFunctions[],
ollama: OllamaFunctions[]
}


Expand All @@ -68,7 +73,8 @@ export const TracedFunctionsByVendor: VendorTracedFunctions = {
openai: OpenAIFunctionNames,
pinecone: PineConeFunctionNames,
qdrant: QdrantFunctionNames,
weaviate: WeaviateFunctionNames
weaviate: WeaviateFunctionNames,
ollama: OllamaFunctionNames
} as const

export const TIKTOKEN_MODEL_MAPPING: Record<TiktokenModel | string, TiktokenEncoding> = {
Expand Down
32 changes: 32 additions & 0 deletions src/typescript/constants/ollama.ts
Original file line number Diff line number Diff line change
@@ -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: {
METHOD: 'ollama.generate',
ENDPOINT: '/api/generate'
},
CHAT: {
METHOD: 'ollama.chat',
ENDPOINT: '/api/chat'
},
EMBEDDINGS: {
METHOD: 'ollama.embeddings',
ENDPOINT: ' /api/embeddings'
}
} as const
export type OllamaFunctions = typeof APIS[keyof typeof APIS]['METHOD']
export const OllamaFunctionNames: OllamaFunctions[] = Object.values(APIS).map((api) => api.METHOD)
2 changes: 2 additions & 0 deletions src/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ollamaAPIS } from "./constants/ollama";
import { queryTypeToFunctionToProps } from "./constants/weaviate";
import { TIKTOKEN_MODEL_MAPPING } from "./constants/common";

Expand Down Expand Up @@ -45,6 +46,7 @@ const APIS = {
openai: OpenAIAPIs,
pinecone: PineConeAPIS,
qdrant: QdrantAPIS,
ollama: ollamaAPIS
}
export {
LLMSpanAttributeNames,
Expand Down
6 changes: 3 additions & 3 deletions src/typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@langtrase/trace-attributes",
"version": "6.0.1",
"version": "6.0.2",
"description": "LangTrace - Trace Attributes",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
Loading