Git Product home page Git Product logo

deepl-fastapi's Introduction

deepl-fastapi

[tests]pythonCode style: blackLicense: MITPyPI version

Your own deepl server via fastapi, cross-platform (Windows/Linux/MacOs) with API for OmegaT

Installation

  • Create a virual environment: optional but recommended e.g.,
    # Linux and friends
    python3.7 -m venv .venv
    source .venv/bin/activate
    
    # Windows
    # py -3.7 -m venv .venv
    # .venv\Scripts\activate
pip install deepl-fastapi

or (if your use poetry)

poetry add deepl-fastapi

or

 pip install git+https://github.com/ffreemt/deepl-fastapi.git

or

Usage

  • Start the server

Use uvicorn directly (note the deepl_server module, not run_uvicorn)

uvicorn deepl_fastapi.deepl_server:app

or

deepl-fastapi
# this option is available only if installed via pip install or poetry add

or

python3.7 -m deepl_fastapi.run_uvicorn

or run the server on the external net, for example at port 9888

uvicorn deepl_fastapi.deepl_server:app --reload --host 0.0.0.0 --port 9888
  • Explore and consume

Point your browser to http://127.0.0.1:8000/text/?q=test&to_lang=zh

Or in python code (pip install requests first)

import requests

# get
url =  "http://127.0.0.1:8000/text/?q=test me&to_lang=zh"
print(requests.get(url).json())
# {'q': 'test me', 'from_lang': None, 'to_lang': 'zh',
# 'trtext': '考我 试探我 测试我 试探'}

# post
text = "test this and that"
data = {"text": text, "to_lang": "zh"}
resp = requests.post("http://127.0.0.1:8000/text", json=data)
print(resp.json())
# {'q': {'text': 'test this and that', 'from_lang': None, 'to_lang': 'zh', 'description': None},
# 'result': '试探 左右逢源 检验 审时度势'}

Interactive Docs (Swagger UI)

http://127.0.0.1:8000/docs

OmegaT Fake MT plugin setup

RunOmegaTand setup omegat-plugin-fake-mt

OmegaT/Preferences/Machine Translation/Fake MT/Configure
	Name: Fake Deepl MT
	URL: http://localhost:8000/text
	Source Parameter: from_lang
	Target Parameter: to_lang
	Text Parameter: q

deepl-fastapi's People

Contributors

ffreemt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

deepl-fastapi's Issues

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.