eric7.Plugins.UiExtensionPlugins.Translator.TranslatorEngines.OllamaEngine

Module implementing the 'ollama' translation engine.

Global Attributes

None

Classes

OllamaEngine Class implementing the translation engine for the 'translategemma' model of an 'ollama' server.
TranslationModelSelectionError Class defining an exception for no selected translation models.
TranslationModelUnavailableError Class defining an exception for unavailable translation models.

Functions

createEngine Function to instantiate a translator engine object.


OllamaEngine

Class implementing the translation engine for the 'translategemma' model of an 'ollama' server.

Derived from

TranslationEngine

Class Attributes

CodeLanguageMapping
MessageTemplate
TranslatorModelName

Class Methods

None

Methods

OllamaEngine Constructor
__handleServerError Private slot handling an issue reported by the 'ollama' server or the server interface.
__handleServerStateChanged Private slot handling a change in the 'ollama' server connected state.
__handleTranslationResponse Private slot handling the server translation response.
engineName Public method to return the name of the engine.
getTranslation Public method to translate the given text.
shutdown Public method to perform shutdown actions before the engine is discarded.
supportedLanguages Public method to get the supported languages.

Static Methods

None

OllamaEngine (Constructor)

OllamaEngine(plugin, parent=None)

Constructor

plugin (TranslatorPlugin)
reference to the plugin object
parent (QObject)
reference to the parent object
Raises TranslationModelSelectionError:
raised when the user did not select any 'translategemma' model variant
Raises TranslationModelUnavailableError:
raised to signal the unavailability of any 'translategemma' model

OllamaEngine.__handleServerError

__handleServerError(message)

Private slot handling an issue reported by the 'ollama' server or the server interface.

message (str)
error message

OllamaEngine.__handleServerStateChanged

__handleServerStateChanged(connected, msg)

Private slot handling a change in the 'ollama' server connected state.

connected (bool)
flag indicating the connected state of an 'ollama' server
msg (str)
status message

OllamaEngine.__handleTranslationResponse

__handleTranslationResponse(translation)

Private slot handling the server translation response.

translation (str)
translated text

OllamaEngine.engineName

engineName()

Public method to return the name of the engine.

Return:
engine name
Return Type:
str

OllamaEngine.getTranslation

getTranslation(requestObject, text, originalLanguage, translationLanguage, )

Public method to translate the given text.

requestObject (TranslatorRequest)
reference to the request object
text (str)
text to be translated
originalLanguage (str)
language code of the original
translationLanguage (str)
language code of the translation
Return:
tuple of translated text and flag indicating success
Return Type:
tuple of (str, bool)

OllamaEngine.shutdown

shutdown()

Public method to perform shutdown actions before the engine is discarded.

OllamaEngine.supportedLanguages

supportedLanguages()

Public method to get the supported languages.

Return:
list of supported language codes
Return Type:
list of str
Up


TranslationModelSelectionError

Class defining an exception for no selected translation models.

Derived from

BaseException

Class Attributes

None

Class Methods

None

Methods

None

Static Methods

None
Up


TranslationModelUnavailableError

Class defining an exception for unavailable translation models.

Derived from

BaseException

Class Attributes

None

Class Methods

None

Methods

None

Static Methods

None
Up


createEngine

createEngine(plugin, parent=None)

Function to instantiate a translator engine object.

plugin (TranslatorPlugin)
reference to the plugin object
parent (QObject (optional))
reference to the parent object (defaults to None)
Return:
reference to the instantiated translator engine object
Return Type:
DeepLEngine
Up