File size: 984 Bytes
423161c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import openai
import os

openai.api_key = os.getenv("OPENAI_API_KEY")

def generate_completion(user_prompt):
    hidden_context = " "
    prompt = hidden_context + user_prompt
    response = openai.Completion.create(
        model="davinci:ft-topwow-llc:braintumor-2023-08-30-01-15-51",
        prompt=prompt,
        max_tokens=30,
        temperature=0,
        stop=["_END"]
    )
    return response.choices[0].text.strip()
iface = gr.Interface(fn=generate_completion,
                     inputs=gr.inputs.Textbox(lines=5, placeholder=' Insert the arrow -> after the description of the symptom, for example "I have a bad headache at night ->"'),
                     outputs='text',
                     title="Brain tumor",
                     description="Platform to detect potential brain tumor symptoms, does not replace medical professionals. ",
                     input_labels="Phrases",
                     output_labels="symptoms")
iface.launch()