Skip to content

Commit 4b487e1

Browse files
committed
documentation: create v0 documentation
1 parent 4ca6898 commit 4b487e1

63 files changed

Lines changed: 5744 additions & 1865 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/compose.ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ services:
77
dockerfile: api/Dockerfile
88
restart: always
99
env_file: "${APP_ENV_FILE:-.env.ci}"
10-
volumes:
11-
- ../scripts/generate_configuration_documentation.py:/scripts/generate_configuration_documentation.py:ro
1210
ports:
1311
- 8000:8000
1412
environment:

.github/workflows/deploy_documentation.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,26 @@ jobs:
1616
steps:
1717
- name: Checkout
1818
uses: actions/checkout@v4
19+
1920
- name: Setup Node.js
2021
uses: actions/setup-node@v4
2122
with:
2223
node-version: 20
2324
cache: npm
2425
cache-dependency-path: ./docs/package-lock.json
26+
2527
- name: Install dependencies
2628
working-directory: ./docs
2729
run: npm ci
30+
2831
- name: Build Docusaurus site
2932
working-directory: ./docs
3033
run: npm run build
34+
35+
- name: Create CNAME file
36+
working-directory: ./docs/build
37+
run: echo "docs.opengatellm.etalab.gouv.fr" > CNAME
38+
3139
- name: Deploy to GitHub Pages
3240
uses: peaceiris/actions-gh-pages@v3
3341
with:

.github/workflows/generate_documentation.yml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,26 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v4
16+
- name: Checkout du code
17+
uses: actions/checkout@v4
1718

18-
- name: Set up Docker Compose
19-
run: |
20-
cp .github/.env.ci.example .github/.env.ci
21-
sed -i 's/^\([A-Z_]*\)_HOST=localhost/\1_HOST=\L\1/' .github/.env.ci
22-
make test-integ action=up execute=docker
23-
env:
24-
BRAVE_API_KEY: ${{ secrets.BRAVE_API_KEY }}
25-
ALBERT_API_KEY: ${{ secrets.ALBERT_API_KEY }}
26-
CS_API_KEY: ${{ secrets.CS_API_KEY }}
19+
- name: Configure Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.12'
2723

28-
- name: Generate configuration documentation
29-
run: |
30-
docker compose -f .github/compose.ci.yml --env-file .github/.env.ci run -T --user $(id -u):$(id -g) -v $(pwd)/api:/api api \
31-
python /scripts/generate_configuration_documentation.py --output /api/configuration.md
32-
33-
cat ./api/configuration.md > ./docs/docs/getting-started/configuration.md
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install ".[api,dev]"
3428
35-
- name: Commit configuration documentation
36-
uses: stefanzweifel/git-auto-commit-action@v4
37-
with:
38-
commit_message: Update configuration documentation
39-
file_pattern: ./docs/getting-started/configuration.md
29+
- name: Generate documentation
30+
run: |
31+
PYTHONPATH=. python ./scripts/docs/generate_configuration_documentation.py --output ./docs/docs/getting-started/configuration.md
32+
PYTHONPATH=. python ./scripts/docs/convert_notebooks_to_docs.py --input ./docs/tutorials --output ./docs/docs/guides
33+
34+
- name: Commit documentation
35+
uses: stefanzweifel/git-auto-commit-action@v4
36+
with:
37+
commit_message: Update docs
38+
file_pattern: ./docs/getting-started/configuration.md ./docs/docs/guides/*.md

CONTRIBUTING.md

Lines changed: 5 additions & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -1,191 +1,7 @@
11
# Contributing
22

3-
## Contributing environment
4-
5-
To contribute to the project, please follow the instructions below to setup your development environment and launch the services locally.
6-
7-
### Prerequisites
8-
9-
- Python 3.12+
10-
- Docker and Docker Compose
11-
12-
### Step 1: development environment
13-
14-
#### Configuration
15-
16-
It is recommended to use a Python [virtualenv](https://docs.python.org/3/library/venv.html).
17-
18-
1. Create a *config.yml* file based on the example configuration file *[config.example.yml](./config.example.yml)*.
19-
20-
```bash
21-
cp config.example.yml config.yml
22-
```
23-
24-
2. Create a *env* file based on the example environment file *[env.example](./env.example)*
25-
26-
```bash
27-
cp .env.example .env
28-
```
29-
30-
3. Comment host names variables like this (by default, they are set to `localhost` in compose.example.yml):
31-
32-
```bash
33-
# POSTGRES_HOST=postgres
34-
```
35-
36-
4. Check the [configuration documentation](./docs/configuration.md) to configure your configuration file.
37-
38-
#### Packages installation
39-
40-
1. Create a Python virtual environment (recommended)
41-
42-
1. Install the dependencies with the following command:
43-
44-
```bash
45-
pip install ".[api,playground,dev,test]"
46-
```
47-
48-
#### Linter installation
49-
50-
The project linter is [Ruff](https://beta.ruff.rs/docs/configuration/). The specific project formatting rules are in the *[pyproject.toml](./pyproject.toml)* file.
51-
52-
Please install the pre-commit hooks:
53-
54-
```bash
55-
pre-commit install
56-
```
57-
58-
Ruff will run automatically at each commit.
59-
60-
To setup ruff in VSCode or Cursor, you can add the following configuration to your editor:
61-
```json
62-
{
63-
"ruff.lint.enabled": true,
64-
"ruff.lint.fix": true
65-
}
66-
```
67-
68-
### Step 2: launch services
69-
70-
Start services locally with the following command:
71-
72-
```bash
73-
make dev
74-
```
75-
76-
> [!NOTE]
77-
> This command will start the API and the playground services and support the following options:
78-
> ```bash
79-
> make dev [service=api|playground|both] [env=.env] [compose=compose.yml] # service=both by default
80-
> ```
81-
> For more information, run `make help`.
82-
83-
To run the services without make command, you can use the following commands:
84-
85-
1. Export the environment variables:
86-
```bash
87-
export $(grep -v '^#' .env | xargs)
88-
```
89-
90-
2. Launch the API:
91-
```bash
92-
uvicorn api.main:app --log-level debug --reload
93-
```
94-
95-
3. Launch the Playground:
96-
```bash
97-
streamlit run playground/main.py
98-
```
99-
100-
## Linter
101-
102-
The project linter is [Ruff](https://beta.ruff.rs/docs/configuration/). The specific project formatting rules are in the *[pyproject.toml](./pyproject.toml)* file. See [Linter installation section](#linter-installation) to install the linter and run it at each commit.
103-
104-
To run the linter manually:
105-
106-
```bash
107-
make lint
108-
```
109-
110-
To setup ruff in VSCode or Cursor, you can add the following configuration to your editor (edit project root path):
111-
112-
```json
113-
{
114-
"[python]": {
115-
"editor.formatOnType": true,
116-
"editor.formatOnSave": true,
117-
"editor.codeActionsOnSave": {
118-
"source.fixAll": "explicit",
119-
"source.organizeImports": "always"
120-
},
121-
"ruff.configuration": "<absolute project root path >/pyproject.toml",
122-
"ruff.format.preview": true,
123-
"ruff.codeAction.fixViolation": {"enable": false},
124-
"ruff.organizeImports": true,
125-
"ruff.fixAll": true,
126-
"ruff.trace.server": "verbose",
127-
"ruff.logLevel": "debug",
128-
"ruff.nativeServer": "on",
129-
}
130-
}
131-
```
132-
133-
## Commit
134-
135-
Please respect the following convention for your commits:
136-
137-
```
138-
[doc|feat|fix](theme) commit object (in english)
139-
140-
# example
141-
feat(collections): collection name retriever
142-
```
143-
144-
## Tests
145-
146-
To run the tests:
147-
148-
```bash
149-
make test
150-
```
151-
152-
## Modifications to SQL database structure
153-
154-
### Modifications to the [`api/sql/models.py`](./api/sql/models.py) file
155-
156-
If you have modified the API database tables in the [models.py](./api/sql/models.py) file, you need to create an Alembic migration with the following command:
157-
158-
```bash
159-
alembic -c api/alembic.ini revision --autogenerate -m "message"
160-
```
161-
162-
Then apply the migration with the following command:
163-
164-
```bash
165-
alembic -c api/alembic.ini upgrade head
166-
```
167-
168-
### Modifications to the [`playground/sql/models.py`](./playground/sql/models.py) file
169-
170-
If you have modified the playground database tables in the [models.py](./playground/sql/models.py) file, you need to create an Alembic migration with the following command:
171-
172-
```bash
173-
alembic -c playground/alembic.ini revision --autogenerate -m "message"
174-
```
175-
176-
Then apply the migration with the following command:
177-
178-
```bash
179-
alembic -c playground/alembic.ini upgrade head
180-
```
181-
182-
## Generate configuration documentation
183-
184-
To generate the configuration documentation, you can use the following command:
185-
186-
```bash
187-
python scripts/generate_configuration_documentation.py
188-
```
189-
190-
> [!NOTE]
191-
> This will generate the configuration documentation in the *[docs/docs/getting-started/configuration.md](./docs/docs/getting-started/configuration.md)* file from the [configuration schema](./api/schemas/core/configuration.py) with the [configuration header](./scripts/configuration_header.md).
3+
The contributings guides is available in *Contributing* section in [documentation](https://docs.opengatellm.com/docs/):
4+
- [Development environment](https://docs.opengatellm.com/docs/contributing/development-environment)
5+
- [Commit and hooks](https://docs.opengatellm.com/docs/contributing/commit)
6+
- [SQL](https://docs.opengatellm.com/docs/contributing/sql)
7+
- [Documentation](https://docs.opengatellm.com/docs/contributing/documentation)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<img src="./docs/static/img/ogl_logo.svg" alt="Logo" width="128" height="128">
77

88
# OpenGateLLM
9-
[Documentation](https://docs.opengatellm.etalab.gouv.fr) | [API Reference](https://albert.api.etalab.gouv.fr/documentation)
9+
### **[Documentation](https://docs.opengatellm.etalab.gouv.fr) | [API Reference](https://albert.api.etalab.gouv.fr/documentation)**
1010

1111
> [!WARNING]
1212
> **The API is still under beta version, major breaking changes may occur.**
@@ -116,9 +116,9 @@ Explore practical use cases:
116116
### 🤝 Contribute
117117
***
118118

119-
This project exists thanks to all the people who contribute. OpenGateLLM thrives on open-source contributions. Join our community!
119+
This project exists thanks to all the people who contribute. OpenGateLLM thrives on open-source contributions. Join our community!
120120

121-
Check out our [Contribution Guide](./CONTRIBUTING.md) to get started.
121+
Check out our [Contribution Guide](https://docs.opengatellm.etalab.gouv.fr/docs/contributing) to get started.
122122

123123
### 🎖️ Sponsors
124124
***

api/schemas/core/configuration.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
from api.utils.variables import (
1616
DEFAULT_APP_NAME,
1717
DEFAULT_TIMEOUT,
18-
ROUTER__AUTH,
1918
ROUTER__ADMIN,
19+
ROUTER__AUTH,
2020
ROUTERS,
2121
)
2222

@@ -118,7 +118,7 @@ class ModelProvider(ConfigBaseModel):
118118
model_name: constr(strip_whitespace=True, min_length=1) = Field(..., description="Model name from the model provider.", examples=["gpt-4o"]) # fmt: off
119119
model_cost_prompt_tokens: float = Field(default=0.0, ge=0.0, description="Model costs prompt tokens for user budget computation. The cost is by 1M tokens.", examples=[0.1]) # fmt: off
120120
model_cost_completion_tokens: float = Field(default=0.0, ge=0.0, description="Model costs completion tokens for user budget computation. The cost is by 1M tokens.", examples=[0.1]) # fmt: off
121-
model_carbon_footprint_zone: CountryCodes = Field(default=CountryCodes.WOR, description="Model hosting zone for carbon footprint computation (with ISO 3166-1 alpha-3 code format). For more information, see https://ecologits.ai", examples=["WOR"]) # fmt: off
121+
model_carbon_footprint_zone: CountryCodes = Field(default=CountryCodes.WOR, description="Model hosting zone using ISO 3166-1 alpha-3 code format (e.g., `WOR` for World, `FRA` for France, `USA` for United States). This determines the electricity mix used for carbon intensity calculations. For more information, see https://ecologits.ai", examples=["WOR"]) # fmt: off
122122
model_carbon_footprint_total_params: Optional[float] = Field(default=None, ge=0.0, description="Total params of the model in billions of parameters for carbon footprint computation. If not provided, the active params will be used if provided, else carbon footprint will not be computed. For more information, see https://ecologits.ai", examples=[8]) # fmt: off
123123
model_carbon_footprint_active_params: Optional[float] = Field(default=None, ge=0.0, description="Active params of the model in billions of parameters for carbon footprint computation. If not provided, the total params will be used if provided, else carbon footprint will not be computed. For more information, see https://ecologits.ai", examples=[8]) # fmt: off
124124

@@ -251,10 +251,6 @@ class BraveDependency(ConfigBaseModel):
251251
timeout: int = Field(default=DEFAULT_TIMEOUT, ge=1, description="Timeout for the Brave API requests.", examples=[10]) # fmt: off
252252

253253

254-
class CentraleSupelecDependency(ConfigBaseModel):
255-
token: str = Field(description="Centrale Supélec token for testing dynamic models")
256-
257-
258254
@custom_validation_error(url="https://github.com/etalab-ia/opengatellm/blob/main/docs/configuration.md#duckduckgodependency")
259255
class DuckDuckGoDependency(ConfigBaseModel):
260256
url: constr(strip_whitespace=True, min_length=1) = Field(default="https://api.duckduckgo.com/", description="DuckDuckGo API url.") # fmt: off
@@ -341,7 +337,6 @@ class EmptyDepencency(ConfigBaseModel):
341337
class Dependencies(ConfigBaseModel):
342338
albert: Optional[AlbertDependency] = Field(default=None, description="If provided, Albert API is used to parse pdf documents. Cannot be used with Marker dependency concurrently. Pass arguments to call Albert API in this section.") # fmt: off
343339
brave: Optional[BraveDependency] = Field(default=None, description="If provided, Brave API is used to web search. Cannot be used with DuckDuckGo dependency concurrently. Pass arguments to call API in this section. All query parameters are supported, see https://api-dashboard.search.brave.com/app/documentation/web-search/query for more information.") # fmt: off
344-
centralesupelec: Optional[CentraleSupelecDependency] = Field(default=None, description="Needed to pass tests where models are added")
345340
duckduckgo: Optional[DuckDuckGoDependency] = Field(default=None, description="If provided, DuckDuckGo API is used to web search. Cannot be used with Brave dependency concurrently. Pass arguments to call API in this section. All query parameters are supported, see https://www.searchapi.io/docs/duckduckgo-api for more information.") # fmt: off
346341
elasticsearch: Optional[ElasticsearchDependency] = Field(default=None, description="Pass all elastic python SDK arguments, see https://elasticsearch-py.readthedocs.io/en/v9.0.2/api/elasticsearch.html#elasticsearch.Elasticsearch for more information.") # fmt: off
347342
qdrant: Optional[QdrantDependency] = Field(default=None, description="Pass all qdrant python SDK arguments, see https://python-client.qdrant.tech/qdrant_client.qdrant_client for more information.") # fmt: off
@@ -494,7 +489,7 @@ def validate_model(cls, values) -> Any:
494489
@custom_validation_error(url="https://github.com/etalab-ia/opengatellm/blob/main/docs/configuration.md#all-configuration")
495490
class ConfigFile(ConfigBaseModel):
496491
"""
497-
Refer to the [configuration example file](../../../config.example.yml) for an example of configuration.
492+
Refer to the [configuration example file](https://github.com/etalab-ia/OpenGateLLM/blob/main/config.example.yml) for an example of configuration.
498493
"""
499494

500495
models: List[Model] = Field(min_length=1, description="Models used by the API. At least one model must be defined.") # fmt: off

0 commit comments

Comments
 (0)