Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add webui App #30

Merged
merged 22 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ poetry.lock
floresp-v2.0-rc.3
*cache
wmt
outputs
89 changes: 89 additions & 0 deletions app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@

## Translation Agent WebUI

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

### Preview

![webui](image.png)

**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
- Ollama
- Together AI
...
- **Different LLM for reflection**: Now you can enable second Endpoint to use another LLM for reflection.


**Getting Started**

1. **Install Dependencies:**

**Linux**
```bash
git clone https://github.com/andrewyng/translation-agent.git
cd translation-agent
poetry install --with app
poetry shell
```
**Windows**
```bash
git clone https://github.com/andrewyng/translation-agent.git
cd translation-agent
poetry install --with app
poetry shell
```

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"
TOGETHER_API_KEY="xxxxx"
```
- Then you can also set the API_KEY in webui.

3. **Run the Web UI:**

**Linux**
```bash
python app/app.py
```
**Windows**
```bash
python .\app\app.py
```

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. Input the source language, target language, and country(optional).
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.
5. Enable Second Endpoint, you can add another endpoint by different LLMs for reflection.
6. Using a custom endpoint, you can enter an OpenAI compatible API base url.

**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.

**DEMO:**

[Huggingface Demo](https://huggingface.co/spaces/vilarin/Translation-Agent-WebUI)
Loading