Aleph Ollama Translator

A simple Erlang module to translate source code files or strings to a target language using Ollama LLMs.

Hex.pmHex DocsLicenseErlang/OTPAI Powered

Features

Usage

Translate a File

aleph_ollama\:translate_code("path/to/your/file.rs", "Python").

Translate a String

aleph_ollama\:translate_code_from_string("fn main() { println!(\"Hello\"); }", "JavaScript").

Configuration

You can configure the module using the following environment variables:

Example

{ok, TranslatedCode} = aleph_ollama\:translate_code("example.rs", "Python"),
io\:format("~s~n", [TranslatedCode]).

Functions

Function Description
translate_code/2 Translates source code from a file to the target language.
translate_code_from_string/2 Translates code from a string to the target language.
translate_code_from_string_stream/2 Streams translation output from Ollama.
parse_response/1 Cleans and parses the response from Ollama to extract only the translated code.
default_config/0 Returns the default configuration map.
get_env_config/0 Returns the configuration map from environment variables, falling back to defaults.
default_prompt_template/0 Returns the default prompt template for code translation.

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.