Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
sync-dev:
uv sync --group dev

start:
uv run fastapi dev app/main.py

build-docker:
docker build -t ecologits-api

run-docker:
docker run -p 8000:80 ecologits-api

test:
uv run pytest

format:
uv run ruff check --select I --fix && uv run ruff format

check-fix:
uv run ruff check --fix && uv run ruff check --select I --fix
81 changes: 0 additions & 81 deletions app/api/v1/router.py

This file was deleted.

File renamed without changes.
11 changes: 11 additions & 0 deletions app/api/v1beta/responses/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from app.api.v1beta.responses.electricity_mix import ELECTRICITY_MIX_RESPONSES
from app.api.v1beta.responses.estimations import ESTIMATIONS_RESPONSES
from app.api.v1beta.responses.models import MODELS_RESPONSES
from app.api.v1beta.responses.providers import PROVIDERS_RESPONSES

__all__ = [
"PROVIDERS_RESPONSES",
"MODELS_RESPONSES",
"ELECTRICITY_MIX_RESPONSES",
"ESTIMATIONS_RESPONSES",
]
28 changes: 28 additions & 0 deletions app/api/v1beta/responses/electricity_mix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ELECTRICITY_MIX_RESPONSES = {
200: {
"description": "Electricity mix composition for the specified zone.",
"content": {
"application/json": {
"example": {
"electricity_mix": {
"zone": "FRA",
"adpe": 4.858e-08,
"pe": 9.3135,
"gwp": 0.04418,
"wue": 3.6737,
}
}
}
},
},
404: {
"description": "Zone not supported by EcoLogits.",
"content": {
"application/json": {
"example": {
"detail": "Electricity mix zone 'XYZ' is not supported by EcoLogits"
}
}
},
},
}
149 changes: 149 additions & 0 deletions app/api/v1beta/responses/estimations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
ESTIMATIONS_RESPONSES = {
200: {
"description": "Environmental impact estimation with min/max intervals.",
"content": {
"application/json": {
"example": {
"impacts": {
"energy": {
"type": "energy",
"name": "Energy",
"value": {
"min": 0.00001740232832301384,
"max": 0.000021502108309942407,
},
"unit": "kWh",
},
"gwp": {
"type": "GWP",
"name": "Global Warming Potential",
"value": {
"min": 0.000008448613075332601,
"max": 0.000010387850006949683,
},
"unit": "kgCO2eq",
},
"adpe": {
"type": "ADPe",
"name": "Abiotic Depletion Potential (elements)",
"value": {
"min": 1.2955834115064265e-11,
"max": 1.3011140147087931e-11,
},
"unit": "kgSbeq",
},
"pe": {
"type": "PE",
"name": "Primary Energy",
"value": {
"min": 0.0000476420806326274,
"max": 0.0000582486214368103,
},
"unit": "MJ",
},
"wcf": {
"type": "WCF",
"name": "Water Consumption Footprint",
"value": {
"min": 0.00009151188371940057,
"max": 0.00011307098675866313,
},
"unit": "L",
},
"usage": {
"type": "usage",
"name": "Usage",
"energy": {
"type": "energy",
"name": "Energy",
"value": {
"min": 0.00001740232832301384,
"max": 0.000021502108309942407,
},
"unit": "kWh",
},
"gwp": {
"type": "GWP",
"name": "Global Warming Potential",
"value": {
"min": 0.000008231475320068776,
"max": 0.000010170712251685857,
},
"unit": "kgCO2eq",
},
"adpe": {
"type": "ADPe",
"name": "Abiotic Depletion Potential (elements)",
"value": {
"min": 2.3475740907745673e-13,
"max": 2.9006344110112307e-13,
},
"unit": "kgSbeq",
},
"pe": {
"type": "PE",
"name": "Primary Energy",
"value": {
"min": 0.000045021563604469106,
"max": 0.000055628104408652,
},
"unit": "MJ",
},
"wcf": {
"type": "WCF",
"name": "Water Consumption Footprint",
"value": {
"min": 0.00009151188371940057,
"max": 0.00011307098675866313,
},
"unit": "L",
},
},
"embodied": {
"type": "embodied",
"name": "Embodied",
"gwp": {
"type": "GWP",
"name": "Global Warming Potential",
"value": {
"min": 2.1713775526382546e-7,
"max": 2.1713775526382546e-7,
},
"unit": "kgCO2eq",
},
"adpe": {
"type": "ADPe",
"name": "Abiotic Depletion Potential (elements)",
"value": {
"min": 1.2721076705986809e-11,
"max": 1.2721076705986809e-11,
},
"unit": "kgSbeq",
},
"pe": {
"type": "PE",
"name": "Primary Energy",
"value": {
"min": 0.0000026205170281582953,
"max": 0.0000026205170281582953,
},
"unit": "MJ",
},
},
"warnings": [
{
"code": "model-arch-not-released",
"message": "The model architecture has not been released, expect lower precision.",
},
{
"code": "model-arch-multimodal",
"message": "The model architecture is multimodal, expect lower precision.",
},
],
"errors": None,
}
}
}
},
},
}
35 changes: 35 additions & 0 deletions app/api/v1beta/responses/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
MODELS_RESPONSES = {
200: {
"description": "List of models for the provider.",
"content": {
"application/json": {
"example": {
"models": [
{
"provider": "openai",
"name": "gpt-4o-mini",
"architecture": {
"type": "moe",
"parameters": {
"total": 440,
"active": {"min": 44, "max": 132},
},
},
"warnings": [
{
"code": "model-arch-not-released",
"message": "The model architecture has not been released, expect lower precision.",
}
],
"sources": [],
}
]
}
}
},
},
404: {
"description": "Provider not found.",
"content": {"application/json": {"example": {"detail": "Provider not found"}}},
},
}
19 changes: 19 additions & 0 deletions app/api/v1beta/responses/providers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
PROVIDERS_RESPONSES = {
200: {
"description": "List of provider identifiers.",
"content": {
"application/json": {
"example": {
"providers": [
"anthropic",
"mistralai",
"openai",
"huggingface_hub",
"cohere",
"google_genai",
]
}
}
},
},
}
Loading
Loading