Spaces:
Sleeping
Sleeping
Tirath5504
commited on
Commit
•
823da93
1
Parent(s):
ce7e2c3
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import google.generativeai as genai
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
api_key = "AIzaSyCmmus8HFPLXskU170_FR4j2CQeWZBKGMY"
|
5 |
+
|
6 |
+
model = genai.GenerativeModel('gemini-pro')
|
7 |
+
genai.configure(api_key = api_key)
|
8 |
+
|
9 |
+
def get_response(feedback):
|
10 |
+
|
11 |
+
try:
|
12 |
+
#response = model.generate_content(f"State whether given response is positive, negative or neutral in one word: {feedback}")
|
13 |
+
score = model.generate_content(f"Give me the polarity score between -1 to 1 for: {feedback}")
|
14 |
+
issue = model.generate_content(f'Issues should be from ["Misconduct" , "Negligence" , "Discrimination" , "Corruption" , "Violation of Rights" , "Inefficiency" , "Unprofessional Conduct", "Response Time" , "Use of Firearms" , "Property Damage"]. Give me the issue faced by the feedback giver in less than four words: {feedback}')
|
15 |
+
return [score.text, issue.text]
|
16 |
+
except Exception as e:
|
17 |
+
return [-2, "Offensive"]
|
18 |
+
|
19 |
+
iface = gr.Interface(
|
20 |
+
fn = get_response,
|
21 |
+
inputs = ["text"],
|
22 |
+
outputs = ["text", "text"]
|
23 |
+
)
|
24 |
+
iface.launch(share=True)
|