diff --git a/demos/hr_agent/README.md b/demos/hr_agent/README.md index cdc74d77..37986f21 100644 --- a/demos/hr_agent/README.md +++ b/demos/hr_agent/README.md @@ -27,5 +27,3 @@ This demo showcases how the **Arch** can be used to build an HR agent to manage ``` 3. Navigate to http://localhost:18080/ 4. "Can you give me workforce data for asia?" - -![alt text](image.png) diff --git a/demos/hr_agent/arch_config.yaml b/demos/hr_agent/arch_config.yaml index 429a4e84..c2c5fdca 100644 --- a/demos/hr_agent/arch_config.yaml +++ b/demos/hr_agent/arch_config.yaml @@ -37,7 +37,7 @@ prompt_targets: parameters: - name: staffing_type type: str - description: Staffing type like contract, fte or agency + description: specific category or nature of employment used by an organization like fte, contract and agency required: true - name: region type: str diff --git a/demos/hr_agent/image.png b/demos/hr_agent/image.png index e36855b2..e9ab580f 100644 Binary files a/demos/hr_agent/image.png and b/demos/hr_agent/image.png differ diff --git a/demos/network_agent/README.md b/demos/network_agent/README.md index 2b019462..32816135 100644 --- a/demos/network_agent/README.md +++ b/demos/network_agent/README.md @@ -39,4 +39,4 @@ Arch gateway publishes stats endpoint at http://localhost:19901/stats. In this d Here is sample interaction -image +![alt text](image.png) diff --git a/demos/network_agent/arch_config.yaml b/demos/network_agent/arch_config.yaml index a684f4ef..e2945e9a 100644 --- a/demos/network_agent/arch_config.yaml +++ b/demos/network_agent/arch_config.yaml @@ -14,30 +14,11 @@ llm_providers: # default system prompt used by all prompt targets system_prompt: | - You are a network assistant that just offers facts; not advice on manufacturers or purchasing decisions. + You are a network assistant that helps operators with a better understanding of network traffic flow and perform actions on networking operations. No advice on manufacturers or purchasing decisions. prompt_targets: - - name: reboot_devices - description: Reboot specific devices or device groups - endpoint: - name: app_server - path: /agent/device_reboot - parameters: - - name: device_ids - type: list - description: A list of device identifiers (IDs) to reboot. - required: true - - name: time_range - type: int - description: Optional time range in days for reboot operations. Defaults to 7. - - name: network_qa - endpoint: - name: app_server - path: /agent/network_summary - description: Handle general Q/A related to networking. - default: true - name: device_summary - description: Retrieve statistics for specific devices within a time range + description: Retrieve network statistics for specific devices within a time range endpoint: name: app_server path: /agent/device_summary @@ -46,9 +27,23 @@ prompt_targets: type: list description: A list of device identifiers (IDs) to retrieve statistics for. required: true # device_ids are required to get device statistics - - name: time_range + - name: days type: int - description: Time range in days for which to gather device statistics. Defaults to 7. + description: The number of days for which to gather device statistics. + default: "7" + - name: reboot_devices + description: Reboot a list of devices + endpoint: + name: app_server + path: /agent/device_reboot + parameters: + - name: device_ids + type: list + description: A list of device identifiers (IDs). + required: true + - name: days + type: int + description: A list of device identifiers (IDs) default: "7" # Arch creates a round-robin load balancing between different endpoints, managed via the cluster subsystem. @@ -60,12 +55,3 @@ endpoints: endpoint: host.docker.internal:18083 # max time to wait for a connection to be established connect_timeout: 0.005s - -ratelimits: - - model: gpt-4 - selector: - key: selector-key - value: selector-value - limit: - tokens: 1 - unit: minute diff --git a/demos/network_agent/docker-compose.yaml b/demos/network_agent/docker-compose.yaml index d04b55cc..21109840 100644 --- a/demos/network_agent/docker-compose.yaml +++ b/demos/network_agent/docker-compose.yaml @@ -2,24 +2,14 @@ services: api_server: build: context: . - dockerfile: Dockerfile + environment: + - CHAT_COMPLETION_ENDPOINT=http://host.docker.internal:10000/v1 + volumes: + - ./arch_config.yaml:/app/arch_config.yaml + - ../shared/chatbot_ui/common.py:/app/common.py ports: - "18083:80" healthcheck: test: ["CMD", "curl" ,"http://localhost:80/healthz"] interval: 5s retries: 20 - - chatbot_ui: - build: - context: ../shared/chatbot_ui - dockerfile: Dockerfile - ports: - - "18080:8080" - environment: - - OPENAI_API_KEY=${OPENAI_API_KEY:?error} - - CHAT_COMPLETION_ENDPOINT=http://host.docker.internal:10000/v1 - extra_hosts: - - "host.docker.internal:host-gateway" - volumes: - - ./arch_config.yaml:/app/arch_config.yaml diff --git a/demos/network_agent/image.png b/demos/network_agent/image.png new file mode 100644 index 00000000..dc0926bd Binary files /dev/null and b/demos/network_agent/image.png differ diff --git a/demos/network_agent/main.py b/demos/network_agent/main.py index 0f9a6ee0..746353b7 100644 --- a/demos/network_agent/main.py +++ b/demos/network_agent/main.py @@ -1,8 +1,15 @@ +from openai import OpenAI from fastapi import FastAPI, HTTPException from pydantic import BaseModel, Field from typing import List, Optional +from common import create_gradio_app +import gradio as gr +import os + app = FastAPI() +demo_description = """This demo illustrates how **Arch** can be used to perform function calling with network-related tasks. +In this demo, you act as a **network assistant** that provides factual information, without offering advice on manufacturers or purchasing decisions.""" # Define the request model @@ -88,27 +95,15 @@ def get_device_summary(request: DeviceSummaryRequest): return DeviceSummaryResponse(statistics=statistics) -@app.post("/agent/network_summary") -async def policy_qa(): - """ - This method handles Q/A related to general issues in networks. - It forwards the conversation to the OpenAI client via a local proxy and returns the response. - """ - return { - "choices": [ - { - "message": { - "role": "assistant", - "content": "I am a helpful networking agent, and I can help you get status for network devices or reboot them", - }, - "finish_reason": "completed", - "index": 0, - } - ], - "model": "network_agent", - "usage": {"completion_tokens": 0}, - } +CHAT_COMPLETION_ENDPOINT = os.getenv("CHAT_COMPLETION_ENDPOINT") +client = OpenAI( + api_key="--", + base_url=CHAT_COMPLETION_ENDPOINT, +) +gr.mount_gradio_app( + app, create_gradio_app(demo_description, client), path="/agent/chat" +) if __name__ == "__main__": app.run(debug=True) diff --git a/demos/network_agent/requirements.txt b/demos/network_agent/requirements.txt index 77e7584c..8aa2003a 100644 --- a/demos/network_agent/requirements.txt +++ b/demos/network_agent/requirements.txt @@ -2,3 +2,12 @@ fastapi uvicorn pydantic typing +pandas +gradio==5.3.0 +async_timeout==4.0.3 +loguru==0.7.2 +asyncio==3.4.3 +httpx==0.27.0 +python-dotenv==1.0.1 +pydantic==2.8.2 +openai==1.51.0 diff --git a/demos/shared/chatbot_ui/common.py b/demos/shared/chatbot_ui/common.py index 4401e266..27838397 100644 --- a/demos/shared/chatbot_ui/common.py +++ b/demos/shared/chatbot_ui/common.py @@ -15,11 +15,11 @@ log = logging.getLogger(__name__) GRADIO_CSS_STYLE = """ .json-container { - height: 95vh !important; + height: 80vh !important; overflow-y: auto !important; } .chatbot { - height: calc(95vh - 100px) !important; + height: calc(80vh - 100px) !important; overflow-y: auto !important; } footer {visibility: hidden}