Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import openai
|
| 3 |
+
def generate_completion(user_prompt):
|
| 4 |
+
hidden_context = " "
|
| 5 |
+
prompt = hidden_context + user_prompt
|
| 6 |
+
response = openai.Completion.create(
|
| 7 |
+
model="davinci:ft-topwow-llc:coloncancer-2023-09-20-01-05-16",
|
| 8 |
+
prompt=prompt,
|
| 9 |
+
max_tokens=30,
|
| 10 |
+
temperature=0,
|
| 11 |
+
stop=["_END"]
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
return response.choices[0].text.strip()
|
| 16 |
+
iface = gr.Interface(fn=generate_completion,
|
| 17 |
+
inputs=gr.inputs.Textbox(lines=5, placeholder='write the phrase here'),
|
| 18 |
+
outputs='text',
|
| 19 |
+
title="Colon cancer symptom detector",
|
| 20 |
+
description="Colon cancer symptom detector. Write the phrase and add the arrow -> plus three spaces, example: Unexplained weight loss -> ",
|
| 21 |
+
input_labels="phrase",
|
| 22 |
+
output_labels="prediction")
|
| 23 |
+
|
| 24 |
+
iface.launch()
|