Skip to main content

aurora-tr

pytestpythonCode style: blackLicense: MITPyPI version

Translate via aurora and variants, openai, azure openai, etc.

Quick Setup

From command line

pip install aurora-tr
docker run -d --name aurora -p 8080:8080 ghcr.io/aurora-develop/aurora:latest

python code

from aurora_tr import aurora_tr

res = aurora_tr("test me", url="http:/127.0.0.1:8080/v1")
print(res)
# output:  {'translation': '测试我', 'notes': ''}

Detailed Instructions

Install

pip install aurora-tr

Use

url for aurora REST API

First off, acquire a url (OPENAI_BASE_URL in python-openai) for the aurora REST API for aurora-tr to use, for example, search the net, beg your friends, or deploy your own aurora, etc.

N.B.: aurora is a service in the wild similar or compatible to openai (more commonly known as chatgpt).

To deplay your own aurora locolly or on a remote machine, refer to https://github.com/aurora-develop/aurora

For example (the easieast way if you can access docker):

docker run -d --name aurora -p 8080:8080 ghcr.io/aurora-develop/aurora:latest

The OPENAI_BASE_URL in this case will be http://localhost:8080/v1 or http://external_ip_or_domainname:8080/v1

python code

Default base_url, api_key and model of aurora_tr take the value of OPENAI_BASE_URL, OPENAI_API_KEY and OPENAI_MODEL from the file .env-aurora.

base_url, api_key and model can also be set directly in aurora_tr, e.g.,

res = aurora_tr(
  '....',
  url_base="https://uu.ci/v1",
  api_key=...,
  model-"gpt-4-turbo-preview",
  selector="uuci"
)

Hence, if you have deployed your own aurora API:

from aurora_tr import aurora_tr

res = aurora_tr("test me", url="http:/127.0.0.1:8080/v1")
print(res)
# output:  {'translation': '测试我', 'notes': ''}

Other examples:

from aurora_tr import aurora_tr

# default aurora, source language: English, target language: Chinese
res = aurora_tr("Test me.")
print(res)
{'translation': '测试我。', 'notes': 'Translated from English to Chinese.'}
# target language: English
res = aurora_tr("试试我", to_lang="English")
{'translation': 'Try me', 'notes': ''}
# select aurora
res = aurora_tr("Testen mich bitte")
 {'translation': '请测试我', 'notes': 'Translated from English to Chinese'}
# select uuci
import dotenv

api_key = dotenv.dotenv_values(".env").get("OPENAI_API_KEY_UUCI")
# or api_key = "......"
res = aurora_tr("Test me.", selector="uuci", api_key=api_key)
{'translation': '测试我。'}

Brief docs

aurora_tr(
    text: str,
    from_lang: Optional[str] = 'English',
    to_lang: str = 'Chinese',
    selector: str = 'aurora',
    base_url: str = '',
    api_key: str = '',
    model: str = '',
    temperature: Optional[float] = None,
)
Docstring:
Translate viaa auroa and uu.ci.

Args
----
text: string to transalte
from_lang: source language
to_lang: target language
selector: prodiver selector
base_url:
api_key: token
model: model name, anything for aurora
temperature (str): 0.2-0.4 for translation, might just left out

Returns
-------
dict/json: {"translation": "...", notes: "..."}

Metadata

Release files for aurora-tr 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aurora-tr 0.1.1
File Size Uploaded
aurora_tr-0.1.1.tar.gz 22.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aurora-tr 0.1.1
File Interpreter ABI Platform
aurora_tr-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.5 kB

Release files / aurora_tr-0.1.1.tar.gz

Download URL aurora_tr-0.1.1.tar.gz
Size 22.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0c9036ac0a6e9a8f970fe474cb17b389787d637e3e3c9063365608466305e437
BLAKE2b-256 checksum
How to use checksums
762c806dacb24d7fb7a813da68e2c22b4c4e197adf2358ef319254d95d793de3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.0

Release files / aurora_tr-0.1.1-py3-none-any.whl

Download URL aurora_tr-0.1.1-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce800a7b21992d569154f8602d116c89c24175af3a78366bbf85a0dfc90aa449
BLAKE2b-256 checksum
How to use checksums
83af8960e94904d6295542ef91e33278de4bf6a2b6ce2c0433eb056d7eca1de7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.0

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page