Rishabh12j commited on
Commit
97c91d1
·
verified ·
1 Parent(s): 773017a

Update models.py

Browse files
Files changed (1) hide show
  1. models.py +21 -20
models.py CHANGED
@@ -1,21 +1,22 @@
1
- from openai import OpenAI
2
- from config import Config
3
-
4
- class Model:
5
- @staticmethod
6
- def openai_chatgpt(transcript, prompt, extra=""):
7
- client = OpenAI(api_key=Config.get_openai_api_key())
8
- model = Config.OPENAI_MODEL
9
-
10
- message = [{"role": "system", "content": prompt + extra + transcript}]
11
- try:
12
- response = client.chat.completions.create(
13
- model=model,
14
- messages=message,
15
- max_tokens=2000, # Increased token limit for quiz generation
16
- temperature=0.7
17
- )
18
- return response.choices[0].message.content
19
- except Exception as e:
20
- response_error = "⚠️ There is a problem with the API key or with python module."
 
21
  return response_error, str(e)
 
1
+ from openai import OpenAI
2
+ from config import Config
3
+
4
+ class Model:
5
+ @staticmethod
6
+ def openai_chatgpt(transcript, prompt, extra=""):
7
+ client = OpenAI(api_key=Config.get_openai_api_key())
8
+ model = Config.OPENAI_MODEL
9
+
10
+ message = [{"role": "system", "content": prompt + extra},
11
+ {"role": "user", "content": transcript}]
12
+ try:
13
+ response = client.chat.completions.create(
14
+ model=model,
15
+ messages=message,
16
+ max_tokens=2000,
17
+ temperature=0.7
18
+ )
19
+ return response.choices[0].message.content
20
+ except Exception as e:
21
+ response_error = "⚠️ There is a problem with the API key or with python module."
22
  return response_error, str(e)