picoflow.io

Lesson 5: Hotel Flow


We will design three complex steps to do the entire flow.

  1. Explore Step
  2. Present Step
  3. Compare Step

Hotel Flow Code

We will create a HotelFlow and add these three steps. It is super easy and clean to configure the steps as follow:

Full flow code:

export class HotelFlow extends Flow {
  public constructor() {
    super(HotelFlow);
  }

  protected defineSteps(): Step[] {
    return [
      new ExploreStep(this, true).setTemperature(0.5),
      new PresentStep(this, false),
      new CompareStep(this, false),
      new EndStep(this).useMemory('end'),
    ];
  }
}

What are these steps?

  1. ExploreStep: Gathers all the information needed from the user to make a hotel booking. This is similar to the details you would enter on a site like hilton.com.
  2. PresentStep: Searches for suitable hotels based on the collected information and presents the options to the user.
  3. CompareStep: Allows the user to compare selected hotels based on price, amenities, and other key attributes.
Important

Granularity of step design: The complexity of each step is fully controllable by the developer. Instead of using a large, monolithic ExploreStep, you can break >the process into many smaller steps, each responsible for collecting a specific piece of information. This approach increases the >reliability of the LLM flow because simpler steps reduce the likelihood of hallucinations.

However, using many small steps comes with a trade-off: without a more sophisticated routing mechanism, the user cannot easily go back and correct information entered in a previous step. In our design, we chose to group all information collection into a single step. This allows more flexible user navigation, at the cost of a slightly higher risk of LLM hallucination—something that can be mitigated with other techniques.

Wrapping up

Next, let's five in the implementation of each step.