Spaces:
Runtime error
Runtime error
sergiolucero
commited on
Commit
•
b04895c
1
Parent(s):
96bde30
Update ailib.py
Browse files
ailib.py
CHANGED
@@ -2,6 +2,8 @@ import openai
|
|
2 |
import time
|
3 |
|
4 |
OPENAI_TRANSCRIPTION_MODEL='whisper-1'
|
|
|
|
|
5 |
openai_client = openai.OpenAI()
|
6 |
|
7 |
def whisper_transcribe(fn, temperature=0):
|
@@ -16,3 +18,22 @@ def whisper_transcribe(fn, temperature=0):
|
|
16 |
transcript = transcript.text
|
17 |
print(f'Whisper transcribe [dt={dt} secs]')
|
18 |
return transcript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import time
|
3 |
|
4 |
OPENAI_TRANSCRIPTION_MODEL='whisper-1'
|
5 |
+
OPENAI_COMPLETION_MODEL = "gpt-4o"
|
6 |
+
MAX_TOKENS = 8192
|
7 |
openai_client = openai.OpenAI()
|
8 |
|
9 |
def whisper_transcribe(fn, temperature=0):
|
|
|
18 |
transcript = transcript.text
|
19 |
print(f'Whisper transcribe [dt={dt} secs]')
|
20 |
return transcript
|
21 |
+
|
22 |
+
def summarize(text):
|
23 |
+
prompt = f"Resume todos los aspectos médicos de esta consulta: '{text}'"
|
24 |
+
|
25 |
+
response = openai_client.chat.completions.create(
|
26 |
+
model = OPENAI_COMPLETION_MODEL,
|
27 |
+
messages = [{'role': 'user',
|
28 |
+
'content': prompt}
|
29 |
+
],
|
30 |
+
temperature = 0, max_tokens = TOKEN_LIMIT,
|
31 |
+
top_p=1.0, frequency_penalty=0.0,
|
32 |
+
presence_penalty=0.0)
|
33 |
+
|
34 |
+
resp_text = response.choices[0].message.content # use others?
|
35 |
+
|
36 |
+
return resp_text
|
37 |
+
|
38 |
+
|
39 |
+
|