Text Gen (LLM)

Example

Let’s build a really dumb chat bot that responds to the last message sent using text_gen (LLM).

Warning

Make sure you understand how to create a bot from Hello World tutorial

main.py

from ugly_bot import *

@export("message_direct")
def text_gen_example(message):
    text = text_gen(
        model=TextGenModel.TOGETHER_META_LLAMA_3_8B,
        question=f"Explain {message.text} to me"
    )
    message_send(text=text)

start()

Note

When a user writes a message, Ugly will check if the bot has exported a “message_direct” function. If so, it will pass the message into that function. The bot will then send the text of the message to text_gen to run AI. The AI will return a string which is then sent back into the conversation.

Glossary