Location>code7788 >text

SimpleTranslationAIAgent: Translation AI Agent based on C# and LLM

Popularity:789 ℃/2024-08-31 13:56:29

File-to-file translation tasks based on C# and LLM can be realized through a simple dialog.

The software is completely open source and free under the MIT agreement, but there may be a cost to call LLM's API, but that's okay, Cyberbuddha Silicon Flow and Wisdom Spectrum AI, among others, have free models available for tuning now.

This Translation AI Agent is just a simple AI Agent sample application, and many of you probably don't need it.

Open source out mainly for interested students can look at the source code, you can also use C# + LLM to build a more interesting and more efficient to improve their own work efficiency of their own exclusive AI Agent application!

You can choose the right model based on the complexity of the AI Agent application you are building. When the application is relatively simple, a free model may be sufficient, but when the application is more complex, a stronger model may be needed. Nowadays, almost all major platforms have sent some token experience, so you can take these tokens to try it out first.

image-20240831115531547

GitHub Address:/Ming-jiayou/SimpleTranslationAIAgent

Now glm-4-flash is free and tested for some simple AI Agent tasks.

Let's start with a simple task that automatically writes the content to a file after it has been translated:

image-20240830164931643

I don't have it on my desktop right now.

image-20240830165003575

Created this file and wrote the contents:

image-20240830165110246

Record the whole thing on screen and take a look:

The md file is also available:

image-20240830165653037

image-20240830165717751

Record the screen to see the whole thing:

Now try the more difficult task of taking text out of one file and translating it before writing it into another.

For example, I have a file that looks like this:

image-20240830170813739

I want to let Translation AI Agent help me translate into Chinese, and then stored in another file, if the file does not exist then create a new file, it can be written like this, just provide the file path:

image-20240830171542144

Failed:

image-20240830172736359

Try switching to a stronger glm-4 model:

image-20240830172933040

Successfully completed this task now:

image-20240830173048479

Now try putting this file:

image-20240830180636766

Translate to English and write to another file:

image-20240830174100940

View Effect:

image-20240830174157728

Omit automatically...

You can debug to see the process.

The first step is to get the contents of the file first:

image-20240830175134230

Successfully fetched the contents of the file:

image-20240830175207798

The second step went wrong:

image-20240830175246128

I should try again with the Qwen/Qwen2-72B-Instruct provided by Silicon Flow:

image-20240830175603881

That's right now.

Successfully obtained translation results:

image-20240830175648519

The third step is to write the result after translation to a file:

image-20240830175745941

has been successfully written:

image-20240830175809502

Step 4: Return the completion message:

image-20240830175845567

image-20240830175910947

View Effect:

image-20240830180006034

If a model returns an error, you can retry it, and if you can't retry it, you can try a different model, and the stronger the model, the higher the chance of success.

Quick Start

GitHub Address:/Ming-jiayou/SimpleTranslationAIAgent

Notice there's a Releases here:

image-20240831114112502

Click on it and there are two zips:

image-20240831114150976

One dependent on the .net8.0-windows framework and one independent.

installed .net8.0-windows framework you can choose the small size of that, I have installed the .net8.0-windows framework on the choice of the small size of that one, click on the download, download and then unzip, as follows:

image-20240831114515700

Now just open appsettings and fill in your API KEY to use it, very easy!

Open the file as shown below:

image-20240831114609377

Once filled in, click to run:

image-20240831114749577

Test if the configuration is successful:

Configuration has been successful, test if Function Calling works:

image-20240831114920726

Function Calling is working fine and you can now start using the Translation AI Agent!

Source Code Build Guide

After git clone to local, it looks like this:

image-20240830160422435

Open the file as shown below:

image-20240830160550389

Wisdom Spectrum AI glm-4-flash is free, take this LLM as an example, after filling in the API KEY, change the name of the file to or create a new one, and copy the contents of the file into it:

image-20240830162839622

IDE:vs2022

.net version: .net 8

Open the solution:

image-20240830162920242

The runtime reports an error:

image-20240830163038688

 

Right-click the file, click Properties, and change to Embedded Resources:

image-20240830163211284

Run it again and verify via dialog that the configuration was successful:

image-20240830164734788

Configuration has been successful, test if Function Calling works:

image-20240830164818771

Function Calling is working fine and you can now start using the Translation AI Agent!