-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGPT_4o_mini.py
39 lines (34 loc) · 1.09 KB
/
GPT_4o_mini.py
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
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
from LLM import LLM
import torch
from openai import AzureOpenAI
import json
from datetime import datetime
from openai import OpenAI
class GPT_4o_mini(LLM):
def load_model(self):
self.id = 23
self.model = OpenAI()
def generate(self, prompt: str) -> str:
messages = [
{
"role": "system",
"content": "You are an AI assistant that answers Place related MCQ questions."
},
{
"role": "user",
"content": prompt,
},
]
completion = self.model.chat.completions.create(
model="gpt-4o-mini",
messages=messages,
max_tokens=256,
temperature=0,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
stop=None
)
# print(completion.choices[0].message.content)
return completion.choices[0].message.content