Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,22 +15,22 @@ os.environ["OPENAI_API_KEY"] = apikey
|
|
| 15 |
# Secret
|
| 16 |
# assit_Public_to_Compliance
|
| 17 |
# Confidential_HR_Director
|
| 18 |
-
def get_answer(
|
| 19 |
-
if
|
| 20 |
-
assist = assit_public
|
| 21 |
-
elif
|
| 22 |
-
assist = Secret
|
| 23 |
-
elif
|
| 24 |
-
assist = assit_Public_to_Compliance
|
| 25 |
-
elif
|
| 26 |
-
assist = Confidential_HR_Director
|
| 27 |
else:
|
| 28 |
return "Invalid knowledge base selected."
|
| 29 |
|
| 30 |
# # Use the selected tool to get the answer
|
| 31 |
# response = agent.chat(question) #, tools=[selected_tool]
|
| 32 |
interpreter_assistant = OpenAIAssistantRunnable(assistant_id= assist)
|
| 33 |
-
output = interpreter_assistant.invoke({"content":
|
| 34 |
response = output[0].content[0].text.value
|
| 35 |
return response
|
| 36 |
css = """
|
|
@@ -51,17 +51,15 @@ function refresh() {
|
|
| 51 |
}
|
| 52 |
}
|
| 53 |
"""
|
| 54 |
-
gr.
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
description="Ask questions related to the Finance Companies Control System.",
|
| 67 |
-
).launch(debug = True)
|
|
|
|
| 15 |
# Secret
|
| 16 |
# assit_Public_to_Compliance
|
| 17 |
# Confidential_HR_Director
|
| 18 |
+
def get_answer(message, history, additional_input):
|
| 19 |
+
if additional_input == "Public":
|
| 20 |
+
assist = assit_public
|
| 21 |
+
elif additional_input == "Secret":
|
| 22 |
+
assist = Secret
|
| 23 |
+
elif additional_input == "Public_to_Compliance":
|
| 24 |
+
assist = assit_Public_to_Compliance
|
| 25 |
+
elif additional_input == "HR_Director":
|
| 26 |
+
assist = Confidential_HR_Director
|
| 27 |
else:
|
| 28 |
return "Invalid knowledge base selected."
|
| 29 |
|
| 30 |
# # Use the selected tool to get the answer
|
| 31 |
# response = agent.chat(question) #, tools=[selected_tool]
|
| 32 |
interpreter_assistant = OpenAIAssistantRunnable(assistant_id= assist)
|
| 33 |
+
output = interpreter_assistant.invoke({"content": message})
|
| 34 |
response = output[0].content[0].text.value
|
| 35 |
return response
|
| 36 |
css = """
|
|
|
|
| 51 |
}
|
| 52 |
}
|
| 53 |
"""
|
| 54 |
+
with gr.Blocks(css=css, js = js_func, theme="soft") as demo:
|
| 55 |
+
chatbot = gr.Chatbot(placeholder="<strong>Your Personal AI</strong><br>Ask Me Anything")
|
| 56 |
+
additional_input = gr.Dropdown(choices=["Public", "Secret", "Public_to_Compliance","HR_Director"], label="Select Knowledge Base")
|
| 57 |
+
|
| 58 |
+
gr.ChatInterface(
|
| 59 |
+
fn=get_answer,
|
| 60 |
+
type="messages",
|
| 61 |
+
chatbot=chatbot,
|
| 62 |
+
additional_inputs=[additional_input] # Add the additional input to the ChatInterface
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
demo.launch(show_error=True,debug=True)
|
|
|
|
|
|