Skip to content

Commit

Permalink
feat: add Mistral AI cost table and vendor integration (#357)
Browse files Browse the repository at this point in the history
* feat: add Mistral AI cost table and vendor integration

* feat: add Mistral AI cost table

* fix: address PR comments for Mistral AI integration

* feat: add Mistral handling in litellm condition and remove duplicate XAI logo code

* Update model check to 'tral'

* Update vendor detection to use 'tral' for Mistral models for consistency

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
  • Loading branch information
devin-ai-integration[bot] authored Nov 21, 2024
1 parent ad8ea38 commit 613c9f2
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
2 changes: 2 additions & 0 deletions components/shared/vendor-metadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ export function VendorLogo({
);
}



if (vendor.includes("xai")) {
const color = vendorColor("vercel");
return (
Expand Down
43 changes: 43 additions & 0 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,49 @@ export const OPENAI_PRICING: Record<string, CostTableEntry> = {

};

export const MISTRAL_PRICING: Record<string, CostTableEntry> = {
"mistral-large-latest": {
input: 0.002,
output: 0.006,
},
"pixtral-large-latest": {
input: 0.002,
output: 0.006,
},
"mistral-small-latest": {
input: 0.0002,
output: 0.0006,
},
"codestral-latest": {
input: 0.0002,
output: 0.0006,
},
"ministral-8b-latest": {
input: 0.0001,
output: 0.0001,
},
"ministral-3b-latest": {
input: 0.00004,
output: 0.00004,
},
"mistral-embed": {
input: 0.0001,
output: 0,
},
"open-mistral-7b": {
input: 0.00025,
output: 0.00025,
},
"open-mixtral-8x7b": {
input: 0.0007,
output: 0.0007,
},
"open-mixtral-8x22b": {
input: 0.002,
output: 0.006,
},
};

export const XAI_PRICING: Record<string, CostTableEntry> = {
"grok-beta": {
input: 0.005,
Expand Down
9 changes: 7 additions & 2 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
CostTableEntry,
GROQ_PRICING,
LangTraceAttributes,
MISTRAL_PRICING,
OPENAI_PRICING,
PERPLEXITY_PRICING,
SpanStatusCode,
Expand Down Expand Up @@ -526,8 +527,8 @@ export function calculatePriceFromUsage(
vendor = "openai";
} else if (model.includes("claude")) {
vendor = "anthropic";
} else if (model.includes("mistral")) {
vendor = "mistral"; // Assuming there is a MISTRAL_PRICING object
} else if (model.includes("tral")) {
vendor = "mistral";
} else if (model.includes("grok")) {
vendor = "xai";
} else if (model.includes("gemini")) {
Expand Down Expand Up @@ -581,6 +582,8 @@ export function calculatePriceFromUsage(
costTable = GEMINI_PRICING[model];
} else if (model.includes("grok")) {
costTable = XAI_PRICING[model];
} else if (model.includes("tral")) {
costTable = MISTRAL_PRICING[model];
}
} else if (vendor === "openai") {
// check if model is present as key in OPENAI_PRICING
Expand Down Expand Up @@ -642,6 +645,8 @@ export function calculatePriceFromUsage(
costTable = GEMINI_PRICING[model];
} else if (vendor === "xai") {
costTable = XAI_PRICING[model];
} else if (vendor === "mistral") {
costTable = MISTRAL_PRICING[model];
}
if (costTable) {
const total =
Expand Down

0 comments on commit 613c9f2

Please sign in to comment.