Update docs to Plano (#639)

This commit is contained in:
Salman Paracha 2025-12-23 17:14:50 -08:00 committed by GitHub
parent 15fbb6c3af
commit e224cba3e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
139 changed files with 4407 additions and 24735 deletions

View file

@ -0,0 +1,59 @@
version: v0.1
listener:
address: 127.0.0.1
port: 8080 #If you configure port 443, you'll need to update the listener with tls_certificates
message_format: huggingface
# Centralized way to manage LLMs, manage keys, retry logic, failover and limits in a central way
llm_providers:
- name: OpenAI
provider: openai
access_key: $OPENAI_API_KEY
model: gpt-3.5-turbo
default: true
# 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.
prompt_targets:
- name: network_qa
endpoint:
name: app_server
path: /agent/network_summary
description: Handle general Q/A related to networking.
default: true
- 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: device_summary
description: Retrieve statistics for specific devices within a time range
endpoint:
name: app_server
path: /agent/device_summary
parameters:
- name: device_ids
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
type: int
description: Time range in days for which to gather device statistics. Defaults to 7.
default: 7
# Arch creates a round-robin load balancing between different endpoints, managed via the cluster subsystem.
endpoints:
app_server:
# value could be ip address or a hostname with port
# this could also be a list of endpoints for load balancing
# for example endpoint: [ ip1:port, ip2:port ]
endpoint: host.docker.internal:18083
# max time to wait for a connection to be established
connect_timeout: 0.005s

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

View file

@ -0,0 +1,44 @@
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route("/agent/device_summary", methods=["POST"])
def get_device_summary():
"""
Endpoint to retrieve device statistics based on device IDs and an optional time range.
"""
data = request.get_json()
# Validate 'device_ids' parameter
device_ids = data.get("device_ids")
if not device_ids or not isinstance(device_ids, list):
return (
jsonify({"error": "'device_ids' parameter is required and must be a list"}),
400,
)
# Validate 'time_range' parameter (optional, defaults to 7)
time_range = data.get("time_range", 7)
if not isinstance(time_range, int):
return jsonify({"error": "'time_range' must be an integer"}), 400
# Simulate retrieving statistics for the given device IDs and time range
# In a real application, you would query your database or external service here
statistics = []
for device_id in device_ids:
# Placeholder for actual data retrieval
stats = {
"device_id": device_id,
"time_range": f"Last {time_range} days",
"data": f"Statistics data for device {device_id} over the last {time_range} days.",
}
statistics.append(stats)
response = {"statistics": statistics}
return jsonify(response), 200
if __name__ == "__main__":
app.run(debug=True)

View file

@ -0,0 +1,39 @@
import os
import gradio as gr
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from typing import Optional
from openai import OpenAI
from common import create_gradio_app
app = FastAPI()
# Define the request model
class EnergySourceRequest(BaseModel):
energy_source: str
consideration: Optional[str] = None
class EnergySourceResponse(BaseModel):
energy_source: str
consideration: Optional[str] = None
# Post method for device summary
@app.post("/agent/energy_source_info")
def get_workforce(request: EnergySourceRequest):
"""
Endpoint to get details about energy source
"""
considertion = "You don't have any specific consideration. Feel free to talk in a more open ended fashion"
if request.consideration is not None:
considertion = f"Add specific focus on the following consideration when you summarize the content for the energy source: {request.consideration}"
response = {
"energy_source": request.energy_source,
"consideration": considertion,
}
return response

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 KiB

View file

@ -0,0 +1,35 @@
version: v0.1
listener:
address: 127.0.0.1
port: 8080 #If you configure port 443, you'll need to update the listener with tls_certificates
message_format: huggingface
# Centralized way to manage LLMs, manage keys, retry logic, failover and limits in a central way
llm_providers:
- name: OpenAI
provider: openai
access_key: $OPENAI_API_KEY
model: gpt-3.5-turbo
default: true
# default system prompt used by all prompt targets
system_prompt: |
You are a helpful assistant and can offer information about energy sources. You will get a JSON object with energy_source and consideration fields. Focus on answering using those fields
prompt_targets:
- name: get_info_for_energy_source
description: get information about an energy source
parameters:
- name: energy_source
type: str
description: a source of energy
required: true
enum: [renewable, fossil]
- name: consideration
type: str
description: a specific type of consideration for an energy source
enum: [cost, economic, technology]
endpoint:
name: rag_energy_source_agent
path: /agent/energy_source_info
http_method: POST

View file

@ -0,0 +1,44 @@
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route("/agent/device_summary", methods=["POST"])
def get_device_summary():
"""
Endpoint to retrieve device statistics based on device IDs and an optional time range.
"""
data = request.get_json()
# Validate 'device_ids' parameter
device_ids = data.get("device_ids")
if not device_ids or not isinstance(device_ids, list):
return (
jsonify({"error": "'device_ids' parameter is required and must be a list"}),
400,
)
# Validate 'time_range' parameter (optional, defaults to 7)
time_range = data.get("time_range", 7)
if not isinstance(time_range, int):
return jsonify({"error": "'time_range' must be an integer"}), 400
# Simulate retrieving statistics for the given device IDs and time range
# In a real application, you would query your database or external service here
statistics = []
for device_id in device_ids:
# Placeholder for actual data retrieval
stats = {
"device_id": device_id,
"time_range": f"Last {time_range} days",
"data": f"Statistics data for device {device_id} over the last {time_range} days.",
}
statistics.append(stats)
response = {"statistics": statistics}
return jsonify(response), 200
if __name__ == "__main__":
app.run(debug=True)

View file

@ -0,0 +1,15 @@
prompt_targets:
- name: get_device_statistics
description: Retrieve and present the relevant data based on the specified devices and time range
path: /agent/device_summary
parameters:
- name: device_ids
type: list
description: A list of device identifiers (IDs) to reboot.
required: true
- name: time_range
type: int
description: The number of days in the past over which to retrieve device statistics
required: false
default: 7