From 25f04ab010d23f8d0e04bbd7475042796178f739 Mon Sep 17 00:00:00 2001 From: aayushwhiz Date: Thu, 5 Dec 2024 13:36:19 -0800 Subject: [PATCH] refactor weather_forecast demo to only be one demo --- ...compose.yaml => docker-compose.jaeger.yml} | 0 .../docker-compose.logfire.yml} | 0 .../docker-compose.signoz.yml} | 0 .../otel-collector/Dockerfile | 0 .../otel-collector/otel-collector-config.yaml | 0 demos/weather_forecast/run_demo.sh | 51 +++++++++--- demos/weather_forecast_logfire/README.md | 27 ------- .../weather_forecast_logfire/arch_config.yaml | 78 ------------------- demos/weather_forecast_logfire/run_demo.sh | 52 ------------- demos/weather_forecast_signoz/README.md | 29 ------- .../weather_forecast_signoz/arch_config.yaml | 72 ----------------- demos/weather_forecast_signoz/run_demo.sh | 47 ----------- 12 files changed, 39 insertions(+), 317 deletions(-) rename demos/weather_forecast/{docker-compose.yaml => docker-compose.jaeger.yml} (100%) rename demos/{weather_forecast_logfire/docker-compose.yaml => weather_forecast/docker-compose.logfire.yml} (100%) rename demos/{weather_forecast_signoz/docker-compose.yaml => weather_forecast/docker-compose.signoz.yml} (100%) rename demos/{weather_forecast_logfire => weather_forecast}/otel-collector/Dockerfile (100%) rename demos/{weather_forecast_logfire => weather_forecast}/otel-collector/otel-collector-config.yaml (100%) delete mode 100644 demos/weather_forecast_logfire/README.md delete mode 100644 demos/weather_forecast_logfire/arch_config.yaml delete mode 100644 demos/weather_forecast_logfire/run_demo.sh delete mode 100644 demos/weather_forecast_signoz/README.md delete mode 100644 demos/weather_forecast_signoz/arch_config.yaml delete mode 100644 demos/weather_forecast_signoz/run_demo.sh diff --git a/demos/weather_forecast/docker-compose.yaml b/demos/weather_forecast/docker-compose.jaeger.yml similarity index 100% rename from demos/weather_forecast/docker-compose.yaml rename to demos/weather_forecast/docker-compose.jaeger.yml diff --git a/demos/weather_forecast_logfire/docker-compose.yaml b/demos/weather_forecast/docker-compose.logfire.yml similarity index 100% rename from demos/weather_forecast_logfire/docker-compose.yaml rename to demos/weather_forecast/docker-compose.logfire.yml diff --git a/demos/weather_forecast_signoz/docker-compose.yaml b/demos/weather_forecast/docker-compose.signoz.yml similarity index 100% rename from demos/weather_forecast_signoz/docker-compose.yaml rename to demos/weather_forecast/docker-compose.signoz.yml diff --git a/demos/weather_forecast_logfire/otel-collector/Dockerfile b/demos/weather_forecast/otel-collector/Dockerfile similarity index 100% rename from demos/weather_forecast_logfire/otel-collector/Dockerfile rename to demos/weather_forecast/otel-collector/Dockerfile diff --git a/demos/weather_forecast_logfire/otel-collector/otel-collector-config.yaml b/demos/weather_forecast/otel-collector/otel-collector-config.yaml similarity index 100% rename from demos/weather_forecast_logfire/otel-collector/otel-collector-config.yaml rename to demos/weather_forecast/otel-collector/otel-collector-config.yaml diff --git a/demos/weather_forecast/run_demo.sh b/demos/weather_forecast/run_demo.sh index e6c678e8..f1c6d921 100644 --- a/demos/weather_forecast/run_demo.sh +++ b/demos/weather_forecast/run_demo.sh @@ -1,13 +1,36 @@ #!/bin/bash set -e +# Directory where the Docker Compose files are stored + +# Function to determine the docker-compose file based on the argument +get_compose_file() { + case "$1" in + jaeger) + echo "docker-compose.jaeger.yml" + ;; + logfire) + echo "docker-compose.logfire.yml" + ;; + signoz) + echo "docker-compose.signoz.yml" + ;; + *) + echo "docker-compose.jaeger.yml" # Default to Jaeger + ;; + esac +} + # Function to start the demo start_demo() { - # Step 1: Check if .env file exists + # Step 1: Determine the docker-compose file + COMPOSE_FILE=$(get_compose_file "$1") + + # Step 2: Check if .env file exists if [ -f ".env" ]; then echo ".env file already exists. Skipping creation." else - # Step 2: Create `.env` file and set OpenAI key + # Step 3: Create `.env` file and set OpenAI key if [ -z "$OPENAI_API_KEY" ]; then echo "Error: OPENAI_API_KEY environment variable is not set for the demo." exit 1 @@ -18,22 +41,26 @@ start_demo() { echo ".env file created with OPENAI_API_KEY." fi - # Step 3: Start Arch + # Step 4: Start Arch echo "Starting Arch with arch_config.yaml..." archgw up arch_config.yaml - # Step 4: Start Network Agent - echo "Starting Network Agent using Docker Compose..." - docker compose up -d # Run in detached mode + # Step 5: Start Network Agent with the chosen Docker Compose file + echo "Starting Network Agent using $COMPOSE_FILE..." + docker compose -f "$COMPOSE_FILE" up -d # Run in detached mode } # Function to stop the demo stop_demo() { - # Step 1: Stop Docker Compose services - echo "Stopping Network Agent using Docker Compose..." - docker compose down + echo "Stopping all Docker Compose services..." - # Step 2: Stop Arch + # Stop all services by iterating through all configurations + for compose_file in ./*.yml; do + echo "Stopping services in $compose_file..." + docker compose -f "$compose_file" down + done + + # Stop Arch echo "Stopping Arch..." archgw down } @@ -42,6 +69,6 @@ stop_demo() { if [ "$1" == "down" ]; then stop_demo else - # Default action is to bring the demo up - start_demo + # Use the argument (jaeger, logfire, signoz) to determine the compose file + start_demo "$1" fi diff --git a/demos/weather_forecast_logfire/README.md b/demos/weather_forecast_logfire/README.md deleted file mode 100644 index 5334d4a5..00000000 --- a/demos/weather_forecast_logfire/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# Function calling -This demo shows how you can use Arch's core function calling capabilites. - -# Starting the demo -1. Please make sure the [pre-requisites](https://github.com/katanemo/arch/?tab=readme-ov-file#prerequisites) are installed correctly -2. Start Arch - -3. - ```sh - sh run_demo.sh - ``` -4. Navigate to http://localhost:18080/ -5. You can type in queries like "how is the weather?" - -# Observability -Arch gateway publishes stats endpoint at http://localhost:19901/stats. In this demo we are using prometheus to pull stats from arch and we are using grafana to visalize the stats in dashboard. To see grafana dashboard follow instructions below, - -1. Start grafana and prometheus using following command - ```yaml - docker compose --profile monitoring up - ``` -1. Navigate to http://localhost:3000/ to open grafana UI (use admin/grafana as credentials) -1. From grafana left nav click on dashboards and select "Intelligent Gateway Overview" to view arch gateway stats - - -Here is a sample interaction, -image diff --git a/demos/weather_forecast_logfire/arch_config.yaml b/demos/weather_forecast_logfire/arch_config.yaml deleted file mode 100644 index 35a3f430..00000000 --- a/demos/weather_forecast_logfire/arch_config.yaml +++ /dev/null @@ -1,78 +0,0 @@ -version: "0.1-beta" - -listener: - address: 0.0.0.0 - port: 10000 - message_format: huggingface - connect_timeout: 0.005s - -endpoints: - weather_forecast_service: - endpoint: host.docker.internal:18083 - connect_timeout: 0.005s - -overrides: - # confidence threshold for prompt target intent matching - prompt_target_intent_matching_threshold: 0.6 - -llm_providers: - - name: gpt-4o-mini - access_key: $OPENAI_API_KEY - provider: openai - model: gpt-4o-mini - default: true - - - name: gpt-3.5-turbo-0125 - access_key: $OPENAI_API_KEY - provider: openai - model: gpt-3.5-turbo-0125 - - - name: gpt-4o - access_key: $OPENAI_API_KEY - provider: openai - model: gpt-4o - -system_prompt: | - You are a helpful assistant. - -prompt_guards: - input_guards: - jailbreak: - on_exception: - message: Looks like you're curious about my abilities, but I can only provide assistance for weather forecasting. - -prompt_targets: - - name: weather_forecast - description: Check weather information for a given city. - parameters: - - name: city - description: the name of the city - required: true - type: str - - name: days - description: the number of days - type: int - required: true - - name: units - description: the temperature unit, e.g., Celsius and Fahrenheit - type: str - default: Fahrenheit - endpoint: - name: weather_forecast_service - path: /weather - - - name: default_target - default: true - description: This is the default target for all unmatched prompts. - endpoint: - name: weather_forecast_service - path: /default_target - system_prompt: | - You are a helpful assistant! Summarize the user's request and provide a helpful response. - # if it is set to false arch will send response that it received from this prompt target to the user - # if true arch will forward the response to the default LLM - auto_llm_dispatch_on_response: false - -tracing: - random_sampling: 100 - trace_arch_internal: true diff --git a/demos/weather_forecast_logfire/run_demo.sh b/demos/weather_forecast_logfire/run_demo.sh deleted file mode 100644 index e2577257..00000000 --- a/demos/weather_forecast_logfire/run_demo.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -set -e - -# Function to start the demo -start_demo() { - # Step 1: Check if .env file exists - if [ -f ".env" ]; then - echo ".env file already exists. Skipping creation." - else - # Step 2: Create `.env` file and set OpenAI key - if [ -z "$OPENAI_API_KEY" ]; then - echo "Error: OPENAI_API_KEY environment variable is not set for the demo." - exit 1 - fi - if [ -z "$LOGFIRE_API_KEY"]; then - echo "Error: LOGFIRE_API_KEY environment variable is not set for the demo." - exit 1 - fi - - echo "Creating .env file..." - echo "OPENAI_API_KEY=$OPENAI_API_KEY" > .env - echo "LOGFIRE_API_KEY=$LOGFIRE_API_KEY" >> .env - echo ".env file created with OPENAI_API_KEY and LOGFIRE_API_KEY." - fi - - # Step 3: Start Arch - echo "Starting Arch with arch_config.yaml..." - archgw up arch_config.yaml - - # Step 4: Start Network Agent - echo "Starting Network Agent using Docker Compose..." - docker compose up -d # Run in detached mode -} - -# Function to stop the demo -stop_demo() { - # Step 1: Stop Docker Compose services - echo "Stopping Network Agent using Docker Compose..." - docker compose down - - # Step 2: Stop Arch - echo "Stopping Arch..." - archgw down -} - -# Main script logic -if [ "$1" == "down" ]; then - stop_demo -else - # Default action is to bring the demo up - start_demo -fi diff --git a/demos/weather_forecast_signoz/README.md b/demos/weather_forecast_signoz/README.md deleted file mode 100644 index d4d9175e..00000000 --- a/demos/weather_forecast_signoz/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# Function calling -This demo shows how you can use Arch's core function calling capabilites. - -# Starting the demo -1. Please make sure the [pre-requisites](https://github.com/katanemo/arch/?tab=readme-ov-file#prerequisites) are installed correctly -2. Start Arch - -3. - ```sh - sh run_demo.sh - ``` -4. Navigate to http://localhost:18080/ -5. You can type in queries like "how is the weather?" - -# Observability -Arch gateway publishes stats endpoint at http://localhost:19901/stats. In this demo we are using prometheus to pull stats from arch and we are using grafana to visalize the stats in dashboard. To see grafana dashboard follow instructions below, - -1. Start grafana and prometheus using following command - ```yaml - docker compose --profile monitoring up - ``` -1. Navigate to http://localhost:3000/ to open grafana UI (use admin/grafana as credentials) -1. From grafana left nav click on dashboards and select "Intelligent Gateway Overview" to view arch gateway stats - - -Here is a sample interaction, -image - -1. Signoz UI: http://localhost:3301 diff --git a/demos/weather_forecast_signoz/arch_config.yaml b/demos/weather_forecast_signoz/arch_config.yaml deleted file mode 100644 index 787a71b3..00000000 --- a/demos/weather_forecast_signoz/arch_config.yaml +++ /dev/null @@ -1,72 +0,0 @@ -version: "0.1-beta" - -listener: - address: 0.0.0.0 - port: 10000 - message_format: huggingface - connect_timeout: 0.005s - -endpoints: - weather_forecast_service: - endpoint: host.docker.internal:18083 - connect_timeout: 0.005s - -overrides: - # confidence threshold for prompt target intent matching - prompt_target_intent_matching_threshold: 0.6 - -llm_providers: - - name: gpt-4o-mini - access_key: $OPENAI_API_KEY - provider: openai - model: gpt-4o-mini - default: true - - - name: gpt-3.5-turbo-0125 - access_key: $OPENAI_API_KEY - provider: openai - model: gpt-3.5-turbo-0125 - - - name: gpt-4o - access_key: $OPENAI_API_KEY - provider: openai - model: gpt-4o - -system_prompt: | - You are a helpful assistant. - -prompt_targets: - - name: weather_forecast - description: Check weather information for a given city. - parameters: - - name: city - description: the name of the city - required: true - type: str - - name: days - description: the number of days - type: int - required: true - - name: units - description: the temperature unit, e.g., Celsius and Fahrenheit - type: str - default: Fahrenheit - endpoint: - name: weather_forecast_service - path: /weather - - - name: default_target - default: true - description: This is the default target for all unmatched prompts. - endpoint: - name: weather_forecast_service - path: /default_target - system_prompt: | - You are a helpful assistant! Summarize the user's request and provide a helpful response. - # if it is set to false arch will send response that it received from this prompt target to the user - # if true arch will forward the response to the default LLM - auto_llm_dispatch_on_response: false - -tracing: - random_sampling: 100 - # trace_arch: true diff --git a/demos/weather_forecast_signoz/run_demo.sh b/demos/weather_forecast_signoz/run_demo.sh deleted file mode 100644 index e6c678e8..00000000 --- a/demos/weather_forecast_signoz/run_demo.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -set -e - -# Function to start the demo -start_demo() { - # Step 1: Check if .env file exists - if [ -f ".env" ]; then - echo ".env file already exists. Skipping creation." - else - # Step 2: Create `.env` file and set OpenAI key - if [ -z "$OPENAI_API_KEY" ]; then - echo "Error: OPENAI_API_KEY environment variable is not set for the demo." - exit 1 - fi - - echo "Creating .env file..." - echo "OPENAI_API_KEY=$OPENAI_API_KEY" > .env - echo ".env file created with OPENAI_API_KEY." - fi - - # Step 3: Start Arch - echo "Starting Arch with arch_config.yaml..." - archgw up arch_config.yaml - - # Step 4: Start Network Agent - echo "Starting Network Agent using Docker Compose..." - docker compose up -d # Run in detached mode -} - -# Function to stop the demo -stop_demo() { - # Step 1: Stop Docker Compose services - echo "Stopping Network Agent using Docker Compose..." - docker compose down - - # Step 2: Stop Arch - echo "Stopping Arch..." - archgw down -} - -# Main script logic -if [ "$1" == "down" ]; then - stop_demo -else - # Default action is to bring the demo up - start_demo -fi