File size: 2,143 Bytes
f4e7deb
 
 
 
4591281
 
 
 
 
0bd54fb
4591281
f4e7deb
4591281
 
f4e7deb
 
4591281
 
 
f4e7deb
 
4591281
 
 
f4e7deb
4591281
f4e7deb
4591281
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cd049f4
f4e7deb
4591281
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import os
import json
from openai import OpenAI

# 1. Environment variables exactly as required
API_BASE_URL = os.getenv("API_BASE_URL", "https://api.openai.com/v1") 
MODEL_NAME = os.getenv("MODEL_NAME", "gpt-3.5-turbo")
HF_TOKEN = os.getenv("HF_TOKEN")
LOCAL_IMAGE_NAME = os.getenv("LOCAL_IMAGE_NAME") # Optional per checklist

# 2. OpenAI client configured via variables
client = OpenAI(
    base_url=API_BASE_URL,
    api_key=HF_TOKEN
)

def run_datacenter_agent(input_data):
    # 3. MUST BE THE VERY FIRST PRINT
    print("START")
    
    try:
        # Every single action must start with "STEP: "
        print("STEP: Agent initialized. Parsing datacenter metrics...")
        print(f"STEP: Input metrics received: {json.dumps(input_data)}")
        
        print(f"STEP: Connecting to LLM ({MODEL_NAME}) for cooling optimization analysis...")
        
        # Replace this prompt with your actual Hackathon prompt/logic
        response = client.chat.completions.create(
            model=MODEL_NAME,
            messages=[
                {"role": "system", "content": "You are a Datacenter Cooling AI. Analyze the metrics and suggest optimal fan speeds and temperature adjustments. Return ONLY concise adjustments."},
                {"role": "user", "content": str(input_data)}
            ]
        )
        
        agent_result = response.choices[0].message.content
        print(f"STEP: LLM Analysis complete. Proposed adjustments: {agent_result}")
        
        print("STEP: Applying cooling adjustments to simulated environment...")
        # (Insert any math or final logic here)
        
    except Exception as e:
        print(f"STEP: ERROR ENCOUNTERED - {str(e)}")
        
    finally:
        # 4. MUST BE THE VERY LAST PRINT
        print("END")

if __name__ == "__main__":
    # The evaluator will execute this file directly. 
    # This dummy data is just so the script runs without crashing if executed manually.
    dummy_input = {
        "server_load_cpu": 85,
        "server_load_gpu": 92,
        "ambient_temp_celsius": 34.5,
        "humidity_percent": 45
    }
    run_datacenter_agent(dummy_input)