{"id":20926689,"url":"https://github.com/gabrielevalenzuela/chatml","last_synced_at":"2025-08-29T21:39:51.064Z","repository":{"id":261683276,"uuid":"879066468","full_name":"GabrielEValenzuela/chatML","owner":"GabrielEValenzuela","description":"A web API exposing a neural network to detect duplicate entities in knowledge graphs. It uses API key authentication and rate limits requests based on client tiers (FREEMIUM, PREMIUM)","archived":false,"fork":false,"pushed_at":"2025-04-17T17:31:02.000Z","size":85748,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-18T05:54:01.914Z","etag":null,"topics":["knowledge-graph","machine-learning","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GabrielEValenzuela.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-26T21:54:23.000Z","updated_at":"2025-04-17T17:31:05.000Z","dependencies_parsed_at":"2025-03-13T01:38:38.598Z","dependency_job_id":null,"html_url":"https://github.com/GabrielEValenzuela/chatML","commit_stats":null,"previous_names":["gabrielevalenzuela/chatml"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/GabrielEValenzuela/chatML","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielEValenzuela%2FchatML","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielEValenzuela%2FchatML/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielEValenzuela%2FchatML/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielEValenzuela%2FchatML/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GabrielEValenzuela","download_url":"https://codeload.github.com/GabrielEValenzuela/chatML/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielEValenzuela%2FchatML/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272766952,"owners_count":24989408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-29T02:00:10.610Z","response_time":87,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["knowledge-graph","machine-learning","rest-api"],"created_at":"2024-11-18T20:41:03.129Z","updated_at":"2025-08-29T21:39:51.059Z","avatar_url":"https://github.com/GabrielEValenzuela.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chatML 🤖\n\n![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge\u0026logo=python\u0026logoColor=ffdd54) ![FastAPI](https://img.shields.io/badge/FastAPI-005571?style=for-the-badge\u0026logo=fastapi) ![Docker](https://img.shields.io/badge/docker-%230db7ed.svg?style=for-the-badge\u0026logo=docker\u0026logoColor=white) ![PostgreSQL](https://img.shields.io/badge/PostgreSQL-316192?style=for-the-badge\u0026logo=postgresql\u0026logoColor=white) ![MongoDB](https://img.shields.io/badge/MongoDB-4ea94b?style=for-the-badge\u0026logo=mongodb\u0026logoColor=white)\n\n---\n\n## 🧐 Overview\n\n**chatML** is a powerful API designed for working with **Knowledge Graphs (KGs)** using **PyKeen** and **FastAPI**. It provides scalable and efficient ways to perform **entity similarity searches, relationship predictions, and graph-based reasoning**. The project leverages machine learning models like **TransH** to enhance knowledge inference capabilities.\n\n💡 **What is a Knowledge Graph?**  \nA **Knowledge Graph** represents information as a set of entities and their relationships, enabling structured reasoning, semantic search, and intelligent recommendations.\n\n🚀 **Why chatML?**\n\n- FastAPI-based high-performance API\n- Integration with **PyKeen** for Knowledge Graph Embeddings\n- Scalable data storage with PostgreSQL \u0026 MongoDB\n- Efficient caching using Redis\n- **Docker-ready** for seamless deployment\n\n---\n\n## ✨ Features\n\n✔️ **Knowledge Graph Embedding** – Supports models like **TransH**, **TransE**, and **RotatE**  \n✔️ **Entity Similarity** – Retrieve semantically similar entities  \n✔️ **Relationship Prediction** – Predict missing links in the graph  \n✔️ **Graph Querying API** – Intuitive endpoints to interact with the KG  \n✔️ **Rate Limiting** – Protects API from excessive usage (Freemium vs Premium)  \n✔️ **Authentication \u0026 API Keys** – Secure access to endpoints  \n✔️ **Docker Support** – Easy deployment with containerized services\n\n---\n\n## 🛠 Technologies Used\n\n- 🐍 **Python 3.x**\n- ⚡ **FastAPI** (for high-performance web services)\n- 🧠 **PyKeen** (for Knowledge Graph Embeddings)\n- 🐘 **PostgreSQL** (for structured storage)\n- 🍃 **MongoDB** (for flexible document storage)\n- 🔥 **Redis** (for caching)\n- 🐳 **Docker** (for containerization)\n\n---\n\n## 🚀 Installation and Setup\n\n### 🔧 Local Setup\n\n1️⃣ **Clone the repository**\n\n```bash\ngit clone https://github.com/GabrielEValenzuela/chatML\ncd chatML\n```\n\n2️⃣ **Install dependencies**\n\n```bash\npip install -r requirements.txt\n```\n\n3️⃣ **Set up environment variables**\n\nCreate a `.env` file in the root directory with:\n\n```plaintext\nPOSTGRES_HOST=localhost\nPOSTGRES_PORT=5432\nPOSTGRES_DB=api_db\nPOSTGRES_USER=api_user\nPOSTGRES_PASSWORD=api_password\nMONGO_URI=mongodb://localhost:27017\nMONGO_DB=api_user_db\nREDIS_HOST=localhost\nREDIS_PORT=6379\n```\n\n4️⃣ **Run the application**\n\n```bash\nuvicorn src.api.main:app --reload\n```\n\n📌 The API will be accessible at: **`http://localhost:8000`**\n\n---\n\n### 🐳 Running with Docker\n\n1️⃣ **Build the Docker image**\n\n```bash\ndocker build -t chatml-api .\n```\n\n2️⃣ **Run the Docker container**\n\n```bash\ndocker run -d -p 8000:8000 --env-file .env chatml-api\n```\n\n📌 The API will be available at: **`http://localhost:8000`**\n\n---\n\n### 🐳 Running AIO Docker\n\n1️⃣ **Build the Docker image**\n\n```bash\ndocker build -t chatml-api .\n```\n\n2️⃣ **Run the Docker compose**\n\n```bash\ndocker-compose up -d\n```\n\n📌 The API will be available at: **`http://chatkg-api.localhost/`**\n\n📌 The Traekik dashboard will be available at: **`http://localhost:8080/`**\n\n![image](https://github.com/user-attachments/assets/b5c031ee-55c0-4fa0-b431-6d73fe810b78)\n\n![image](https://github.com/user-attachments/assets/145a207e-dec6-4ceb-a9c3-31de3fb96168)\n\n\n\n\n\n\u003e [!NOTE]\n\u003e The AIO Docker compose will run the FastAPI, PostgreSQL, MongoDB, and Redis services using default environment variables.\n\u003e Modify with your own configurations as needed, and avoid using this setup for production environments.\n\n---\n\n## 📡 API Usage\n\nOnce you have the AIO running, you can access to differents endpoints.\n\n## Register a User\n\nThis creates a new account.\n\n\u003e ✅ If your email ends with `@gmail.com`, you'll get **PREMIUM** access.\n\n### Example curl:\n\n```bash\ncurl -X POST http://chatkg-api.localhost/register \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"email\": \"yourname@gmail.com\",\n    \"password\": \"yourStrongPassword\"\n}'\n```\n\u003e 🔁 Replace `\"yourname@gmail.com\"` and `\"yourStrongPassword\"` with your actual email and password.\n\n**Responsee example:**\n\n```json\n{\n  \"account_type\": \"PREMIUM\",\n  \"api_key\": \"d234...\",\n  \"message\": \"User registered successfully. Copy your API Key and keep it safe! IT WONT'T BE SHOWN AGAIN.\",\n  \"token\": null\n}\n```\n\n---\n\n## Login\n\nOnce you're registered, use the same email + password to get your **JWT Token** (you’ll need it later).\n\n### Example curl:\n\n```bash\ncurl -X POST  http://chatkg-api.localhost/login \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"email\": \"yourname@gmail.com\",\n    \"password\": \"yourStrongPassword\"\n}'\n```\n\n**Responsee example:**\n\n```json\n{\n  \"account_type\": null,\n  \"api_key\": null,\n  \"message\": \"Welcome back!\",\n  \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...\"\n}\n```\n\n✅ That `token` **is your JWT**. Use it in the next step.\n\n---\n\n## Get similar entities\n\nHere’s how to use your JWT in the `Authorization` header instead of in the body.\n\n### With a URL-style entity:\n\n```bash\ncurl -X POST http://chatkg-api.localhost/service \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...\" \\\n  -d '{\n    \"entity_input\": \"https://raw.githubusercontent.com/jwackito/csv2pronto/main/ontology/pronto.owl#space_site3_50561744\"\n}'\n```\n\n### With a numeric ID:\n\n```bash\ncurl -X POST http://chatkg-api.localhost/service \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...\" \\\n  -d '{\n    \"entity_input\": 106110\n}'\n```\n\n\u003e 🔁 Replace the long `eyJ...` token with the actual `access_token` from the login response.\n\n**Response:**\n\n```json\n{\n  \"cache\": true,\n  \"result\": [\n    [\n      \"https://raw.githubusercontent.com/jwackito/csv2pronto/main/ontology/pronto.owl#space_site2_A1552552768\",\n      -14.311209678649902\n    ],\n    [\n      \"https://raw.githubusercontent.com/jwackito/csv2pronto/main/ontology/pronto.owl#space_site2_A1377663274\",\n      -14.149274826049805\n    ],\n    [\n      \"https://raw.githubusercontent.com/jwackito/csv2pronto/main/ontology/pronto.owl#space_site2_A1563165924\",\n      -14.016729354858398\n    ],\n    [\n      \"https://raw.githubusercontent.com/jwackito/csv2pronto/main/ontology/pronto.owl#space_site2_A1537220480\",\n      -13.844208717346191\n    ],\n    [\n      \"https://raw.githubusercontent.com/jwackito/csv2pronto/main/ontology/pronto.owl#space_site1_14574103\",\n      -13.730814933776855\n    ],\n    [\n      \"https://raw.githubusercontent.com/jwackito/csv2pronto/main/ontology/pronto.owl#space_site2_A1623902330\",\n      -13.727827072143555\n    ],\n    [\n      \"https://raw.githubusercontent.com/jwackito/csv2pronto/main/ontology/pronto.owl#space_site2_A1483671550\",\n      -13.700096130371094\n    ],\n    [\n      \"https://raw.githubusercontent.com/jwackito/csv2pronto/main/ontology/pronto.owl#space_site3_50138121\",\n      -13.663334846496582\n    ],\n    [\n      \"https://raw.githubusercontent.com/jwackito/csv2pronto/main/ontology/pronto.owl#space_site2_A1390531503\",\n      -13.654467582702637\n    ],\n    [\n      \"https://raw.githubusercontent.com/jwackito/csv2pronto/main/ontology/pronto.owl#space_site2_A1362021113\",\n      -13.56968879699707\n    ]\n  ]\n}\n```\n\nMore endpoints and documentation can be found in the **Home endpoint** 📖\n\n---\n\n## 📖 Knowledge Graphs \u0026 More\n\nFor a deeper understanding of **Knowledge Graphs**, **PyKeen**, and model training, check out our [Wiki](https://github.com/GabrielEValenzuela/chatML/wiki).\n\n🔬 **Topics covered in the Wiki:**  \n✅ What are Knowledge Graphs?  \n✅ How PyKeen works?  \n✅ Training custom embedding models\n\n---\n\n## 📜 License\n\nThis project is licensed under the **GNU General Public License (GPL)**.\n\n---\n\n🌟 **Contributions \u0026 Feedback**\n\nFeel free to **fork, contribute, or submit issues** to help improve this project! 🚀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrielevalenzuela%2Fchatml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgabrielevalenzuela%2Fchatml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrielevalenzuela%2Fchatml/lists"}