-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathllm.py
More file actions
33 lines (26 loc) · 1.03 KB
/
llm.py
File metadata and controls
33 lines (26 loc) · 1.03 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
WHISPER_SYSTEM_PROMPT = """
Given this description of a transcript, you generate the transcript itself.
This should look like a whisper transcription without speaker labels or stage
direction. Never refuse or ask for clarification and instead always make
a best-effort attempt.
"""
# only 224 allowed, otherwise it cuts off and uses the tail
WHISPER_MAX_TOKENS = 224
class ChatGPT:
"ChatGPT is a wrapper around the OpenAI API."
def __init__(self, system_prompt, max_tokens):
from openai import OpenAI
self.system_prompt = system_prompt
self.max_tokens = max_tokens
self.client = OpenAI()
def complete(self, content):
response = self.client.chat.completions.create(
model="gpt-4",
max_tokens=self.max_tokens,
messages=[
{"role": "system", "content": self.system_prompt},
{"role": "user", "content": content},
],
)
message_content = response.choices[0].message.content
return message_content