Llm-Chatbot

Llm-Chatbot 1.0.0
GiusTex
​

Features
This plugin let your npcs and characters chat with you, using free local large language models (LLM)s. The plugin is inspired by ChatGPT_APIMZ by Kotonoha. Some code parts are also inspired by Message Plus by Gabe.

How to Use
You can download the demo, or download the files manually following these steps:
- Download the chatbot folder and add it to the root directory of your game;
- download the plugin and add it in js/plugins;
- start the plugin command "Run Windows Server" or "Start Mac Server" (if you are on Mac more dependencies will be automatically downloaded, more infos on my github page).

Plugin Commands
There are 6 plugin commands available:
- Run Windows Server (starts koboldcpp with your desired options directly in-game (only on windows and mac);
- Run Mac Server (starts koboldcpp with your desired options directly in-game (only on windows and mac);
- Custom AI Answer (the character replies to a fixed message in the text box);
- Gab Message (message box that doesn't block the user's commands, so you can keep moving);
- AI Gab Message (the character replies to a fixed message in a message box that doesn't block the user's commands, so he can keep moving);
- Start Dialogue (you can chat with the character/npc and he answers you).

Demo


Download
Info + download links on my github page here, file archive on my github page here.

Terms and Credits
-The plugin can be used only for non commercial use.
-You can use this script in your game projects as long as you give credit
(you can credit GiusTex).
-You are allowed to edit and reuse the code directly as long as it’s for
your own project, extension plugins, or built-in compatibility patches. Don't
delete or change any information about the base plugin.
我试过了,真的很好。你太了不起了!我希望改进两点。首先,AI响应太慢,其次,如果输入对话框可以使用默认对话框会更好。
我试过了,真的很好。你太了不起了!我希望改进两点。首先,AI响应太慢,其次,如果输入对话框可以使用默认对话框会更好。
Thanks for the feedback!
- About the slowness, what gpu do you have? And if you are on mac, did you try different gpu layer numbers, while if you are on windows did you try different gpu layer numbers + did you set the right cublas numbers (the double numbers "0 0" or "0 1" etc, to tell the code where your gpu is) ?
Should I add a more detailed guide about it?
- About the input, do you mean the game text message, something with that layout?
@beiduo These forums operate in English as a standard language. You may compose a message in any other language you need to for your own benefit but a translation to English is required. This may be accomplished with an online tool if needed. Thank you.
Thanks for the feedback!
- About the slowness, what gpu do you have? And if you are on mac, did you try different gpu layer numbers, while if you are on windows did you try different gpu layer numbers + did you set the right cublas numbers (the double numbers "0 0" or "0 1" etc, to tell the code where your gpu is) ?
Should I add a more detailed guide about it?
- About the input, do you mean the game text message, something with that layout?

I think I can understand your meaning now. The response speed of AI has improved, but it is still not ideal enough.

Yes, what I'm talking about is the game text message. I hope to use it in the future to input and edit text, and even achieve voice input and output. I may have thought too much, but it doesn't seem technically difficult.

In addition, the first line of the NPC's dialog box is blank, and the last line sometimes contains the player's name.

bot.jpg


@beiduo These forums operate in English as a standard language. You may compose a message in any other language you need to for your own benefit but a translation to English is required. This may be accomplished with an online tool if needed. Thank you.

Sorry! My fault. Forgot to turn off the automatic translation function of edge.
I think I can understand your meaning now.
Can you send me a screen of your server terminal? If you are on windows I can check if the right gpu is selected from the screen.
In addition, the first line of the NPC's dialog box is blank, and the last line sometimes contains the player's name.
-I know, sorry. Sometimes the bot gives an empty answer, and I didn't fix it yet. In one of the next releases I'll make the plugin check if the answer is empty and if yes generates the answer again (this will take more time from the player though).
-About the player's name in the last line, did you change the options? If no, I'll check the code again.
what I'm talking about is the game text message. I hope to use it in the future to input and edit text
-I don't think it's possible, but you could change my input window layout and position to look like the game one. You can also look at RPG API MZ, which has a window similiar to your description.
-About editing in the input window, that's not possible with this plugin, for now.
and even achieve voice input and output
Possible, I think, but it requires more python dependencies probably, so I want add it for now.
Can you send me a screen of your server terminal? If you are on windows I can check if the right gpu is selected from the screen.
I am using Windows. The following is a screenshot of the server terminal.
bot.jpg

-About the player's name in the last line, did you change the options? If no, I'll check the code again.
I haven't changed the options.
The following is a screenshot of the server terminal.
-Try setting 27 gpu layers (you now have 24 gpu layers set, and the model have 27), see if it still works.
-How much time does it take to generate a message? If it takes around 4-5 seconds I'd say it's okay, most of the commands are supposed to be used while the player does something else...
I haven't changed the options.
Ok, thanks for the info.
and even achieve voice input and output
Possible, I think, but it requires more python dependencies probably, so I want add it for now.
-About adding voice to the character answer, I said I won't add it for now since it's a free plugin, and I think this is already a big plugin considering it's free.
-Also, generating voice from text (TTS) doesn't always give a quick and good audio, unless I add more big dependencies (I have something in mind), but I started this plugin as a light-weight thing, and keeping adding dependencies would go against it.
-I could do it if more people asked for it or as a paid addition, but it would require tests and time.
-And finally, we must remember that this plugin isn't for anyone, since not everyone has a decent gpu; there are people that could get bored before getting the character answer so adding more features to a plugin for a few people could not be smart
-Try setting 27 gpu layers (you now have 24 gpu layers set, and the model have 27), see if it still works.
Yes, It works. Wonderful!

-How much time does it take to generate a message?
About 5 seconds now.

I fully understand your concerns. The result is not always proportional to the effort. Thank you again for your selfless dedication!
About 5 seconds now.
Good. I don't think it's possible to speed up more the generation, sorry; even in the video on my rtx 2060 the time was similar.
Thank you again for your selfless dedication!
❤

So now all that remains is to fix the name that sometimes appears at the end of the message? The input window similar to the game text message is an aesthetic thing maybe for the future
This robot does not recognize Chinese correctly. Although it can display Chinese characters, the meaning is incomprehensible.
This robot does not recognize Chinese correctly.
You can change the model and try a new one (that understands chinese): search 3b (3b models are lighter and quicker) ggml or gguf models here or on internet, then put it in the chatbot folder, and write its name when you start the server. This model here it's an example, anyway it understands chinese but it's a 7b model, you have to see if you can run it at a decent speed without much quality loss
Understood, thank you again!
Terms and Credits
-The plugin can be used only for non commercial use.
What would be your conditions to use in a commercial project?

thanks
What would be your conditions to use in a commercial project?
I could add a paid version with the same conditions (but available for commercial use), and maybe add some features suggested by the buyer, if I find them reasonable

Original thread: https://forums.rpgmakerweb.com/threads/llm-chatbot.161951/