-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathanalyzer.py
More file actions
55 lines (46 loc) · 1.58 KB
/
Copy pathanalyzer.py
File metadata and controls
55 lines (46 loc) · 1.58 KB
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
import os
from openai import OpenAI
# -------------------------------------------------------------------
# Configuration for Colibrì GLM-5.2 local runtime
# Ensure you are running: `./coli serve --host 127.0.0.1 --port 8000 --model-id glm-5.2-colibri`
# -------------------------------------------------------------------
API_BASE_URL = os.getenv("API_BASE_URL", "http://127.0.0.1:8000/v1")
API_KEY = os.getenv("API_KEY", "local-secret")
MODEL_ID = os.getenv("MODEL_ID", "glm-5.2-colibri")
client = OpenAI(
api_key=API_KEY,
base_url=API_BASE_URL,
)
def analyze_logs(log_content: str) -> str:
"""
Sends log content to the local AI model to identify anomalies,
summarize the issue, and propose a solution.
"""
prompt = f"""You are an expert DevOps engineer and system administrator.
Analyze the following application logs.
Please provide your analysis strictly in this Markdown structure:
## 📊 Executive Summary
[A brief 2-3 sentence summary of what happened]
## 🚨 Identified Anomalies
- [Anomaly 1]
- [Anomaly 2]
## 🛠️ Recommended Fixes
1. [Fix 1]
2. [Fix 2]
---
Logs:
{log_content}
"""
try:
response = client.chat.completions.create(
model=MODEL_ID,
messages=[
{"role": "system", "content": "You are a helpful DevOps assistant."},
{"role": "user", "content": prompt}
],
temperature=0.2,
max_tokens=800,
)
return response.choices[0].message.content
except Exception as e:
return f"Error communicating with the local AI model: {str(e)}"