janvarev / OneRingTranslator

Simple local REST web service to translate texts. Plugins. Automatic calculate BLEU/COMET metrics of translation quality.
MIT License
110 stars 12 forks source link

[Feature Request] pip package #4

Open Cohee1207 opened 1 year ago

Cohee1207 commented 1 year ago

Hi there,

Following up on the pull request for SillyTavern, I really liked your project and wondering if you could wrap it into a pip package so the translation service could be installed to any Python project. I would like including it into my ST-Extras project (https://github.com/SillyTavern/SillyTavern-extras) as an optional module to make a one-click install for users of ST and colabs.

If you need examples, here's Silero TTS server that was possible to be integrated thanks to that: https://github.com/ouoertheo/silero-api-server

Best wishes.

janvarev commented 1 year ago

Hi! Thanks for request, and for SillyTavern stuff! :)

About pip package - I'm not really sure about it. One of core functions as I feel it's to add your own plugins and edit their options - and in this case you must have access to folder structure. And I just no good at pip packages making...

On other hand, there is two ways:

just somewhere run (I've just copied relevant fragments from run_webapi.py file):

core = OneRingCore()
core.init_with_plugins()

def translate(text:str, from_lang:str = "", to_lang:str = "", translator_plugin:str = "", add_params:str = ""):
    if translator_plugin == "":
        translator_plugin = core.default_translator
    res = core.translators[translator_plugin][1](core,text,from_lang,to_lang,add_params)

That's all!

I will think about pip package later, but not sure I'll make it good...