Merge branch 'main' into adil/release_0.1.0

This commit is contained in:
Adil Hafeez 2024-10-30 18:38:35 -07:00
commit d7464782b4
10 changed files with 51 additions and 73 deletions

View file

@ -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/ 3. Navigate to http://localhost:18080/
4. "Can you give me workforce data for asia?" 4. "Can you give me workforce data for asia?"
![alt text](image.png)

View file

@ -37,7 +37,7 @@ prompt_targets:
parameters: parameters:
- name: staffing_type - name: staffing_type
type: str 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 required: true
- name: region - name: region
type: str type: str

Binary file not shown.

Before

Width:  |  Height:  |  Size: 456 KiB

After

Width:  |  Height:  |  Size: 549 KiB

Before After
Before After

View file

@ -39,4 +39,4 @@ Arch gateway publishes stats endpoint at http://localhost:19901/stats. In this d
Here is sample interaction Here is sample interaction
<img width="575" alt="image" src="https://github.com/user-attachments/assets/25d40f46-616e-41ea-be8e-1623055c84ec"> ![alt text](image.png)

View file

@ -14,30 +14,11 @@ llm_providers:
# default system prompt used by all prompt targets # default system prompt used by all prompt targets
system_prompt: | 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: 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 - 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: endpoint:
name: app_server name: app_server
path: /agent/device_summary path: /agent/device_summary
@ -46,9 +27,23 @@ prompt_targets:
type: list type: list
description: A list of device identifiers (IDs) to retrieve statistics for. description: A list of device identifiers (IDs) to retrieve statistics for.
required: true # device_ids are required to get device statistics required: true # device_ids are required to get device statistics
- name: time_range - name: days
type: int 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" default: "7"
# Arch creates a round-robin load balancing between different endpoints, managed via the cluster subsystem. # 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 endpoint: host.docker.internal:18083
# max time to wait for a connection to be established # max time to wait for a connection to be established
connect_timeout: 0.005s connect_timeout: 0.005s
ratelimits:
- model: gpt-4
selector:
key: selector-key
value: selector-value
limit:
tokens: 1
unit: minute

View file

@ -2,24 +2,14 @@ services:
api_server: api_server:
build: build:
context: . 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: ports:
- "18083:80" - "18083:80"
healthcheck: healthcheck:
test: ["CMD", "curl" ,"http://localhost:80/healthz"] test: ["CMD", "curl" ,"http://localhost:80/healthz"]
interval: 5s interval: 5s
retries: 20 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 KiB

View file

@ -1,8 +1,15 @@
from openai import OpenAI
from fastapi import FastAPI, HTTPException from fastapi import FastAPI, HTTPException
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
from typing import List, Optional from typing import List, Optional
from common import create_gradio_app
import gradio as gr
import os
app = FastAPI() 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 # Define the request model
@ -88,27 +95,15 @@ def get_device_summary(request: DeviceSummaryRequest):
return DeviceSummaryResponse(statistics=statistics) return DeviceSummaryResponse(statistics=statistics)
@app.post("/agent/network_summary") CHAT_COMPLETION_ENDPOINT = os.getenv("CHAT_COMPLETION_ENDPOINT")
async def policy_qa(): client = OpenAI(
""" api_key="--",
This method handles Q/A related to general issues in networks. base_url=CHAT_COMPLETION_ENDPOINT,
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},
}
gr.mount_gradio_app(
app, create_gradio_app(demo_description, client), path="/agent/chat"
)
if __name__ == "__main__": if __name__ == "__main__":
app.run(debug=True) app.run(debug=True)

View file

@ -2,3 +2,12 @@ fastapi
uvicorn uvicorn
pydantic pydantic
typing 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

View file

@ -15,11 +15,11 @@ log = logging.getLogger(__name__)
GRADIO_CSS_STYLE = """ GRADIO_CSS_STYLE = """
.json-container { .json-container {
height: 95vh !important; height: 80vh !important;
overflow-y: auto !important; overflow-y: auto !important;
} }
.chatbot { .chatbot {
height: calc(95vh - 100px) !important; height: calc(80vh - 100px) !important;
overflow-y: auto !important; overflow-y: auto !important;
} }
footer {visibility: hidden} footer {visibility: hidden}