Skip to content

Commit

Permalink
Merge pull request #11 from dataforgoodfr/4-package-documentation
Browse files Browse the repository at this point in the history
4 package documentation
  • Loading branch information
samuelrince authored Mar 1, 2024
2 parents b234c11 + b6001c3 commit 538192a
Show file tree
Hide file tree
Showing 6 changed files with 823 additions and 38 deletions.
90 changes: 63 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,89 @@
Template DataForGood
================
GenAI Impact
============

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
**GenAI Impact** tracks and estimates the energy consumption and environmental impacts of using generative AI models through APIs.

This file will become your README and also the index of your
documentation.

# Contributing
# ⚙️ Installation

Coming soon...

## Use a venv
# 🚀 Usage

python3 -m venv name-of-your-venv
```python
from genai_impact import OpenAI

source name-of-your-venv/bin/activate
client = OpenAI(
api_key="<OPENAI_API_KEY>",
)

response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "Hello, can you explain what is the GenAI Impact project?"}
]
)

## Utiliser Poetry
# Get estimated environmental impacts for that inference.
print(response.impacts) # Impacts(energy=0.025, energy_unit='Wh', ...)
```

[Installer Poetry](https://python-poetry.org/docs/):

python3 -m pip install "poetry==1.4.0"

Installer les dépendances:
See package documentation on [GenAI Impact](<link-to-mkdocs-material>)

poetry install
# 💪 Contributing

Ajouter une dépendance:
## Requirements

poetry add pandas
Have [poetry](https://python-poetry.org/docs/#installation) installed on your system.

Mettre à jour les dépendances:

poetry update
<details>
<summary>
Easy install using a virtualenv:
</summary>

## Utiliser Jupyter Notebook
Create a venv:

jupyter notebook
```shell
python3 -m venv .venv
source .venv/bin/activate
```

and check your browser !
Install poetry:

## Lancer les precommit-hook localement
```shell
pip install poetry
```

[Installer les precommit](https://pre-commit.com/)
</details>


pre-commit run --all-files

## Install project

## Utiliser Tox pour tester votre code
```shell
poetry install --with dev,docs
```

tox -vv

## Run tests

```shell
tox -vv
```

OR:

```shell
poetry run pytest
```


## Run pre-commit hooks locally

[Install pre-commit](https://pre-commit.com/)

```shell
pre-commit run --all-files
```
Binary file added docs/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Getting Started

GenAI Impact is an open-source project built by [Data For Good](https://dataforgood.fr/) to highlight GenAI tools' energy consumption.

## Installation

```shell
pip install genai_impact
```


## Basic example for OpenAI

```python
from genai_impact.client_wrapper import OpenAI

client = OpenAI()

response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "Hello World!"}
]
)

print(response.impacts)
```
60 changes: 60 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
site_name: GenAI Impact

repo_name: dataforgoodfr/12_genai_impact
repo_url: https://github.com/dataforgoodfr/12_genai_impact


nav:
- 'Getting Started': index.md


theme:
name: material
logo: assets/logo.png
font:
text: Roboto
palette:
- scheme: default
primary: green
toggle:
icon: material/lightbulb-outline
name: Switch to dark mode
- scheme: slate
primary: green
toggle:
icon: material/lightbulb
name: Switch to light mode
features:
- content.tabs.link
- content.code.copy
- content.code.annotate



watch:
- docs


plugins:
- search


markdown_extensions:
- attr_list
- md_in_html
- tables
- admonition
- pymdownx.emoji:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
- pymdownx.highlight:
anchor_linenums: true
line_spans: __span
pygments_lang_class: true
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences
- pymdownx.details
- pymdownx.tabbed:
alternate_style: true

Loading

0 comments on commit 538192a

Please sign in to comment.