This repository was archived by the owner on May 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdescriber.py
More file actions
35 lines (29 loc) · 1.6 KB
/
Copy pathdescriber.py
File metadata and controls
35 lines (29 loc) · 1.6 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
import openai
import requests
def generate_description(transcription, model):
prompt = f"I have a transcript of an audio file and I need a brief description or summary of it. Here's the transcript followed by ENDOFTRANSCRIPT: \"{transcription}\" ENDOFTRANSCRIPT. Can you provide a summary?"
completion = openai.ChatCompletion.create(
model=model,
messages=[
{"role": "system", "content": "You are a helpful assistant that summarizes and describes audio transcripts with no other commentary so that they can be copied into a video description."},
{"role": "user", "content": prompt}
]
)
description = completion['choices'][0]['message']['content']
return description
def generate_description_local(transcription, model):
prompt = f"I have a transcript of an audio file and I need a brief description or summary of it. Here's the transcript followed by ENDOFTRANSCRIPT: \"{transcription}\" ENDOFTRANSCRIPT. Can you provide a summary?"
# Send a POST request to the local server
response = requests.post(
"http://localhost:1234/v1/chat/completions",
json={
"model": model,
"messages": [
{"role": "system", "content": "You are a helpful assistant that summarizes and describes audio transcripts with no other commentary so that they can be copied into a video description."},
{"role": "user", "content": prompt}
]
}
)
# Retrieve the description from the response
description = response.json()['choices'][0]['message']['content']
return description