-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLLM.py
More file actions
37 lines (31 loc) · 1.06 KB
/
LLM.py
File metadata and controls
37 lines (31 loc) · 1.06 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
import yaml
from openai import OpenAI
import logging
logging.basicConfig()
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
class LLM:
def __init__(self):
with open("settings.yml", "r") as file:
meta_data = yaml.safe_load(file)
self.api_key = meta_data['api_key']
self.base_url = meta_data['base_url']
self.model_name = meta_data['model']
# Start OpenAI client
self.client = OpenAI(
api_key=self.api_key,
base_url=self.base_url
)
with open("systemprompt.txt", 'r') as prompt:
self.prompt = prompt.read()
def analyze_ticket(self, ticket):
chat_completion = self.client.chat.completions.create(
messages = [
{"role":"system",
"content": self.prompt},
{"role":"user",
"content": ticket}
],
model = self.model_name,
)
return chat_completion