Skip to content

A Python library that logs LLM calls with a single line of code. Part of a bigger project to monitor CO2 emissions caused by gen AI.

Notifications You must be signed in to change notification settings

adityakakarla/call-to-change

Repository files navigation

Description

CallToChange is a carbon emissions calculator for AI apps. This tool analyzes and calculates the carbon emissions generated by a company's LLM (Large Language Model) calls.

This project won first place in the environmental track at LA Hacks (hundreds of participants)


This repo is for call-to-change, a Python library that logs LLM calls with a single line of code.


How to use the Python library

Use the command pip install call-to-change to download our library. Ensure the downloaded version is >= 0.8.6.

Here is a sample script utilizing call-to-change:

from openai import OpenAI
from call_to_change import log

client = OpenAI()

log(client, 'test@test.com')

response = client.chat.completions.create(
  model="gpt-3.5-turbo",
  messages=[
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Who won the world series in 2020?"},
  ]
)

print(response.choices[0].message.content)

How to use the log function

The log function takes in two parameters, an OpenAI client and an email address.

It modifies the client to log any text generation or image generation calls you made. These calls will be tied to the email address you input into the log function.


How to access logs

If you have an account with our web app, your logged calls can be seen through your dashboard. From there, you can view the carbon emissions tied to your OpenAI calls and the offset cost.

If not, your text generation and image generation calls will still be saved. To access your data, create an account with us here and go to the Dashboard page.


How it works

Our Python library logs LLM calls in MongoDB.

Under the hood, it does this by sending a POST request to API routes in our web app. These API routes securely handle data updates in MongoDB.

About

A Python library that logs LLM calls with a single line of code. Part of a bigger project to monitor CO2 emissions caused by gen AI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages