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

feat: add Mistral AI cost table and vendor integration #357

Merged
merged 6 commits into from
Nov 21, 2024
Merged
16 changes: 16 additions & 0 deletions components/shared/vendor-metadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,22 @@ export function VendorLogo({
);
}

if (vendor.includes("mistral")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already handled in this file

const color = vendorColor("mistral");
return (
<Image
alt="Mistral Logo"
src="/mistral.png"
width={30}
height={30}
className={cn(
`${color} p-[3px]`,
variant === "circular" ? "rounded-full" : "rounded-md"
)}
/>
);
}

if (vendor.includes("xai")) {
const color = vendorColor("vercel");
return (
Expand Down
51 changes: 51 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 Expand Up @@ -338,6 +381,10 @@ export const LLM_VENDOR_APIS = [
value: "PERPLEXITY_API_KEY",
label: "Perplexity",
},
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

value: "MISTRAL_API_KEY",
label: "Mistral",
},
];

export const LLM_VENDORS = [
Expand All @@ -361,6 +408,10 @@ export const LLM_VENDORS = [
value: "perplexity",
label: "Perplexity",
},
{
value: "mistral",
label: "Mistral",
},
];

export const SUPPORTED_VENDORS: Record<string, string> = {
Expand Down
5 changes: 4 additions & 1 deletion 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 @@ -527,7 +528,7 @@ export function calculatePriceFromUsage(
} else if (model.includes("claude")) {
vendor = "anthropic";
} else if (model.includes("mistral")) {
karthikscale3 marked this conversation as resolved.
Show resolved Hide resolved
karthikscale3 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

@karthikscale3 karthikscale3 Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update this to "tral"

vendor = "mistral"; // Assuming there is a MISTRAL_PRICING object
vendor = "mistral";
karthikscale3 marked this conversation as resolved.
Show resolved Hide resolved
} else if (model.includes("grok")) {
vendor = "xai";
} else if (model.includes("gemini")) {
Expand Down Expand Up @@ -642,6 +643,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