generated from dataforgoodfr/d4g-project-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from dataforgoodfr/4-package-documentation
4 package documentation
- Loading branch information
Showing
6 changed files
with
823 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
Oops, something went wrong.