perseus-client 1.0.0rc1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- perseus_client-1.0.0rc1/.github/workflows/release.yml +33 -0
- perseus_client-1.0.0rc1/.gitignore +7 -0
- perseus_client-1.0.0rc1/.pre-commit-config.yaml +6 -0
- perseus_client-1.0.0rc1/.releaserc.json +62 -0
- perseus_client-1.0.0rc1/LICENSE +21 -0
- perseus_client-1.0.0rc1/PKG-INFO +143 -0
- perseus_client-1.0.0rc1/README.md +124 -0
- perseus_client-1.0.0rc1/examples/advanced/graph-rag-reporting/.gitignore +1 -0
- perseus_client-1.0.0rc1/examples/advanced/graph-rag-reporting/README.md +50 -0
- perseus_client-1.0.0rc1/examples/advanced/graph-rag-reporting/assets/LOREAL_Rapport_Annuel_2024.md +163 -0
- perseus_client-1.0.0rc1/examples/advanced/graph-rag-reporting/assets/LOREAL_Rapport_Annuel_2024.pdf +0 -0
- perseus_client-1.0.0rc1/examples/advanced/graph-rag-reporting/docker-compose.yaml +48 -0
- perseus_client-1.0.0rc1/examples/advanced/graph-rag-reporting/index.py +33 -0
- perseus_client-1.0.0rc1/examples/advanced/graph-rag-reporting/output/graph.ttl +188 -0
- perseus_client-1.0.0rc1/examples/advanced/graph-rag-reporting/output/report_money_kpis.md +60 -0
- perseus_client-1.0.0rc1/examples/advanced/graph-rag-reporting/pdf_to_markdown.py +50 -0
- perseus_client-1.0.0rc1/examples/advanced/graph-rag-reporting/report.py +68 -0
- perseus_client-1.0.0rc1/examples/advanced/graph-rag-reporting/requirements.txt +6 -0
- perseus_client-1.0.0rc1/examples/advanced/graph-rag-reporting/template.env +3 -0
- perseus_client-1.0.0rc1/examples/advanced/graph-rag-reporting/utils.py +47 -0
- perseus_client-1.0.0rc1/examples/simple/build_graph/README.md +29 -0
- perseus_client-1.0.0rc1/examples/simple/build_graph/assets/pizza.ttl +103 -0
- perseus_client-1.0.0rc1/examples/simple/build_graph/assets/pizza.txt +1 -0
- perseus_client-1.0.0rc1/examples/simple/build_graph/build_graph.py +25 -0
- perseus_client-1.0.0rc1/examples/simple/build_graph/output/graph.ttl +23 -0
- perseus_client-1.0.0rc1/examples/simple/build_graph/requirements.txt +2 -0
- perseus_client-1.0.0rc1/examples/simple/build_graph/template.env +1 -0
- perseus_client-1.0.0rc1/examples/simple/delete_operations/README.md +29 -0
- perseus_client-1.0.0rc1/examples/simple/delete_operations/assets/file_to_delete.txt +1 -0
- perseus_client-1.0.0rc1/examples/simple/delete_operations/assets/ontology_to_delete.ttl +3 -0
- perseus_client-1.0.0rc1/examples/simple/delete_operations/delete_example.py +69 -0
- perseus_client-1.0.0rc1/examples/simple/delete_operations/requirements.txt +2 -0
- perseus_client-1.0.0rc1/examples/simple/delete_operations/template.env +1 -0
- perseus_client-1.0.0rc1/examples/simple/file_operations/README.md +29 -0
- perseus_client-1.0.0rc1/examples/simple/file_operations/assets/example.txt +1 -0
- perseus_client-1.0.0rc1/examples/simple/file_operations/file_example.py +29 -0
- perseus_client-1.0.0rc1/examples/simple/file_operations/requirements.txt +2 -0
- perseus_client-1.0.0rc1/examples/simple/file_operations/template.env +1 -0
- perseus_client-1.0.0rc1/examples/simple/ontology_operations/README.md +29 -0
- perseus_client-1.0.0rc1/examples/simple/ontology_operations/assets/example_ontology.ttl +17 -0
- perseus_client-1.0.0rc1/examples/simple/ontology_operations/ontology_example.py +31 -0
- perseus_client-1.0.0rc1/examples/simple/ontology_operations/requirements.txt +2 -0
- perseus_client-1.0.0rc1/examples/simple/ontology_operations/template.env +1 -0
- perseus_client-1.0.0rc1/perseus_client/__init__.py +21 -0
- perseus_client-1.0.0rc1/perseus_client/client.py +160 -0
- perseus_client-1.0.0rc1/perseus_client/config.py +49 -0
- perseus_client-1.0.0rc1/perseus_client/exceptions.py +27 -0
- perseus_client-1.0.0rc1/perseus_client/models.py +63 -0
- perseus_client-1.0.0rc1/perseus_client/services/__init__.py +13 -0
- perseus_client-1.0.0rc1/perseus_client/services/base_service.py +122 -0
- perseus_client-1.0.0rc1/perseus_client/services/file_service.py +153 -0
- perseus_client-1.0.0rc1/perseus_client/services/job_service.py +152 -0
- perseus_client-1.0.0rc1/perseus_client/services/neo4j_service.py +73 -0
- perseus_client-1.0.0rc1/perseus_client/services/ontology_service.py +151 -0
- perseus_client-1.0.0rc1/pyproject.toml +33 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
- release-candidate
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
release:
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write
|
|
13
|
+
issues: write
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- name: Set up Python
|
|
18
|
+
uses: actions/setup-python@v2
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.x"
|
|
21
|
+
- name: Install dependencies
|
|
22
|
+
run: |
|
|
23
|
+
python -m pip install --upgrade pip
|
|
24
|
+
pip install wheel setuptools build
|
|
25
|
+
npm install -g semantic-release semantic-release-pypi @semantic-release/github @semantic-release/git semantic-release-replace-plugin
|
|
26
|
+
- name: Clean dist directory
|
|
27
|
+
run: rm -rf dist/
|
|
28
|
+
- name: Release
|
|
29
|
+
env:
|
|
30
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
31
|
+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
|
|
32
|
+
PYPI_REPOSITORY_URL: https://test.pypi.org/legacy/
|
|
33
|
+
run: npx semantic-release
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"branches": [
|
|
3
|
+
"main",
|
|
4
|
+
{
|
|
5
|
+
"name": "release-candidate",
|
|
6
|
+
"prerelease": "rc"
|
|
7
|
+
}
|
|
8
|
+
],
|
|
9
|
+
"plugins": [
|
|
10
|
+
"@semantic-release/commit-analyzer",
|
|
11
|
+
"@semantic-release/release-notes-generator",
|
|
12
|
+
[
|
|
13
|
+
"semantic-release-replace-plugin",
|
|
14
|
+
{
|
|
15
|
+
"replacements": [
|
|
16
|
+
{
|
|
17
|
+
"files": ["README.md"],
|
|
18
|
+
"from": "pip install perseus-client==.*",
|
|
19
|
+
"to": "pip install perseus-client==${nextRelease.version}",
|
|
20
|
+
"results": [
|
|
21
|
+
{
|
|
22
|
+
"file": "README.md",
|
|
23
|
+
"hasChanged": true,
|
|
24
|
+
"numMatches": 1,
|
|
25
|
+
"numReplacements": 1
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"countMatches": true
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
[
|
|
34
|
+
"semantic-release-pypi",
|
|
35
|
+
{
|
|
36
|
+
"repoUrl": "https://upload.pypi.org/legacy/"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
[
|
|
40
|
+
"@semantic-release/github",
|
|
41
|
+
{
|
|
42
|
+
"assets": [
|
|
43
|
+
{
|
|
44
|
+
"path": "dist/*.whl",
|
|
45
|
+
"label": "Wheel distribution"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "dist/*.tar.gz",
|
|
49
|
+
"label": "Source distribution"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
"@semantic-release/git",
|
|
56
|
+
{
|
|
57
|
+
"assets": ["pyproject.toml", "README.md"],
|
|
58
|
+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
]
|
|
62
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lettria
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: perseus-client
|
|
3
|
+
Version: 1.0.0rc1
|
|
4
|
+
Summary: A Python client for Perseus API
|
|
5
|
+
Project-URL: Homepage, https://github.com/pypa/sampleproject
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/pypa/sampleproject/issues
|
|
7
|
+
Author-email: Victor de La Salmonière <victor@lettria.com>
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Requires-Dist: aiohttp
|
|
14
|
+
Requires-Dist: certifi
|
|
15
|
+
Requires-Dist: neo4j
|
|
16
|
+
Requires-Dist: pydantic
|
|
17
|
+
Requires-Dist: pydantic-settings
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# Perseus Client 🚀
|
|
21
|
+
|
|
22
|
+
[](https://opensource.org/licenses/MIT)
|
|
23
|
+
|
|
24
|
+
In today's world, a vast amount of valuable information is locked away in unstructured text—documents, articles, emails, and more. While AI and analytics tools are incredibly powerful, they struggle to make sense of this chaotic data. They need structured, connected information to reason effectively.
|
|
25
|
+
|
|
26
|
+
This is where the gap lies:
|
|
27
|
+
|
|
28
|
+
| **What Organizations Have** | **What AI Systems Need** |
|
|
29
|
+
| :-------------------------- | :------------------------------ |
|
|
30
|
+
| 📄 **Unstructured Text** | 🔗 **Connected Knowledge** |
|
|
31
|
+
| Chaotic, disconnected data | Structured, queryable graphs |
|
|
32
|
+
| Implicit relationships | Explicit entities and relations |
|
|
33
|
+
| Hard to query and analyze | Ready for deep analysis |
|
|
34
|
+
|
|
35
|
+
Without a way to bridge this gap, AI systems can't unlock the full potential of your data. They might miss critical insights, provide incomplete answers, or fail to see the bigger picture.
|
|
36
|
+
|
|
37
|
+
Lettria's Perseus service is designed to solve this problem. It transforms your raw text into a structured knowledge graph, making it instantly usable for AI applications, from advanced search to complex reasoning. Furthermore, the SDK empowers users to leverage their own ontologies, providing a flexible way to define the desired data schema. This greatly reduces data complexity and ensures the generated knowledge graph is precisely tailored to specific use cases.
|
|
38
|
+
|
|
39
|
+
## 🌟 Features
|
|
40
|
+
|
|
41
|
+
- **Asynchronous Client**: High-performance, non-blocking API calls using `asyncio` and `aiohttp`.
|
|
42
|
+
- **Simple Interface**: Easy-to-use methods for file operations, ontology management, and graph building.
|
|
43
|
+
- **Data Validation**: Robust data modeling with `pydantic`.
|
|
44
|
+
- **Neo4j Integration**: Directly save your graph data to a Neo4j instance.
|
|
45
|
+
- **Flexible Configuration**: Configure via environment variables or directly in code.
|
|
46
|
+
|
|
47
|
+
## 📦 Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install perseus-client==1.0.0-rc.1
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## 🚀 Quick Start
|
|
54
|
+
|
|
55
|
+
To start using the SDK, you will need an API key from Lettria.
|
|
56
|
+
|
|
57
|
+
To create an API key, please visit our app [here](https://app.perseus.lettria.net/).
|
|
58
|
+
|
|
59
|
+
Access to the API is managed by whitelisting. If you require access, please contact us at [hello@lettria.com](mailto:hello@lettria.com) to request whitelisting.
|
|
60
|
+
|
|
61
|
+
### Configuration
|
|
62
|
+
|
|
63
|
+
The SDK can be configured via environment variables. The `PerseusClient` will automatically load them. You can place them in a `.env` file in your project root.
|
|
64
|
+
|
|
65
|
+
| Variable | Description | Required |
|
|
66
|
+
| ----------------- | ----------------------------------------- | -------- |
|
|
67
|
+
| `LETTRIA_API_KEY` | Your unique API key for the Lettria API. | Yes |
|
|
68
|
+
| `NEO4J_URI` | The URI for your Neo4j database instance. | No |
|
|
69
|
+
| `NEO4J_USER` | The username for your Neo4j database. | No |
|
|
70
|
+
| `NEO4J_PASSWORD` | The password for your Neo4j database. | No |
|
|
71
|
+
|
|
72
|
+
### Example: Build a Graph
|
|
73
|
+
|
|
74
|
+
This example shows how to build a graph from a text file.
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
import asyncio
|
|
78
|
+
from perseus_client import PerseusClient
|
|
79
|
+
|
|
80
|
+
async def main():
|
|
81
|
+
async with PerseusClient() as client:
|
|
82
|
+
try:
|
|
83
|
+
await client.build_graph(
|
|
84
|
+
file_path="path/to/your/document.txt",
|
|
85
|
+
)
|
|
86
|
+
print("🎉 Graph built successfully!")
|
|
87
|
+
except Exception as e:
|
|
88
|
+
print(f"An error occurred: {e}")
|
|
89
|
+
|
|
90
|
+
if __name__ == "__main__":
|
|
91
|
+
asyncio.run(main())
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 📚 API Reference
|
|
95
|
+
|
|
96
|
+
### `client.build_graph`
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
async def build_graph(
|
|
100
|
+
file_path: str,
|
|
101
|
+
ontology_path: Optional[str] = None,
|
|
102
|
+
output_path: Optional[str] = None,
|
|
103
|
+
save_to_neo4j: bool = False,
|
|
104
|
+
refresh_graph: bool = False,
|
|
105
|
+
) -> Job:
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Processes a file by uploading it, optionally with an ontology, running a job, and downloading the output.
|
|
109
|
+
|
|
110
|
+
| Parameter | Type | Description | Default |
|
|
111
|
+
| --------------- | --------------- | ----------------------------------------------------------------------------- | ------- |
|
|
112
|
+
| `file_path` | `str` | The path to the file to process. | |
|
|
113
|
+
| `ontology_path` | `Optional[str]` | The path to the ontology file to use. | `None` |
|
|
114
|
+
| `output_path` | `Optional[str]` | The path to save the output to. If not provided, a default path will be used. | `None` |
|
|
115
|
+
| `save_to_neo4j` | `bool` | Whether to save the output to Neo4j. | `False` |
|
|
116
|
+
| `refresh_graph` | `bool` | Whether to force a new job to be created (refresh the graph). | `False` |
|
|
117
|
+
|
|
118
|
+
## 📂 Examples
|
|
119
|
+
|
|
120
|
+
For more detailed examples, check out the [`examples/`](./examples/) directory. Each example has its own README with instructions.
|
|
121
|
+
|
|
122
|
+
### Simple Examples
|
|
123
|
+
|
|
124
|
+
- **[Build Graph](./examples/simple/build_graph/)**: Build a knowledge graph from a text file.
|
|
125
|
+
- **[File Operations](./examples/simple/file_operations/)**: Upload and manage files.
|
|
126
|
+
- **[Ontology Operations](./examples/simple/ontology_operations/)**: Upload and manage ontologies.
|
|
127
|
+
- **[Delete Operations](./examples/simple/delete_operations/)**: Delete files and ontologies.
|
|
128
|
+
|
|
129
|
+
### Advanced Example
|
|
130
|
+
|
|
131
|
+
- **[Graph RAG Reporting](./examples/advanced/graph-rag-reporting/)**: A complete workflow to turn a PDF into a knowledge graph and generate a report.
|
|
132
|
+
|
|
133
|
+
## 🤝 Contributing
|
|
134
|
+
|
|
135
|
+
Contributions are welcome! Feel free to open an issue or submit a pull request.
|
|
136
|
+
|
|
137
|
+
## 📧 Contact
|
|
138
|
+
|
|
139
|
+
For support or questions, please reach out at [hello@lettria.com](mailto:hello@lettria.com).
|
|
140
|
+
|
|
141
|
+
## 📄 License
|
|
142
|
+
|
|
143
|
+
This SDK is licensed under the MIT License.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Perseus Client 🚀
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
|
|
5
|
+
In today's world, a vast amount of valuable information is locked away in unstructured text—documents, articles, emails, and more. While AI and analytics tools are incredibly powerful, they struggle to make sense of this chaotic data. They need structured, connected information to reason effectively.
|
|
6
|
+
|
|
7
|
+
This is where the gap lies:
|
|
8
|
+
|
|
9
|
+
| **What Organizations Have** | **What AI Systems Need** |
|
|
10
|
+
| :-------------------------- | :------------------------------ |
|
|
11
|
+
| 📄 **Unstructured Text** | 🔗 **Connected Knowledge** |
|
|
12
|
+
| Chaotic, disconnected data | Structured, queryable graphs |
|
|
13
|
+
| Implicit relationships | Explicit entities and relations |
|
|
14
|
+
| Hard to query and analyze | Ready for deep analysis |
|
|
15
|
+
|
|
16
|
+
Without a way to bridge this gap, AI systems can't unlock the full potential of your data. They might miss critical insights, provide incomplete answers, or fail to see the bigger picture.
|
|
17
|
+
|
|
18
|
+
Lettria's Perseus service is designed to solve this problem. It transforms your raw text into a structured knowledge graph, making it instantly usable for AI applications, from advanced search to complex reasoning. Furthermore, the SDK empowers users to leverage their own ontologies, providing a flexible way to define the desired data schema. This greatly reduces data complexity and ensures the generated knowledge graph is precisely tailored to specific use cases.
|
|
19
|
+
|
|
20
|
+
## 🌟 Features
|
|
21
|
+
|
|
22
|
+
- **Asynchronous Client**: High-performance, non-blocking API calls using `asyncio` and `aiohttp`.
|
|
23
|
+
- **Simple Interface**: Easy-to-use methods for file operations, ontology management, and graph building.
|
|
24
|
+
- **Data Validation**: Robust data modeling with `pydantic`.
|
|
25
|
+
- **Neo4j Integration**: Directly save your graph data to a Neo4j instance.
|
|
26
|
+
- **Flexible Configuration**: Configure via environment variables or directly in code.
|
|
27
|
+
|
|
28
|
+
## 📦 Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install perseus-client==1.0.0-rc.1
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 🚀 Quick Start
|
|
35
|
+
|
|
36
|
+
To start using the SDK, you will need an API key from Lettria.
|
|
37
|
+
|
|
38
|
+
To create an API key, please visit our app [here](https://app.perseus.lettria.net/).
|
|
39
|
+
|
|
40
|
+
Access to the API is managed by whitelisting. If you require access, please contact us at [hello@lettria.com](mailto:hello@lettria.com) to request whitelisting.
|
|
41
|
+
|
|
42
|
+
### Configuration
|
|
43
|
+
|
|
44
|
+
The SDK can be configured via environment variables. The `PerseusClient` will automatically load them. You can place them in a `.env` file in your project root.
|
|
45
|
+
|
|
46
|
+
| Variable | Description | Required |
|
|
47
|
+
| ----------------- | ----------------------------------------- | -------- |
|
|
48
|
+
| `LETTRIA_API_KEY` | Your unique API key for the Lettria API. | Yes |
|
|
49
|
+
| `NEO4J_URI` | The URI for your Neo4j database instance. | No |
|
|
50
|
+
| `NEO4J_USER` | The username for your Neo4j database. | No |
|
|
51
|
+
| `NEO4J_PASSWORD` | The password for your Neo4j database. | No |
|
|
52
|
+
|
|
53
|
+
### Example: Build a Graph
|
|
54
|
+
|
|
55
|
+
This example shows how to build a graph from a text file.
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
import asyncio
|
|
59
|
+
from perseus_client import PerseusClient
|
|
60
|
+
|
|
61
|
+
async def main():
|
|
62
|
+
async with PerseusClient() as client:
|
|
63
|
+
try:
|
|
64
|
+
await client.build_graph(
|
|
65
|
+
file_path="path/to/your/document.txt",
|
|
66
|
+
)
|
|
67
|
+
print("🎉 Graph built successfully!")
|
|
68
|
+
except Exception as e:
|
|
69
|
+
print(f"An error occurred: {e}")
|
|
70
|
+
|
|
71
|
+
if __name__ == "__main__":
|
|
72
|
+
asyncio.run(main())
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 📚 API Reference
|
|
76
|
+
|
|
77
|
+
### `client.build_graph`
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
async def build_graph(
|
|
81
|
+
file_path: str,
|
|
82
|
+
ontology_path: Optional[str] = None,
|
|
83
|
+
output_path: Optional[str] = None,
|
|
84
|
+
save_to_neo4j: bool = False,
|
|
85
|
+
refresh_graph: bool = False,
|
|
86
|
+
) -> Job:
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Processes a file by uploading it, optionally with an ontology, running a job, and downloading the output.
|
|
90
|
+
|
|
91
|
+
| Parameter | Type | Description | Default |
|
|
92
|
+
| --------------- | --------------- | ----------------------------------------------------------------------------- | ------- |
|
|
93
|
+
| `file_path` | `str` | The path to the file to process. | |
|
|
94
|
+
| `ontology_path` | `Optional[str]` | The path to the ontology file to use. | `None` |
|
|
95
|
+
| `output_path` | `Optional[str]` | The path to save the output to. If not provided, a default path will be used. | `None` |
|
|
96
|
+
| `save_to_neo4j` | `bool` | Whether to save the output to Neo4j. | `False` |
|
|
97
|
+
| `refresh_graph` | `bool` | Whether to force a new job to be created (refresh the graph). | `False` |
|
|
98
|
+
|
|
99
|
+
## 📂 Examples
|
|
100
|
+
|
|
101
|
+
For more detailed examples, check out the [`examples/`](./examples/) directory. Each example has its own README with instructions.
|
|
102
|
+
|
|
103
|
+
### Simple Examples
|
|
104
|
+
|
|
105
|
+
- **[Build Graph](./examples/simple/build_graph/)**: Build a knowledge graph from a text file.
|
|
106
|
+
- **[File Operations](./examples/simple/file_operations/)**: Upload and manage files.
|
|
107
|
+
- **[Ontology Operations](./examples/simple/ontology_operations/)**: Upload and manage ontologies.
|
|
108
|
+
- **[Delete Operations](./examples/simple/delete_operations/)**: Delete files and ontologies.
|
|
109
|
+
|
|
110
|
+
### Advanced Example
|
|
111
|
+
|
|
112
|
+
- **[Graph RAG Reporting](./examples/advanced/graph-rag-reporting/)**: A complete workflow to turn a PDF into a knowledge graph and generate a report.
|
|
113
|
+
|
|
114
|
+
## 🤝 Contributing
|
|
115
|
+
|
|
116
|
+
Contributions are welcome! Feel free to open an issue or submit a pull request.
|
|
117
|
+
|
|
118
|
+
## 📧 Contact
|
|
119
|
+
|
|
120
|
+
For support or questions, please reach out at [hello@lettria.com](mailto:hello@lettria.com).
|
|
121
|
+
|
|
122
|
+
## 📄 License
|
|
123
|
+
|
|
124
|
+
This SDK is licensed under the MIT License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
report_*
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Graph RAG Reporting Example 📊
|
|
2
|
+
|
|
3
|
+
This guide demonstrates how to leverage the Perseus client for building a powerful Graph RAG (Retrieval Augmented Generation) reporting application. You'll learn to convert a PDF document into a Markdown file using an LLM, construct a rich knowledge graph from its content, and then use this graph to generate insightful, context-aware reports.
|
|
4
|
+
|
|
5
|
+
## Quick Start 🚀
|
|
6
|
+
|
|
7
|
+
1. **Setup Environment**:
|
|
8
|
+
|
|
9
|
+
- Requires Docker, Docker Compose, and Python 3.8+. 🐳🐍
|
|
10
|
+
- Copy `template.env` to `.env` and fill your credentials.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
cp template.env .env
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
2. **Install Dependencies & Start Services**:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install -r requirements.txt
|
|
20
|
+
docker compose up -d
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
> ⏳ The embedder service may take a few minutes to fully boot on first run, as it needs to download the underlying model.
|
|
24
|
+
|
|
25
|
+
3. **Run the Workflow**:
|
|
26
|
+
|
|
27
|
+
- **Convert PDF to Markdown**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
python pdf_to_markdown.py assets/LOREAL_Rapport_Annuel_2024.pdf
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- **Index the Document**:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
python index.py assets/LOREAL_Rapport_Annuel_2024.md
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- **Generate a Report**:
|
|
40
|
+
```bash
|
|
41
|
+
python report.py "What are the main activities of L'Oréal?"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Cleaning Up 🧹
|
|
45
|
+
|
|
46
|
+
When you're done, stop and remove the Docker containers:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
docker compose down
|
|
50
|
+
```
|
perseus_client-1.0.0rc1/examples/advanced/graph-rag-reporting/assets/LOREAL_Rapport_Annuel_2024.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
Voici une conversion du rapport annuel 2024 de L'Oréal en format Markdown, structurée par page :
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# RAPPORT ANNUEL 2024 — L’ESSENTIEL : L’ORÉAL
|
|
6
|
+
|
|
7
|
+
**Nº 1 mondial de la beauté**
|
|
8
|
+
|
|
9
|
+
- Nouvelle année de croissance solide et équilibrée
|
|
10
|
+
- Découvrez les chiffres clés et faits marquants
|
|
11
|
+
- Chaque jour, nous inventons le futur de la beauté
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Sommaire et Chiffres Clés (Page 2)
|
|
16
|
+
|
|
17
|
+
### Sommaire
|
|
18
|
+
|
|
19
|
+
- **04** • Mot du Président
|
|
20
|
+
- **05** • Interview du Directeur Général
|
|
21
|
+
- **06** • Conseil d’Administration
|
|
22
|
+
- **08** • Comité Exécutif
|
|
23
|
+
- **10** • Stratégie
|
|
24
|
+
- **12** • Nos fondamentaux : Éthique et Culture
|
|
25
|
+
- **Performances**
|
|
26
|
+
- **14** • Performance financière
|
|
27
|
+
- **16** • Progrès social et environnemental
|
|
28
|
+
- **18** • Création et partage de la valeur
|
|
29
|
+
- **Marques**
|
|
30
|
+
- **20** • Acquisitions
|
|
31
|
+
- **21** • Marques internationales
|
|
32
|
+
- **22** • Produits Grand Public
|
|
33
|
+
- **24** • Luxe
|
|
34
|
+
- **26** • Beauté Dermatologique
|
|
35
|
+
- **28** • Produits Professionnels
|
|
36
|
+
- **Inventer le futur de la beauté**
|
|
37
|
+
- **31** • Une chaîne de valeur agile et responsable
|
|
38
|
+
- **32** • La beauté née de la science
|
|
39
|
+
- **33** • Champion de la Beauty Tech
|
|
40
|
+
- **34** • Vers un modèle plus durable et inclusif
|
|
41
|
+
|
|
42
|
+
### Indicateurs clés 2024
|
|
43
|
+
|
|
44
|
+
- **N°1 mondial de la beauté**
|
|
45
|
+
- **+ de 90 000** collaborateurs
|
|
46
|
+
- **43,48 milliards d’euros** de chiffre d’affaires
|
|
47
|
+
- **8,69 milliards d’euros** de résultat d’exploitation
|
|
48
|
+
- **37** marques internationales
|
|
49
|
+
- **694** brevets déposés en 2024
|
|
50
|
+
- **+ de 150** pays
|
|
51
|
+
|
|
52
|
+
### Notre Raison d'Être
|
|
53
|
+
|
|
54
|
+
**"Créer la beauté qui fait avancer le monde"**
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Éditos (Page 3)
|
|
59
|
+
|
|
60
|
+
### Jean-Paul Agon, Président du Conseil d’Administration
|
|
61
|
+
|
|
62
|
+
> « Dans un environnement incertain, L’Oréal crée de la valeur partagée et façonne le futur de la beauté. »
|
|
63
|
+
|
|
64
|
+
### Nicolas Hieronimus, Directeur Général
|
|
65
|
+
|
|
66
|
+
> « 2024 a été une année décisive au cours de laquelle nous avons établi les fondations du prochain chapitre de la grande Aventure L’Oréal. »
|
|
67
|
+
|
|
68
|
+
**Points clés de l'interview :**
|
|
69
|
+
|
|
70
|
+
- Croissance à données comparables de **+ 5,1 %**.
|
|
71
|
+
- Marge d’exploitation record de **20 %**.
|
|
72
|
+
- **97 %** de l’énergie des sites provient de sources renouvelables.
|
|
73
|
+
- Acquisitions et licences notables : Miu Miu, Dr.G, Galderma, Amouage et Jacquemus.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Gouvernance (Pages 4-5)
|
|
78
|
+
|
|
79
|
+
### Le Conseil d’Administration (au 31 décembre 2024)
|
|
80
|
+
|
|
81
|
+
- **Âge moyen :** 58,5 ans
|
|
82
|
+
- **Indépendance :** 50 % d'administrateurs indépendants
|
|
83
|
+
- **Diversité :** 43 % de femmes, 4 nationalités.
|
|
84
|
+
|
|
85
|
+
**Composition :** Jean-Paul Agon (Président), Nicolas Hieronimus (DG), Françoise Bettencourt Meyers, Paul Bulcke, Sophie Bellon, Patrice Caine, Fabienne Dulac, Béatrice Guillaume-Grabisch, Thierry Hamel, Ilham Kadri, Jean-Victor Meyers, Nicolas Meyers, Virginie Morgon, Alexandre Ricard, Jacques Ripoll, Benny de Vlieger.
|
|
86
|
+
|
|
87
|
+
### Le Comité Exécutif
|
|
88
|
+
|
|
89
|
+
Dirigé par **Nicolas Hieronimus**, il comprend 19 membres supervisant les divisions (Luxe, Grand Public, Beauté Dermatologique, Produits Professionnels), les zones géographiques et les directions fonctionnelles (Recherche, Opérations, RH, Finance, Digital, etc.).
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Stratégie et Fondamentaux (Pages 6-7)
|
|
94
|
+
|
|
95
|
+
### Stratégie
|
|
96
|
+
|
|
97
|
+
- **La beauté pour chacun :** Présence dans 150 pays sur tous les segments de prix.
|
|
98
|
+
- **Le pari de l’innovation :** Plus d’un milliard d’euros investis chaque année en R&I avec 4 000 chercheurs.
|
|
99
|
+
- **Modèle multipolaire et agile :** Organisation décentralisée pour saisir les opportunités locales.
|
|
100
|
+
|
|
101
|
+
### Éthique et Culture
|
|
102
|
+
|
|
103
|
+
- **Principes :** Intégrité, Respect, Courage et Transparence.
|
|
104
|
+
- **Talents :** 1,3 million de candidatures reçues en 2024.
|
|
105
|
+
- **Engagement :** 79 % de taux d’engagement des collaborateurs.
|
|
106
|
+
- **Skills revolution :** Identification de 578 compétences clés pour le futur (Data, IA).
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Performance financière (Page 8)
|
|
111
|
+
|
|
112
|
+
- **Chiffre d’affaires :** 43,48 Mds € (+ 5,1 % comparable).
|
|
113
|
+
- **Résultat d’exploitation :** 8,69 Mds € (+ 6,7 %).
|
|
114
|
+
- **Bénéfice net par action :** 12,66 € (+ 4,8 %).
|
|
115
|
+
- **Répartition du CA par zone :** Europe (33 %), Amérique du Nord (27 %), Asie du Nord (24 %), SAPMENA-SSA (9 %), Amérique latine (8 %).
|
|
116
|
+
- **E-commerce :** 12,3 Mds € (28,2 % du CA total), en croissance de + 7,8 %.
|
|
117
|
+
- **Dividende :** Proposé à 7,00 € (+ 6,1 % par rapport à l'année précédente).
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Progrès social et environnemental (Page 9)
|
|
122
|
+
|
|
123
|
+
- **97 %** d’énergie renouvelable pour les sites opérés.
|
|
124
|
+
- **53 %** de l'eau industrielle est recyclée et réutilisée.
|
|
125
|
+
- **49 %** des emballages plastiques sont rechargeables, réutilisables, recyclables ou compostables.
|
|
126
|
+
- **70 M€** alloués au Fonds L’Oréal pour les Femmes depuis 2020.
|
|
127
|
+
- **Distinctions :** Score AAA au CDP pour la 9e année consécutive ; Médaille Platine EcoVadis (top 1 %).
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Création et partage de la valeur (Page 10)
|
|
132
|
+
|
|
133
|
+
L'Oréal crée de la valeur pour l'ensemble de ses parties prenantes :
|
|
134
|
+
|
|
135
|
+
- **Collaborateurs :** 25 000 opportunités pour les moins de 30 ans.
|
|
136
|
+
- **Consommateurs :** Plus de 7 milliards de produits distribués.
|
|
137
|
+
- **Pouvoirs publics :** 2,8 Mds € d'impôts et taxes reversés en 2024.
|
|
138
|
+
- **Fournisseurs :** Plus de 750 fournisseurs impliqués dans le programme d'Achats Inclusifs.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Portefeuille de Marques (Pages 11-15)
|
|
143
|
+
|
|
144
|
+
L'Oréal s'appuie sur **37 marques internationales** réparties en 4 divisions :
|
|
145
|
+
|
|
146
|
+
1. **Produits Grand Public (+ 5,4 %) :** L'Oréal Paris, Garnier, Maybelline, NYX, etc. Focus sur la démocratisation et l'IA (Beauty Genius).
|
|
147
|
+
2. **Luxe (+ 2,7 %) :** Lancôme, Yves Saint Laurent, Giorgio Armani, Prada, Aesop, etc. Leader en parfumerie fine.
|
|
148
|
+
3. **Beauté Dermatologique (+ 9,8 %) :** La Roche-Posay, CeraVe, Vichy, etc. Innovation majeure : molécule Melasyl™ contre l'hyperpigmentation.
|
|
149
|
+
4. **Produits Professionnels (+ 5,3 %) :** Kérastase, L'Oréal Professionnel, Redken, etc. Lancement du sèche-cheveu AirLight Pro.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Inventer le futur de la beauté (Pages 16-18)
|
|
154
|
+
|
|
155
|
+
- **Opérations :** Déploiement de fulfilment centres automatisés (ex: Suzhou, Chine).
|
|
156
|
+
- **Science :** Lancement de la plateforme _Skin Technology by L’Oréal_ (modèles de peau bioprintés).
|
|
157
|
+
- **Beauty Tech :** Utilisation de l'IA générative via le laboratoire _CreAItech_ pour la création de contenu.
|
|
158
|
+
- **Décarbonation :** Trajectoire validée par la SBTi (objectif 1,5 °C).
|
|
159
|
+
- **Inclusion :** 106 000 personnes issues de communautés vulnérables ont accédé à l'emploi via les programmes du groupe.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
_Pour plus d'informations : lorealrapportannuel2024.com_
|
perseus_client-1.0.0rc1/examples/advanced/graph-rag-reporting/assets/LOREAL_Rapport_Annuel_2024.pdf
ADDED
|
Binary file
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
services:
|
|
2
|
+
# Graph Database
|
|
3
|
+
neo4j:
|
|
4
|
+
image: neo4j:latest
|
|
5
|
+
ports:
|
|
6
|
+
- "7474:7474" # HTTP
|
|
7
|
+
- "7687:7687" # Bolt
|
|
8
|
+
environment:
|
|
9
|
+
- NEO4J_AUTH=neo4j/j4oenj4oen # Change 'password' for production
|
|
10
|
+
- NEO4J_PLUGINS=["apoc"]
|
|
11
|
+
networks:
|
|
12
|
+
- main_local
|
|
13
|
+
volumes:
|
|
14
|
+
- neo4j_data:/data
|
|
15
|
+
restart: unless-stopped
|
|
16
|
+
|
|
17
|
+
# Vector Database
|
|
18
|
+
qdrant:
|
|
19
|
+
image: qdrant/qdrant:latest
|
|
20
|
+
ports:
|
|
21
|
+
- "6333:6333" # API
|
|
22
|
+
- "6334:6334" # gRPC
|
|
23
|
+
networks:
|
|
24
|
+
- main_local
|
|
25
|
+
volumes:
|
|
26
|
+
- qdrant_data:/qdrant/storage
|
|
27
|
+
restart: unless-stopped
|
|
28
|
+
|
|
29
|
+
# Text Embeddings Inference (TEI)
|
|
30
|
+
tei_embedder:
|
|
31
|
+
image: ghcr.io/huggingface/text-embeddings-inference:cpu-latest
|
|
32
|
+
ports:
|
|
33
|
+
- "8080:80"
|
|
34
|
+
environment:
|
|
35
|
+
- MODEL_ID=BAAI/bge-small-en-v1.5
|
|
36
|
+
- REVISION=main
|
|
37
|
+
networks:
|
|
38
|
+
- main_local
|
|
39
|
+
restart: unless-stopped
|
|
40
|
+
|
|
41
|
+
networks:
|
|
42
|
+
main_local:
|
|
43
|
+
driver: bridge
|
|
44
|
+
|
|
45
|
+
volumes:
|
|
46
|
+
neo4j_data:
|
|
47
|
+
qdrant_data:
|
|
48
|
+
minio_data:
|