pushing to remote

This commit is contained in:
Salman Paracha 2024-10-18 15:07:28 -07:00
parent 5235f27d70
commit 8a233df119
2 changed files with 28 additions and 20 deletions

View file

@ -6,48 +6,55 @@ import re
app = FastAPI() app = FastAPI()
class StaffingType(Enum): class StaffingType(Enum):
CONTRACT = "contract"
FTE = "fte" FTE = "fte"
AGENCY = "agency" AGENCY = "agency"
CONTRACT = "contract"
class RegionType(Enum):
ASIA = "asia"
EUROPE = "europe"
AMERICAS = "americas"
# Define the request model # Define the request model
class HeadcountRequest(BaseModel): class HeadcountRequest(BaseModel):
region: str region: RegionType
staffing_type: str staffing_type: str
class HeadcountResponseSummary(BaseModel): class HeadcountResponseSummary(BaseModel):
region: str region: str
headcount: int headcount: int
staffing_type: str staffing_type: str
HEADCOUNT = {
ASIA: {CONTRACT: 100, FTE: 150, AGENCY: 2000},
EUROPE: {CONTRACT: 80, FTE: 120, AGENCY: 2500},
AMERICAS: {CONTRACT: 90, FTE: 200, AGENCY: 3000},
}
# Post method for device summary # Post method for device summary
@app.post("/agent/headcount") @app.post("/agent/headcount")
def get_headcount(request: HeadcountRequest): def get_headcount(request: HeadcountRequest):
""" """
Endpoint to headcount data by region, staffing type over time range Endpoint to headcount data by region, staffing type over time range
""" """
staffing_type_value = request.staffing_type headcount = HEADCOUNT[request.region][request.staffing_type]
if re.match(r"(?i)contract", staffing_type_value): # Case-insensitive regex match
headcount = 500
elif re.match(r"(?i)fte", staffing_type_value):
headcount = 1000
elif re.match(r"(?i)agency", staffing_type_value):
headcount = 4000
else:
raise HTTPException(
status_code=400, detail="staffing_type parameter is invalid."
)
response = { response = {
"region": request.region, "region": request.region.value,
"staffing_type": f"Staffing agency: {staffing_type_value}", "staffing_type": f"Staffing agency: {staffing_type}",
"headcount" : f"Headcount: {headcount}" "headcount": f"Headcount: {headcount}",
} }
return response return response
@app.post("/agent/hr_qa") @app.post("/agent/hr_qa")
async def general_hr_qa(): async def general_hr_qa():
""" """
@ -69,5 +76,6 @@ async def general_hr_qa():
"usage": {"completion_tokens": 0}, "usage": {"completion_tokens": 0},
} }
if __name__ == "__main__": if __name__ == "__main__":
app.run(debug=True) app.run(debug=True)

View file

@ -22,14 +22,14 @@ start_demo() {
archgw up arch_config.yaml archgw up arch_config.yaml
# Step 4: Start Network Agent # Step 4: Start Network Agent
echo "Starting Network Agent using Docker Compose..." echo "Starting HR Agent using Docker Compose..."
docker compose up -d # Run in detached mode docker compose up -d # Run in detached mode
} }
# Function to stop the demo # Function to stop the demo
stop_demo() { stop_demo() {
# Step 1: Stop Docker Compose services # Step 1: Stop Docker Compose services
echo "Stopping Network Agent using Docker Compose..." echo "Stopping HR Agent using Docker Compose..."
docker compose down docker compose down
# Step 2: Stop Arch # Step 2: Stop Arch