diff --git a/demos/samples_python/network_switch_operator_agent/arch_config.yaml b/demos/samples_python/network_switch_operator_agent/arch_config.yaml index 40d529a2..fa830d0b 100644 --- a/demos/samples_python/network_switch_operator_agent/arch_config.yaml +++ b/demos/samples_python/network_switch_operator_agent/arch_config.yaml @@ -11,7 +11,7 @@ llm_providers: - name: OpenAI provider_interface: openai access_key: $OPENAI_API_KEY - model: gpt-3.5-turbo + model: gpt-4o default: true # default system prompt used by all prompt targets @@ -26,25 +26,26 @@ prompt_targets: path: /agent/device_summary http_method: POST parameters: - - name: device_ids - type: list - description: A list of device identifiers (IDs) to retrieve statistics for. + - name: device_id + type: str + description: A device identifier to retrieve statistics for. required: true # device_ids are required to get device statistics - name: days type: int description: The number of days for which to gather device statistics. - default: "7" - - name: reboot_devices - description: Reboot a list of devices + default: 7 + - name: reboot_device + description: Reboot a device endpoint: name: app_server path: /agent/device_reboot http_method: POST parameters: - - name: device_ids - type: list - description: A list of device identifiers (IDs). + - name: device_id + type: str + description: the device identifier required: true + system_prompt: You will get a status JSON object. Simply summarize it # Arch creates a round-robin load balancing between different endpoints, managed via the cluster subsystem. endpoints: @@ -55,3 +56,8 @@ endpoints: endpoint: host.docker.internal:18083 # max time to wait for a connection to be established connect_timeout: 0.005s + + +tracing: + random_sampling: 100 + trace_arch_internal: true diff --git a/demos/samples_python/network_switch_operator_agent/docker-compose.yaml b/demos/samples_python/network_switch_operator_agent/docker-compose.yaml index 90b5c084..237afa4f 100644 --- a/demos/samples_python/network_switch_operator_agent/docker-compose.yaml +++ b/demos/samples_python/network_switch_operator_agent/docker-compose.yaml @@ -18,3 +18,11 @@ services: - "host.docker.internal:host-gateway" volumes: - ./arch_config.yaml:/app/arch_config.yaml + + jaeger: + build: + context: ../../shared/jaeger + ports: + - "16686:16686" + - "4317:4317" + - "4318:4318" diff --git a/demos/samples_python/network_switch_operator_agent/main.py b/demos/samples_python/network_switch_operator_agent/main.py index b9676c45..a7a07ab4 100644 --- a/demos/samples_python/network_switch_operator_agent/main.py +++ b/demos/samples_python/network_switch_operator_agent/main.py @@ -13,7 +13,7 @@ DEMO_DESCRIPTION = """This demo illustrates how **Arch** can be used to perform # Define the request model class DeviceSummaryRequest(BaseModel): - device_ids: List[int] + device_id: str time_range: Optional[int] = Field( default=7, description="Time range in days, defaults to 7" ) @@ -21,7 +21,7 @@ class DeviceSummaryRequest(BaseModel): # Define the response model class DeviceStatistics(BaseModel): - device_id: int + device_id: str time_range: str data: str @@ -33,7 +33,7 @@ class DeviceSummaryResponse(BaseModel): class DeviceRebootRequest(BaseModel): - device_ids: List[int] + device_id: str # Response model for the device reboot @@ -49,24 +49,21 @@ def reboot_network_device(request_data: DeviceRebootRequest): """ # Access data from the Pydantic model - device_ids = request_data.device_ids + device_id = request_data.device_id - # Validate 'device_ids' + # Validate 'device_id' # (This is already validated by Pydantic, but additional logic can be added if needed) - if not device_ids: - raise HTTPException( - status_code=400, detail="'device_ids' parameter is required" - ) + if not device_id: + raise HTTPException(status_code=400, detail="'device_id' parameter is required") # Simulate reboot operation and return the response statistics = [] - for device_id in device_ids: - # Placeholder for actual data retrieval or device reboot logic - stats = {"data": f"Device {device_id} has been successfully rebooted."} - statistics.append(stats) + # Placeholder for actual data retrieval or device reboot logic + stats = {"data": f"Device {device_id} has been successfully rebooted."} + statistics.append(stats) # Return the response with a summary - return CoverageResponse(status="success", summary={"device_ids": device_ids}) + return CoverageResponse(status="success", summary={"device_id": device_id}) # Post method for device summary @@ -76,28 +73,20 @@ def get_device_summary(request: DeviceSummaryRequest): Endpoint to retrieve device statistics based on device IDs and an optional time range. """ - # Extract 'device_ids' and 'time_range' from the request - device_ids = request.device_ids + # Extract 'device_id' and 'time_range' from the request + device_id = request.device_id time_range = request.time_range # Simulate retrieving statistics for the given device IDs and time range statistics = [] - minutes = 1 - for device_id in device_ids: - stats = { - "device_id": device_id, - "time_range": f"Last {time_range} days", - "data": f"""Device {device_id} over the last {time_range} days experienced {minutes} - minutes of downtime.""", - } - minutes += 1 - statistics.append(DeviceStatistics(**stats)) + minutes = 4 + stats = { + "device_id": device_id, + "time_range": f"Last {time_range} days", + "data": f"""Device {device_id} over the last {time_range} days experienced {minutes} + minutes of downtime.""", + } + + statistics.append(DeviceStatistics(**stats)) return DeviceSummaryResponse(statistics=statistics) - - -CHAT_COMPLETION_ENDPOINT = os.getenv("CHAT_COMPLETION_ENDPOINT") -client = OpenAI( - api_key="--", - base_url=CHAT_COMPLETION_ENDPOINT, -) diff --git a/demos/samples_python/network_switch_operator_agent/run_demo.sh b/demos/samples_python/network_switch_operator_agent/run_demo.sh index 6995e7d0..eb47dce6 100644 --- a/demos/samples_python/network_switch_operator_agent/run_demo.sh +++ b/demos/samples_python/network_switch_operator_agent/run_demo.sh @@ -22,9 +22,8 @@ start_demo() { echo "Starting Arch with arch_config.yaml..." archgw up arch_config.yaml - # Step 4: Start Network Agent + # Step 4: Start developer services echo "Starting Network Agent using Docker Compose..." - cd build docker compose up -d # Run in detached mode }