cleaning up demos

This commit is contained in:
Salman Paracha 2025-02-07 14:03:59 -08:00
parent ae28ab8612
commit 005ae95383
50 changed files with 178 additions and 35 deletions

View file

@ -1,7 +1,7 @@
services:
chatbot_ui:
build:
context: ../shared/chatbot_ui
context: ../../shared/chatbot_ui
ports:
- "18080:8080"
environment:

View file

@ -8,7 +8,6 @@ services:
- 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:
- "18080:80"
healthcheck:
@ -18,7 +17,7 @@ services:
chatbot_ui:
build:
context: ../shared/chatbot_ui
context: ../../shared/chatbot_ui
dockerfile: Dockerfile
ports:
- "18080:8080"

View file

Before

Width:  |  Height:  |  Size: 549 KiB

After

Width:  |  Height:  |  Size: 549 KiB

Before After
Before After

View file

@ -1,5 +1,5 @@
# Stage 1: Build the application using Maven
FROM maven:3.8.7-openjdk-17 AS build
FROM maven:3.8.7-openjdk-18-slim AS build
WORKDIR /app
# Copy pom.xml and download dependencies first (caching)
COPY pom.xml .
@ -14,5 +14,5 @@ WORKDIR /app
# Copy the built jar from the previous stage
COPY --from=build /app/target/weather-forecast-service-0.0.1-SNAPSHOT.jar app.jar
# Expose the port on which the app runs (default Spring Boot is 8080)
EXPOSE 8080
EXPOSE 8081
ENTRYPOINT ["java", "-jar", "app.jar"]

View file

@ -0,0 +1,45 @@
version: v0.1
listener:
address: 127.0.0.1
port: 10000 #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_interface: openai
access_key: $OPENAI_API_KEY
model: gpt-4o-mini
default: true
# Arch creates a round-robin load balancing between different endpoints, managed via the cluster subsystem.
endpoints:
weather_forecast_service:
# 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:18081
# max time to wait for a connection to be established
connect_timeout: 0.005s
# default system prompt used by all prompt targets
system_prompt: |
You are a helpful weather assistant.
prompt_targets:
- name: weather_forecast
description: get the weather forecast
parameters:
- name: location
description: the location for which to get the weather forecast
required: true
type: string
format: City, State
- name: days
description: the number of days for the forecast
required: true
type: int
endpoint:
name: weather_forecast_service
path: /weather
http_method: POST

View file

@ -0,0 +1,20 @@
services:
weather_forecast_service:
build:
context: .
dockerfile: Dockerfile
ports:
- "18081:8081"
chatbot_ui:
build:
context: ../../../shared/chatbot_ui
dockerfile: Dockerfile
ports:
- "18080:8080"
environment:
- CHAT_COMPLETION_ENDPOINT=http://host.docker.internal:10000/v1
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./arch_config.yaml:/app/arch_config.yaml

View file

@ -4,7 +4,7 @@
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId></groupId>
<groupId>weather</groupId>
<artifactId>weather-forecast-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

View file

@ -1,7 +1,6 @@
package weather.controller;
import weather.model.DayForecast;
import weeather.model.Temperature;
import weather.model.WeatherForecastResponse;
import weather.model.WeatherRequest;
import org.springframework.web.bind.annotation.PostMapping;
@ -20,7 +19,7 @@ public class WeatherController {
private Random random = new Random();
@PostMapping("/weather")
public WeatherForecastResponse getWeather(@RequestBody WeatherRequest req) {
public WeatherForecastResponse getRandomWeatherForecast(@RequestBody WeatherRequest req) {
WeatherForecastResponse response = new WeatherForecastResponse();
response.setLocation(req.getLocation());
response.setUnits(req.getUnits());

View file

@ -5,7 +5,7 @@ import java.util.List;
public class WeatherForecastResponse {
private String location;
private String units;
private List<DayForecast> temperature;
private List<DayForecast> forecast;
// Default Constructor
public WeatherForecastResponse() {}
@ -28,10 +28,10 @@ public class WeatherForecastResponse {
}
public List<DayForecast> getDailyForecast() {
return temperature;
return forecast;
}
public void setDailyForecas(List<DayForecast> forecast) {
public void setDailyForecast(List<DayForecast> forecast) {
this.forecast = forecast;
}
}

View file

@ -0,0 +1,19 @@
FROM python:3.12 AS base
FROM base AS builder
WORKDIR /src
COPY requirements.txt /src/
RUN pip install --prefix=/runtime --force-reinstall -r requirements.txt
COPY ../. /src
FROM python:3.12-slim AS output
COPY --from=builder /runtime /usr/local
COPY ../. /app
WORKDIR /app
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80", "--log-level", "info"]

View file

@ -0,0 +1,20 @@
services:
api_server:
build:
context: .
dockerfile: Dockerfile
ports:
- "18083:80"
chatbot_ui:
build:
context: ../../shared/chatbot_ui
dockerfile: Dockerfile
ports:
- "18080:8080"
environment:
- CHAT_COMPLETION_ENDPOINT=http://host.docker.internal:10000/v1
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./arch_config.yaml:/app/arch_config.yaml

View file

Before

Width:  |  Height:  |  Size: 636 KiB

After

Width:  |  Height:  |  Size: 636 KiB

Before After
Before After

View file

@ -0,0 +1,13 @@
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

View file

@ -1,7 +1,7 @@
services:
chatbot_ui:
build:
context: ../shared/chatbot_ui
context: ../../shared/chatbot_ui
ports:
- "18080:8080"
environment:

View file

@ -0,0 +1,47 @@
#!/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 developer services
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

View file

Before

Width:  |  Height:  |  Size: 673 KiB

After

Width:  |  Height:  |  Size: 673 KiB

Before After
Before After

View file

@ -11,7 +11,7 @@ services:
chatbot_ui:
build:
context: ../shared/chatbot_ui
context: ../../shared/chatbot_ui
ports:
- "18080:8080"
environment:
@ -19,23 +19,3 @@ services:
- CHAT_COMPLETION_ENDPOINT=http://host.docker.internal:10000/v1
extra_hosts:
- "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"
prometheus:
build:
context: ../shared/prometheus
grafana:
build:
context: ../shared/grafana
ports:
- "3000:3000"

View file

@ -2,7 +2,7 @@ services:
chatbot_ui:
build:
context: ../shared/chatbot_ui
context: ../../shared/chatbot_ui
dockerfile: Dockerfile
ports:
- "18080:8080"

View file

@ -1,7 +1,7 @@
services:
chatbot_ui:
build:
context: ../shared/chatbot_ui
context: ../../shared/chatbot_ui
ports:
- "18080:8080"
environment: