Code Monkey home page Code Monkey logo

openai-translator's Introduction

OpenAI-Translator


English | δΈ­ζ–‡

All the code and documentation are entirely generated by OpenAI's GPT-4 Model

Introduction

OpenAI Translator is an AI-powered translation tool designed to translate English PDF books to Chinese. The tool leverages large language models (LLMs) like ChatGLM and OpenAI's GPT-3 and GPT-3.5 Turbo for translation. It's built in Python and has a flexible, modular, and object-oriented design.

Why this project

In the current landscape, there's a lack of non-commercial yet efficient PDF translation tools. Many users have PDF documents with sensitive data that they prefer not to upload to public commercial service websites due to privacy concerns. This project was developed to address this gap, providing a solution for users who need to translate their PDFs while maintaining data privacy.

Sample Results

The OpenAI Translator is still in its early stages of development, and I'm actively working on adding more features and improving its performance. We appreciate any feedback or contributions!

The_Old_Man_of_the_Sea

"The Old Man and the Sea"

Features

  • Translation of English PDF books to Chinese using LLMs.
  • Support for both ChatGLM and OpenAI models.
  • Flexible configuration through a YAML file or command-line arguments.
  • Timeouts and error handling for robust translation operations.
  • Modular and object-oriented design for easy customization and extension.
  • Implement a graphical user interface (GUI) for easier use.
  • Add support for batch processing of multiple PDF files.
  • Create a web service or API to enable usage in web applications.
  • Add support for other languages and translation directions.
  • Add support for preserving the original layout and formatting of the source PDF.
  • Improve translation quality by using custom-trained translation models.

Getting Started

Environment Setup

1.Clone the repository git clone [email protected]:DjangoPeng/openai-translator.git.

2.The OpenAI-Translator requires Python 3.6 or later. Install the dependencies with pip install -r requirements.txt.

3.Set up your OpenAI API key($OPENAI_API_KEY) or ChatGLM Model URL($GLM_MODEL_URL). You can either add it to your environment variables or specify it in the config.yaml file.

Usage

You can use OpenAI-Translator either by specifying a configuration file or by providing command-line arguments.

Using a configuration file:

Adapt config.yaml file with your settings:

OpenAIModel:
  model: "gpt-3.5-turbo"
  api_key: "your_openai_api_key"

GLMModel:
  model_url: "your_chatglm_model_url"
  timeout: 300

common:
  book: "test/test.pdf"
  file_format: "markdown"

Then run the tool:

python ai_translator/main.py

sample_out

Using command-line arguments:

You can also specify the settings directly on the command line. Here's an example of how to use the OpenAI model:

# Set your api_key as an env variable
export OPENAI_API_KEY="sk-xxx"
python ai_translator/main.py --model_type OpenAIModel --api_key $OPENAI_API_KEY --book your_book.pdf 

And an example of how to use the GLM model:

# Set your GLM Model URL as an env variable
export GLM_MODEL_URL="http://xxx:xx"
python ai_translator/main.py --model_type GLMModel --glm_model_url $GLM_MODEL_URL --book your_book.pdf 

License

This project is licensed under the GPL-3.0 License. See the LICENSE file for details.

openai-translator's People

Contributors

djangopeng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.