Spaces:
Runtime error
Runtime error
sergiolucero
commited on
Commit
•
6086021
1
Parent(s):
8b5626d
Update ailib.py
Browse files
ailib.py
CHANGED
@@ -7,6 +7,28 @@ TOKEN_LIMIT = 4096
|
|
7 |
|
8 |
openai_client = openai.OpenAI()
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
def whisper_transcribe(fn, temperature=0):
|
11 |
t0 = time.time()
|
12 |
audio_file = open(fn,'rb') # redundant?
|
@@ -22,19 +44,5 @@ def whisper_transcribe(fn, temperature=0):
|
|
22 |
|
23 |
def summarize(text):
|
24 |
prompt = f"Resume todos los aspectos médicos de esta consulta: '{text}'"
|
25 |
-
|
26 |
-
|
27 |
-
model = OPENAI_COMPLETION_MODEL,
|
28 |
-
messages = [{'role': 'user',
|
29 |
-
'content': prompt}
|
30 |
-
],
|
31 |
-
temperature = 0, max_tokens = TOKEN_LIMIT,
|
32 |
-
top_p=1.0, frequency_penalty=0.0,
|
33 |
-
presence_penalty=0.0)
|
34 |
-
|
35 |
-
resp_text = response.choices[0].message.content # use others?
|
36 |
-
|
37 |
-
return resp_text
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
7 |
|
8 |
openai_client = openai.OpenAI()
|
9 |
|
10 |
+
def openai_query(prompt):
|
11 |
+
response = openai_client.chat.completions.create(
|
12 |
+
model = OPENAI_COMPLETION_MODEL,
|
13 |
+
messages = [{'role': 'user',
|
14 |
+
'content': prompt}
|
15 |
+
],
|
16 |
+
temperature = 0, max_tokens = TOKEN_LIMIT,
|
17 |
+
top_p=1.0, frequency_penalty=0.0,
|
18 |
+
presence_penalty=0.0)
|
19 |
+
resp_text = response.choices[0].message.content
|
20 |
+
return resp_text
|
21 |
+
|
22 |
+
def nueva_ficha(resumen_historial, resumen_hoy):
|
23 |
+
|
24 |
+
new_prompt = f'''Escribe una nueva ficha médica, considerando el historial médico: "{resumen_historial}",
|
25 |
+
y también lo que ocurrió hoy: "{resumen_hoy}"
|
26 |
+
'''
|
27 |
+
nueva = openai_query(new_prompt)
|
28 |
+
|
29 |
+
return nueva
|
30 |
+
|
31 |
+
|
32 |
def whisper_transcribe(fn, temperature=0):
|
33 |
t0 = time.time()
|
34 |
audio_file = open(fn,'rb') # redundant?
|
|
|
44 |
|
45 |
def summarize(text):
|
46 |
prompt = f"Resume todos los aspectos médicos de esta consulta: '{text}'"
|
47 |
+
resp_text = openai_query(prompt)
|
48 |
+
return resp_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|