Skip to content

Commit 1f1a4a9

Browse files
committed
final deployment updates
2 parents e5acf2e + 2addbca commit 1f1a4a9

File tree

9 files changed

+7117
-0
lines changed

9 files changed

+7117
-0
lines changed

fastapi/app/API docs.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# **Wikipedia Translation & Comparison API Documentation**
2+
3+
This API provides services to fetch Wikipedia articles, translate them, semantically compare texts, and manage the underlying Machine Learning models used for these tasks.
4+
5+
## **Getting Started**
6+
7+
### **Prerequisites**
8+
9+
Ensure you have the necessary dependencies installed:
10+
11+
pip install fastapi uvicorn requests nltk Wikipedia-API
12+
13+
### **Running the Server**
14+
15+
Since the code provided is an APIRouter module (endpoints.py), it must be mounted to a main FastAPI application instance.
16+
17+
1. **Run the main.py file**: python main.py
18+
2. **Access the API:**
19+
* **Base URL:** http://127.0.0.1:8000
20+
21+
22+
23+
## **Endpoints**
24+
25+
### **1\. Article Retrieval**
26+
27+
Fetch the content and available languages of a Wikipedia article.
28+
29+
* **Endpoint:** /get\_article
30+
* **Method:** GET
31+
32+
#### **Parameters**
33+
34+
| Parameter | Type | Required | Description |
35+
| :---- | :---- | :---- | :---- |
36+
| url | string | No\* | The full URL of the Wikipedia page. |
37+
| title | string | No\* | The title of the Wikipedia page. |
38+
39+
*\*Note: Either url or title must be provided.*
40+
41+
#### **Responses**
42+
43+
* **200 OK:** Returns article content and language links.
44+
{
45+
"source\_article": "Article text content here...",
46+
"article\_languages": \["es", "fr", "de", "ja"\]
47+
}
48+
49+
* **400 Bad Request:** If neither title nor URL is provided, or URL is invalid.
50+
* **404 Not Found:** If the Wikipedia article does not exist.
51+
52+
### **2\. Translation**
53+
54+
Translate a given text segment from a source language to a target language.
55+
56+
* **Endpoint:** /translate
57+
* **Method:** GET
58+
59+
#### **Parameters**
60+
61+
| Parameter | Type | Required | Description |
62+
| :---- | :---- | :---- | :---- |
63+
| source\_language | string | Yes | Language code of input text (e.g., "en"). |
64+
| target\_language | string | Yes | Language code for output (e.g., "es"). |
65+
| text | string | Yes | The text to translate. |
66+
67+
#### **Responses**
68+
69+
* **200 OK:** Returns the translated text.
70+
71+
### **3\. Semantic Comparison**
72+
73+
Compare the semantic similarity between an original text and a translated text.
74+
75+
* **Endpoint:** /comparison/semantic\_comparison
76+
* **Method:** GET
77+
78+
#### **Parameters**
79+
80+
| Parameter | Type | Required | Description |
81+
| :---- | :---- | :---- | :---- |
82+
| original\_text | string | Yes | The source text. |
83+
| translated\_text | string | Yes | The text to compare against the source. |
84+
| source\_language | string | Yes | Language of the original text. |
85+
| target\_language | string | Yes | Language of the translated text. |
86+
| similarity\_threshold | float | No | Threshold for similarity (Default: 0.75). Must be between 0 and 1\. |
87+
88+
#### **Constraints**
89+
90+
* similarity\_threshold must be between 0 and 1\.
91+
* Input texts cannot be purely numeric strings.
92+
93+
#### **Responses**
94+
95+
* **200 OK:** Returns comparison metrics.
96+
* **400 Bad Request:** If the threshold is invalid or input texts are purely numeric.
97+
98+
### **4\. Model Management**
99+
100+
These endpoints allow you to load, delete, and import specific ML models for translation and comparison tasks.
101+
102+
#### **Translation Models**
103+
104+
| Action | Endpoint | Method | Parameters | Description |
105+
| :---- | :---- | :---- | :---- | :---- |
106+
| **Select** | /models/translation/select | GET | modelname (str) | Activates a specific translation model. |
107+
| **Delete** | /models/translation/delete | GET | modelname (str) | Deletes a loaded translation model. |
108+
| **Import** | /models/translation/import | GET | model (str), from\_huggingface (bool) | Downloads/Imports a new model. |
109+
110+
#### **Comparison Models**
111+
112+
| Action | Endpoint | Method | Parameters | Description |
113+
| :---- | :---- | :---- | :---- | :---- |
114+
| **Select** | /models/comparison/select | GET | modelname (str) | Activates a specific comparison model. |
115+
| **Delete** | /models/comparison/delete | GET | modelname (str) | Deletes a loaded comparison model. |
116+
| **Import** | /models/comparison/import | GET | model (str), from\_huggingface (bool) | Downloads/Imports a new model. |
117+

fastapi/app/ai/dataset/__init__.py

Whitespace-only changes.

fastapi/app/ai/dataset/dataset.json

Lines changed: 3536 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)