Translate via aurora and variants, openai, azure openai, etc.
Project description
aurora-tr
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: "..."}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file aurora_tr-0.1.1.tar.gz
.
File metadata
- Download URL: aurora_tr-0.1.1.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c9036ac0a6e9a8f970fe474cb17b389787d637e3e3c9063365608466305e437 |
|
MD5 | 383ba19664280c0d9cc5ffa70d11453f |
|
BLAKE2b-256 | 762c806dacb24d7fb7a813da68e2c22b4c4e197adf2358ef319254d95d793de3 |
File details
Details for the file aurora_tr-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: aurora_tr-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce800a7b21992d569154f8602d116c89c24175af3a78366bbf85a0dfc90aa449 |
|
MD5 | d8e934aa33da8b36ef9c3a973e130316 |
|
BLAKE2b-256 | 83af8960e94904d6295542ef91e33278de4bf6a2b6ce2c0433eb056d7eca1de7 |