Skip to content

Commit

Permalink
fix cost test
Browse files Browse the repository at this point in the history
  • Loading branch information
chitalian committed Jan 22, 2025
1 parent 12ff79f commit 3ec47bd
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 2 deletions.
9 changes: 9 additions & 0 deletions bifrost/packages/cost/providers/mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { openAIProvider } from "./openai";
import { anthropicProvider } from "./anthropic";
import { costs as awsBedrockCosts } from "./awsBedrock";
import { costs as deepseekCosts } from "./deepseek";
import { costs as xCosts } from "./x";

const openAiPattern = /^https:\/\/api\.openai\.com/;
const anthropicPattern = /^https:\/\/api\.anthropic\.com/;
Expand Down Expand Up @@ -52,6 +53,8 @@ const firecrawl = /^https:\/\/api\.firecrawl\.dev/;
const awsBedrock = /^https:\/\/bedrock-runtime\.[a-z0-9-]+\.amazonaws\.com\/.*/;
// https://api.deepseek.com
const deepseek = /^https:\/\/api\.deepseek\.com/;
// https://api.x.ai
const x = /^https:\/\/api\.x\.ai/;

export const providersNames = [
"OPENAI",
Expand All @@ -78,6 +81,7 @@ export const providersNames = [
"FIRECRAWL",
"AWS",
"DEEPSEEK",
"X",
] as const;

export type ProviderName = (typeof providersNames)[number];
Expand Down Expand Up @@ -127,6 +131,11 @@ export const providers: {
pattern: cloudflareAiGatewayPattern,
provider: "CLOUDFLARE",
},
{
pattern: x,
provider: "X",
costs: xCosts,
},
{
pattern: twoYFV,
provider: "2YFV",
Expand Down
9 changes: 9 additions & 0 deletions costs/__tests__/ensureOnlyOne.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,15 @@ WHEN (request_response_rmt.model ILIKE 'o1-mini-2024-09-12') THEN 3000 * request
ELSE 0
END
)
WHEN (request_response_rmt.provider = 'X') THEN (
CASE
WHEN (request_response_rmt.model ILIKE 'grok-beta') THEN 5000 * request_response_rmt.prompt_tokens + 15000 * request_response_rmt.completion_tokens
WHEN (request_response_rmt.model ILIKE 'grok-vision-beta') THEN 5000 * request_response_rmt.prompt_tokens + 15000 * request_response_rmt.completion_tokens
WHEN (request_response_rmt.model ILIKE 'grok-2-1212') THEN 2000 * request_response_rmt.prompt_tokens + 10000 * request_response_rmt.completion_tokens
WHEN (request_response_rmt.model ILIKE 'grok-2-vision-1212') THEN 2000 * request_response_rmt.prompt_tokens + 10000 * request_response_rmt.completion_tokens
ELSE 0
END
)
WHEN (request_response_rmt.provider = 'TOGETHER') THEN (
CASE
WHEN (request_response_rmt.model ILIKE 'allenai/OLMo-7B-Instruct') THEN 200 * request_response_rmt.prompt_tokens + 200 * request_response_rmt.completion_tokens
Expand Down
9 changes: 9 additions & 0 deletions valhalla/jawn/src/packages/cost/providers/mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { openAIProvider } from "./openai";
import { anthropicProvider } from "./anthropic";
import { costs as awsBedrockCosts } from "./awsBedrock";
import { costs as deepseekCosts } from "./deepseek";
import { costs as xCosts } from "./x";

const openAiPattern = /^https:\/\/api\.openai\.com/;
const anthropicPattern = /^https:\/\/api\.anthropic\.com/;
Expand Down Expand Up @@ -52,6 +53,8 @@ const firecrawl = /^https:\/\/api\.firecrawl\.dev/;
const awsBedrock = /^https:\/\/bedrock-runtime\.[a-z0-9-]+\.amazonaws\.com\/.*/;
// https://api.deepseek.com
const deepseek = /^https:\/\/api\.deepseek\.com/;
// https://api.x.ai
const x = /^https:\/\/api\.x\.ai/;

export const providersNames = [
"OPENAI",
Expand All @@ -78,6 +81,7 @@ export const providersNames = [
"FIRECRAWL",
"AWS",
"DEEPSEEK",
"X",
] as const;

export type ProviderName = (typeof providersNames)[number];
Expand Down Expand Up @@ -127,6 +131,11 @@ export const providers: {
pattern: cloudflareAiGatewayPattern,
provider: "CLOUDFLARE",
},
{
pattern: x,
provider: "X",
costs: xCosts,
},
{
pattern: twoYFV,
provider: "2YFV",
Expand Down
2 changes: 1 addition & 1 deletion valhalla/jawn/src/tsoa-build/private/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ const models: TsoaRoute.Models = {
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
"ProviderName": {
"dataType": "refAlias",
"type": {"dataType":"union","subSchemas":[{"dataType":"enum","enums":["OPENAI"]},{"dataType":"enum","enums":["ANTHROPIC"]},{"dataType":"enum","enums":["AZURE"]},{"dataType":"enum","enums":["LOCAL"]},{"dataType":"enum","enums":["HELICONE"]},{"dataType":"enum","enums":["AMDBARTEK"]},{"dataType":"enum","enums":["ANYSCALE"]},{"dataType":"enum","enums":["CLOUDFLARE"]},{"dataType":"enum","enums":["2YFV"]},{"dataType":"enum","enums":["TOGETHER"]},{"dataType":"enum","enums":["LEMONFOX"]},{"dataType":"enum","enums":["FIREWORKS"]},{"dataType":"enum","enums":["PERPLEXITY"]},{"dataType":"enum","enums":["GOOGLE"]},{"dataType":"enum","enums":["OPENROUTER"]},{"dataType":"enum","enums":["WISDOMINANUTSHELL"]},{"dataType":"enum","enums":["GROQ"]},{"dataType":"enum","enums":["COHERE"]},{"dataType":"enum","enums":["MISTRAL"]},{"dataType":"enum","enums":["DEEPINFRA"]},{"dataType":"enum","enums":["QSTASH"]},{"dataType":"enum","enums":["FIRECRAWL"]},{"dataType":"enum","enums":["AWS"]},{"dataType":"enum","enums":["DEEPSEEK"]}],"validators":{}},
"type": {"dataType":"union","subSchemas":[{"dataType":"enum","enums":["OPENAI"]},{"dataType":"enum","enums":["ANTHROPIC"]},{"dataType":"enum","enums":["AZURE"]},{"dataType":"enum","enums":["LOCAL"]},{"dataType":"enum","enums":["HELICONE"]},{"dataType":"enum","enums":["AMDBARTEK"]},{"dataType":"enum","enums":["ANYSCALE"]},{"dataType":"enum","enums":["CLOUDFLARE"]},{"dataType":"enum","enums":["2YFV"]},{"dataType":"enum","enums":["TOGETHER"]},{"dataType":"enum","enums":["LEMONFOX"]},{"dataType":"enum","enums":["FIREWORKS"]},{"dataType":"enum","enums":["PERPLEXITY"]},{"dataType":"enum","enums":["GOOGLE"]},{"dataType":"enum","enums":["OPENROUTER"]},{"dataType":"enum","enums":["WISDOMINANUTSHELL"]},{"dataType":"enum","enums":["GROQ"]},{"dataType":"enum","enums":["COHERE"]},{"dataType":"enum","enums":["MISTRAL"]},{"dataType":"enum","enums":["DEEPINFRA"]},{"dataType":"enum","enums":["QSTASH"]},{"dataType":"enum","enums":["FIRECRAWL"]},{"dataType":"enum","enums":["AWS"]},{"dataType":"enum","enums":["DEEPSEEK"]},{"dataType":"enum","enums":["X"]}],"validators":{}},
},
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
"Provider": {
Expand Down
3 changes: 2 additions & 1 deletion valhalla/jawn/src/tsoa-build/private/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,8 @@
"QSTASH",
"FIRECRAWL",
"AWS",
"DEEPSEEK"
"DEEPSEEK",
"X"
]
},
"Provider": {
Expand Down
9 changes: 9 additions & 0 deletions web/packages/cost/providers/mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { openAIProvider } from "./openai";
import { anthropicProvider } from "./anthropic";
import { costs as awsBedrockCosts } from "./awsBedrock";
import { costs as deepseekCosts } from "./deepseek";
import { costs as xCosts } from "./x";

const openAiPattern = /^https:\/\/api\.openai\.com/;
const anthropicPattern = /^https:\/\/api\.anthropic\.com/;
Expand Down Expand Up @@ -52,6 +53,8 @@ const firecrawl = /^https:\/\/api\.firecrawl\.dev/;
const awsBedrock = /^https:\/\/bedrock-runtime\.[a-z0-9-]+\.amazonaws\.com\/.*/;
// https://api.deepseek.com
const deepseek = /^https:\/\/api\.deepseek\.com/;
// https://api.x.ai
const x = /^https:\/\/api\.x\.ai/;

export const providersNames = [
"OPENAI",
Expand All @@ -78,6 +81,7 @@ export const providersNames = [
"FIRECRAWL",
"AWS",
"DEEPSEEK",
"X",
] as const;

export type ProviderName = (typeof providersNames)[number];
Expand Down Expand Up @@ -127,6 +131,11 @@ export const providers: {
pattern: cloudflareAiGatewayPattern,
provider: "CLOUDFLARE",
},
{
pattern: x,
provider: "X",
costs: xCosts,
},
{
pattern: twoYFV,
provider: "2YFV",
Expand Down
9 changes: 9 additions & 0 deletions worker/src/packages/cost/providers/mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { openAIProvider } from "./openai";
import { anthropicProvider } from "./anthropic";
import { costs as awsBedrockCosts } from "./awsBedrock";
import { costs as deepseekCosts } from "./deepseek";
import { costs as xCosts } from "./x";

const openAiPattern = /^https:\/\/api\.openai\.com/;
const anthropicPattern = /^https:\/\/api\.anthropic\.com/;
Expand Down Expand Up @@ -52,6 +53,8 @@ const firecrawl = /^https:\/\/api\.firecrawl\.dev/;
const awsBedrock = /^https:\/\/bedrock-runtime\.[a-z0-9-]+\.amazonaws\.com\/.*/;
// https://api.deepseek.com
const deepseek = /^https:\/\/api\.deepseek\.com/;
// https://api.x.ai
const x = /^https:\/\/api\.x\.ai/;

export const providersNames = [
"OPENAI",
Expand All @@ -78,6 +81,7 @@ export const providersNames = [
"FIRECRAWL",
"AWS",
"DEEPSEEK",
"X",
] as const;

export type ProviderName = (typeof providersNames)[number];
Expand Down Expand Up @@ -127,6 +131,11 @@ export const providers: {
pattern: cloudflareAiGatewayPattern,
provider: "CLOUDFLARE",
},
{
pattern: x,
provider: "X",
costs: xCosts,
},
{
pattern: twoYFV,
provider: "2YFV",
Expand Down

0 comments on commit 3ec47bd

Please sign in to comment.