Sayed121 commited on
Commit
5b6551c
·
verified ·
1 Parent(s): 1c043a6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import google.cloud.aiplatform as aiplatform
3
+
4
+ # Initialize Vertex AI
5
+ aiplatform.init(project='318551047592', location='us-central1')
6
+ endpoint = aiplatform.Endpoint('4054023616424050688') # Replace with your endpoint ID
7
+
8
+ def predict(text):
9
+ response = endpoint.predict(instances=[{"text": text}])
10
+ response1= response.predictions[0]
11
+ response2= response1['prediction']
12
+ return response2
13
+
14
+ # Create the Gradio interface
15
+ interface = gr.Interface(
16
+ fn=predict,
17
+ inputs=gr.Textbox(
18
+ lines=3,
19
+ placeholder="Ask your question about diabetes..."
20
+ ),
21
+ outputs=gr.Textbox(label="Response"),
22
+ title="Diabetica Medical Assistant",
23
+ description="Ask questions about diabetes and get responses from our medical AI assistant.",
24
+ examples=[
25
+ ["What are the early symptoms of diabetes?"],
26
+ ["How is Type 2 diabetes diagnosed?"],
27
+ ["What lifestyle changes can help manage diabetes?"]
28
+ ],
29
+ theme="default"
30
+ )
31
+
32
+ # Launch the app
33
+ interface.launch(server_name="0.0.0.0", server_port=8082)