undreamai/LLMUnity

Setting Up And Using ChatML By Myself

TKTSWalker opened this issue · 6 comments

Describe the feature

I want to have my AI work in a specific way but want to use my own ChatML templates I made! I saw using ChatML was possible but i'm not sure if it's already possible to use your own ChatML files! Is it also possible to import new ChatML files while the AI is running?

Hi, yes you can use your own prompt using the Complete function in the same way as the Chat.
The Complete function passes the prompt to the LLM without any additional formatting.

The stopwords are set based on the template selected.
You can add more if you need by doing llm.stop.Add("stopword")

Ah no you have to provide it via code:
llm.Complete("my prompt", HandleReply, ReplyCompleted);
You can see how to use HandleReply and ReplyCompleted in the readme.

The (system) prompt in the box is not used for completion. You would have to format and prepare the prompt how you want it.

I'm closing the issue, feel free to reopen if you have more questions!

Thank you for your help! I did a bit of work and got a mechanism that packs the tracking info! Here is the code (I will open source it all and link this project once done)

` public void LoadAI(AI AI)
{

   string TrainingSet = default;

   //To create the AI, we first take all the basic training data from SARCHOPAGUS 

   TrainingSet = TrainingSet + LoadSarchopagus();

   //Now we take the ChatML folder if it exists

   string FolderToCheck = SaveLocation + @"/AIs" + "/" + AI.AITruename + "/ChatML";

   //Let's check if the directory exists

   if (Directory.Exists(FolderToCheck))
   {
       //We get each txt file (Which we assume is ChatML) and add it
       string[] txtFiles = Directory.GetFiles(FolderToCheck, "*.txt");

       //First do txt files exist
       if (txtFiles.Length > 0 )
       {
           //We remove the final ] on the string

           //Now we add the files to the TrainingSet

           foreach (string item in txtFiles)
           {
               //We get the text 
               TrainingSet = TrainingSet + File.ReadAllText(item);

           }

       }
       
   }

   //Now to load
   Driver.Complete(TrainingSet, HandleReply, LoadedAI);

}`

HandleReply and LoadedAI does nothing yet but the HandleReply will be ignored for loading and LoadedAI will allow inputs to be tused by used by changing a boolean (Else it checks if it is still being loaded and if it isn't it starts the process)

Does this look right to you?

I also forgot to add the part so a ] is added to the end but let's ignore that for now :)