-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessor_llm.py
More file actions
38 lines (29 loc) · 1.2 KB
/
processor_llm.py
File metadata and controls
38 lines (29 loc) · 1.2 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
from dotenv import load_dotenv
from groq import Groq
import json
import re
load_dotenv()
groq = Groq()
def classify_with_llm(log_msg):
prompt = f'''Classify the log message into one of these categories:
(1) Workflow Error, (2) Deprecation Warning.
If you can't figure out a category, use "Unclassified".
Put the category inside <category> </category> tags.
Log message: {log_msg}'''
chat_completion = groq.chat.completions.create(
messages=[{"role": "user", "content": prompt}],
model="llama-3.3-70b-versatile",
temperature=0.5
)
content = chat_completion.choices[0].message.content
match = re.search(r'<category>(.*)<\/category>', content, flags=re.DOTALL)
category = "Unclassified"
if match:
category = match.group(1)
return category
if __name__ == "__main__":
print(classify_with_llm(
"Case escalation for ticket ID 7324 failed because the assigned support agent is no longer active."))
print(classify_with_llm(
"The 'ReportGenerator' module will be retired in version 4.0. Please migrate to the 'AdvancedAnalyticsSuite' by Dec 2025"))
print(classify_with_llm("System reboot initiated by user 12345."))