Skip to content

Commit

Permalink
Merge branch 'master' into feat/google-ai
Browse files Browse the repository at this point in the history
  • Loading branch information
soumik12345 authored Aug 6, 2024
2 parents 21ef120 + 144d27c commit b91297d
Show file tree
Hide file tree
Showing 100 changed files with 1,790 additions and 639 deletions.
2 changes: 1 addition & 1 deletion genpydocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def doc_module(module):


def main():
from weave import api
from weave import query_api as api

api_docs = doc_module(api)
with open("docs/docs/api-reference/python/weave.md", "w") as f:
Expand Down
4 changes: 4 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ disallow_untyped_calls = False
disallow_untyped_defs = False
disallow_untyped_calls = False

[mypy-weave.query_api]
disallow_untyped_defs = False
disallow_untyped_calls = False

[mypy-weave.legacy.panel]
disallow_untyped_defs = False
disallow_untyped_calls = False
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ known-third-party = ["wandb"]
line-length = 88
show-fixes = true
exclude = [
"weave/api.py",
"weave/query_api.py",
"weave/__init__.py",
"weave/legacy/**/*.py",
"examples",
Expand Down
6 changes: 5 additions & 1 deletion requirements.dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ types-setuptools>=65.7.0.3
pre-commit>=3.3.3
black==22.3.0
types-aiofiles>=22.1.0.6
types-all>=1.0.0
# Our mypy step in pre-commit depends on types-all. types-all depends on types-pkg-resources.
# All of the versions of types-pkg-resources were yanked: https://pypi.org/project/types-pkg-resources/#history
# Hardpinning 1.0.0 for now.
types-all==1.0.0
types-pkg-resources==0.1.3
typing_extensions>=4.4.0
build>=0.10.0
twine>=4.0.0
Expand Down
3 changes: 3 additions & 0 deletions requirements.test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ pysqlite3-binary==0.5.3 # LangChain
cohere>=5.5.8 # Cohere
groq>=0.9.0 # Groq
google-generativeai==0.7.2 # Google Generative AI

# Used for Integration Tests
semver
1 change: 1 addition & 0 deletions wb_schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ type Artifact {
currentManifest: ArtifactManifest
historyStep: Int64
ttlDurationSeconds: Int64!
tags: [Tag!]!
}

type ArtifactManifestConnection {
Expand Down
96 changes: 2 additions & 94 deletions weave-js/src/util/llmTokenCosts.ts
Original file line number Diff line number Diff line change
@@ -1,102 +1,10 @@
import {LLM_TOKEN_COSTS} from './tokenCosts';

export type Model = keyof typeof LLM_TOKEN_COSTS;
export const isValidLLMModel = (model: string): model is Model => {
return Object.keys(LLM_TOKEN_COSTS).includes(model);
};

export const LLM_TOKEN_COSTS = {
// Default pricing if model has no specific pricing
default: {
input: 0.005,
output: 0.015,
},

// OPENAI pricing for 1k LLM tokens taken on June 4, 2024
// https://openai.com/api/pricing/
'gpt-4o': {
input: 0.005,
output: 0.015,
},
'gpt-4o-2024-05-13': {
input: 0.005,
output: 0.015,
},
'gpt-4-turbo': {
input: 0.01,
output: 0.03,
},
'gpt-4-turbo-2024-04-09': {
input: 0.01,
output: 0.03,
},
'gpt-4': {
input: 0.03,
output: 0.06,
},
'gpt-4-32k': {
input: 0.06,
output: 0.12,
},
'gpt-4-0125-preview': {
input: 0.01,
output: 0.03,
},
'gpt-4-1106-preview': {
input: 0.01,
output: 0.03,
},
'gpt-4-vision-preview': {
input: 0.01,
output: 0.03,
},
'gpt-3.5-turbo-1106': {
input: 0.001,
output: 0.002,
},
'gpt-3.5-turbo-0613': {
input: 0.0015,
output: 0.002,
},
'gpt-3.5-turbo-16k-0613': {
input: 0.003,
output: 0.004,
},
'gpt-3.5-turbo-0301': {
input: 0.0015,
output: 0.002,
},
'gpt-3.5-turbo-0125': {
input: 0.0005,
output: 0.0015,
},
'gpt-3.5-turbo-instruct': {
input: 0.0015,
output: 0.002,
},
'davinci-002': {
input: 0.002,
output: 0.002,
},
'babbage-002': {
input: 0.0004,
output: 0.0004,
},

// Anthropic pricing for 1k LLM tokens taken on June 4, 2024
// https://docs.anthropic.com/en/docs/models-overview
'claude-3-opus-20240229': {
input: 0.015,
output: 0.075,
},
'claude-3-sonnet-20240229': {
input: 0.003,
output: 0.015,
},
'claude-3-haiku-20240307': {
input: 0.00025,
output: 0.00125,
},
};

export const getLLMTokenCost = (
model: string,
type: 'input' | 'output',
Expand Down
Loading

0 comments on commit b91297d

Please sign in to comment.