-
Notifications
You must be signed in to change notification settings - Fork 0
/
script_generate_status_live.py
58 lines (46 loc) · 1.53 KB
/
script_generate_status_live.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import config
import openai
import schedule
import time
from openai import OpenAI
client = OpenAI(api_key=config.OPENAI_API_KEY)
def generate_gpt():
with open('transcriptions/transcript.txt') as f:
text = f.read()
instructions = config.PROMPT_INSTRUCTIONS
prompt = f"""
{text}
{config.PROMPT_OUTPUT_FORMAT}
"""
engine = config.LLM_MODEL
retry = True
while retry:
try:
response = client.chat.completions.create(
model=engine,
temperature=0.7,
max_tokens = 800,
messages=[
{"role": "system", "content": instructions},
{"role": "user", "content": prompt},
],
).choices[0].message.content
try:
print(response.strip())
except Exception as e:
print(f"error parsing response from OpenAI {e}")
insights = response.strip()
retry = False
except Exception as e:
raise(e)
with open("status_content.txt", 'w') as f1:
f1.write(insights)
f1.close()
def execute_generate_gpt():
print("Generating full report and analysis of the current conversation...")
generate_gpt()
print("Starting background generator! Welcome!")
schedule.every(20).seconds.do(execute_generate_gpt)
while True:
schedule.run_pending()
time.sleep(1)