Skip to content

Outfit Recommendation with Switch Example

This example demonstrates how to use the framework for outfit recommendation tasks with switch_case functionality. The example code can be found in the examples/step2_outfit_with_switch directory.

   cd examples/step2_outfit_with_switch

Overview

This example implements an outfit recommendation workflow that uses switch-case functionality to conditionally include weather information in the recommendation process. The workflow consists of the following key components:

  1. Input Interface
  2. Handles user input containing clothing requests and image data
  3. Processes and caches any uploaded images
  4. Extracts the user's outfit request instructions

  5. Weather Decision Logic

  6. WeatherDecider: Analyzes the user's request to determine if weather information is needed
  7. Makes a binary decision (0 or 1) based on context in the user's request
  8. Controls whether weather data should be fetched

  9. Conditional Weather Search

  10. WeatherSearcher: Only executes if WeatherDecider returns 0 (weather info needed)
  11. Uses web search functionality to fetch current weather conditions
  12. Integrates weather data into the recommendation context

  13. Outfit Recommendation

  14. Generates final clothing suggestions based on:
    • User's original request
    • Weather information (if available)
    • Any provided image context
  15. Provides complete outfit recommendations

The workflow follows this sequence:

Prerequisites

  • Python 3.10+
  • Required packages installed (see requirements.txt)
  • Access to OpenAI API or compatible endpoint (see configs/llms/gpt.yml)
  • Access to Bing API key for web search functionality to search real-time weather information for outfit recommendations (see configs/tools/websearch.yml)
  • Redis server running locally or remotely
  • Conductor server running locally or remotely

Configuration

The container.yaml file is a configuration file that manages dependencies and settings for different components of the system, including Conductor connections, Redis connections, and other service configurations. To set up your configuration:

  1. Generate the container.yaml file: bash python compile_container.py This will create a container.yaml file with default settings under examples/step2_outfit_with_switch.

  2. Configure your LLM settings in configs/llms/gpt.yml and configs/llms/text_res.yml:

  3. Set your OpenAI API key or compatible endpoint through environment variable or by directly modifying the yml file bash export custom_openai_key="your_openai_api_key" export custom_openai_endpoint="your_openai_endpoint"

  4. Configure other model settings like temperature as needed through environment variable or by directly modifying the yml file

  5. Configure your Bing Search API key in configs/tools/websearch.yml:

  6. Set your Bing API key through environment variable or by directly modifying the yml file bash export bing_api_key="your_bing_api_key"

  7. Update settings in the generated container.yaml:

  8. Modify Redis connection settings:
    • Set the host, port and credentials for your Redis instance
    • Configure both redis_stream_client and redis_stm_client sections
  9. Update the Conductor server URL under conductor_config section
  10. Adjust any other component settings as needed

Running the Example

  1. Run the outfit recommendation with switch example:

For terminal/CLI usage: bash python run_cli.py

For app/GUI usage: bash python run_app.py

Troubleshooting

If you encounter issues:

  • Verify Conductor and Redis are running and accessible
  • Check your OpenAI API key and Bing API key are valid
  • Check Redis Stream client and Redis STM client configuration

  • Ensure all dependencies are installed correctly

  • Review logs for any error messages

Building the Example

Coming soon! This section will provide detailed instructions for building the step2_outfit_with_switch example step by step.