File size: 2,363 Bytes
c00b9e6
783d533
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c00b9e6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82

## Translation Agent WebUI

This repository contains a Gradio web UI for a translation agent that utilizes various language models for translation.

**Features:**

- **Tokenized Text:**  Displays translated text with tokenization, highlighting differences between original and translated words.
- **Document Upload:** Supports uploading various document formats (PDF, TXT, DOC, etc.) for translation.
- **Multiple API Support:**  Integrates with popular language models like:
    - Groq
    - OpenAI
    - Cohere
    - Ollama
    - Together AI
    - Hugging Face Inference API
    ...

Llama Index supported, easily extendable



**Getting Started**

1. **Install Dependencies:**
    **Linux(Using Python Venv)**

    ```bash

        git clone https://github.com/andrewyng/translation-agent.git

        cd translation-agent

        python -m venv web_ui

        source web_ui/bin/activate

        pip install -r app/webui/requirements.txt


    ```

    **Windows**

    ```bash

        git clone https://github.com/andrewyng/translation-agent.git

        cd translation-agent

        python -m venv web_ui

        .\web_ui\Scripts\activate

        pip install -r app/webui/requirements.txt


    ```


2. **Set API Keys:**
   - Rename `.env.sample` to `.env`, you can add your API keys for each service:

     ```

     OPENAI_API_KEY="sk-xxxxx" # Keep this field

     GROQ_API_KEY="xxxxx"

     COHERE_API_KEY="xxxxx"

     TOGETHER_API_KEY="xxxxx"

     HF_TOKEN="xxxxx"

     ```

    - Then you can also set the API_KEY in webui.


3. **Run the Web UI:**
    ```bash

    python -m app.webui.app

    ```


4. **Access the Web UI:**
   Open your web browser and navigate to `http://127.0.0.1:7860/`.

**Usage:**

1. Select your desired translation API from the Endpoint dropdown menu.
2. If using Hugging Face API, enter your `HF_TOKEN` in the `api_key` textbox.
3. Input the source text or upload your document file.
4. Submit and get translation, the UI will display the translated text with tokenization and highlight differences.

**Customization:**

- **Add New LLMs:**  Modify the `patch.py` file to integrate additional LLMs.

**Contributing:**

Contributions are welcome! Feel free to open issues or submit pull requests.

**License:**

This project is licensed under the MIT License.