@genai-impact/ecologits-mistral
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

Ecologits.js - Mistral provider

Install

npm

npm install @genai-impact/ecologits-mistral

yarn

yarn add @genai-impact/ecologits-mistral

Usage (Calculator only)

import { Mistral } from "@mistralai/mistralai";
import { completeImpact } from "@genai-impact/ecologits-mistral";

const apiKey = process.env.MISTRAL_API_KEY;

const client = new Mistral({ apiKey });

const main = async () => {
  try {
    const startDate = new Date();
    const response = await client.chat.complete({
      model: "mistral-tiny",
      messages: [{ role: "user", content: "What is the best French cheese?" }],
    });
    const impacts = completeImpact(response, "mistral-tiny", startDate);
    // Get estimated environmental impacts of the inference
    console.log(
      // @ts-ignore
      `Energy consumption: ${impacts.energy.value} ${impacts.energy.unit}`
    );
    console.log(
      // @ts-ignore
      `GHG emissions: ${impacts.gwp.value} ${impacts.gwp.unit}`
    );
  } catch (e) {
    console.error(e);
    throw e;
  }
};
main();

Package Sidebar

Install

npm i @genai-impact/ecologits-mistral

Homepage

ecologits.ai

Weekly Downloads

6

Version

1.0.9

License

MPL-2.0

Unpacked Size

8.65 kB

Total Files

16

Last publish

Collaborators

  • yco
  • samuelrince