1.0.9 • Published 11 months ago

@genai-impact/ecologits-mistral v1.0.9

Weekly downloads
-
License
MPL-2.0
Repository
github
Last release
11 months ago

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();
1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago