Homeless With You

Thanks @PromptMOJO ;) for sharing the code of the AI agent, Homeless With You.

Homeless With You is an RPG AI agent integrated with various themes such as casino and crypto. Imagine you lost all your money and became homeless with your girlfriend. Good luck surviving on the streets. Start from finding a shelter and then experiencing getting a work and earning money.

We use the code of this agent as an example to show how to build an advanced AI agent integrated with LLMs and image-generation widgets using the Pro Config mode.

Homeless With You interface

In this tutorial, we break the whole code down into several parts to show how to build an AI agent like Homeless With You using the Pro Config mode on MyShell.

Download the full source code:

Basic Structure

The following example demonstrates the basic structure of an AI agent. Each agent must have a unique identifier (id) and an initial state that defines where the agent begins its execution. In this example:

  • The agent's id is set to HomelessWithYou.

  • The agent's initial state is defined as intro.

The structure also includes inputs, outputs, context, and states, which will be expanded upon later. Below is the code snippet:

Context

In the context field, you can define constants or variables that your agent can reference in its states. These constants or variables allow for reusability and clarity when implementing complex behavior or generating outputs.

Below is an example of a context section as part of an AI agent configuration:

States

This agent contains 53 states totally. The main states are intro, choose_action, input, auto-reply, llm, and image.

Among these main states, the choose_action state contains 9 sub-states, such as comfort, shelter, work, casino, crypto, shop, housing, enter_motorhome, and check_rank. The 9 sub-states correspond to the 9 functions (buttons) in this agent as shown below.

9 sub-states under the main state, choose_action

Here, we omitted the content of each state to show you the structure of all the states.

State: intro

After clicked the Start button, this agent will pop-up a window to let the user enter User Name.

State: choose_action

When you click the certain button (e.g. Coomfort her), this agent will direct you to the related state (e.g. comfort).

State: comfort

There is one task in this state: image generation via Animagine XL 3.1.

module_config breakdown:

  • widget_id: Unique identifier for the widget, here refers to 1787741947264778240 (Animagine XL 3.1)

  • prompt: A string template (likely for generating images) using data from context variables. This agent dynamically constructs the prompt based on the current context (e.g., image properties, character traits).

  • negative_prompt: Defines features to avoid in the output, sourced from context.image_negative_prompt.

  • width & height: Image resolution (1024x1024 pixels).

  • num_inference_steps: Number of steps in the image generation process (28 steps).

  • guidance_scale: Affects how closely the generated image follows the prompt (value: 7).

  • quality_selector & style_selector: Predefined settings for rendering quality and style.

  • seed: Controls randomness in generation (empty, implying random seed).

render breakdown:

  • text: Markdown-like string with placeholders for dynamic content. It includes:

    • An image generated by the task (result.file_url).

    • A motivational message about progress (context.days_survived).

  • buttons: Interactive UI elements. Three buttons, each with:

    • content: Label shown on the button (e.g., "❤️Hug her").

    • description: Tooltip or explanation of the action.

    • on_click: Specifies the transition triggered by clicking the button.

State: hug

outputs breakdown:

  • context.current_reply: Sets a reply message describing the outcome of the action (hugging Piyo).

  • context.days_survived: Increments the days_survived variable by 1.

Last updated