Spaces:
Sleeping
Sleeping
import google.generativeai as genai | |
import gradio as gr | |
api_key = "AIzaSyCmmus8HFPLXskU170_FR4j2CQeWZBKGMY" | |
model = genai.GenerativeModel('gemini-pro') | |
genai.configure(api_key = api_key) | |
def get_response(feedback): | |
try: | |
#response = model.generate_content(f"State whether given response is positive, negative or neutral in one word: {feedback}") | |
score = model.generate_content(f"Give me the polarity score between -1 to 1 for: {feedback}") | |
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}') | |
return [score.text, issue.text] | |
except Exception as e: | |
return [-2, "Offensive"] | |
iface = gr.Interface( | |
fn = get_response, | |
inputs = ["text"], | |
outputs = ["text", "text"] | |
) | |
iface.launch(share=True) |