Spaces:
Sleeping
Sleeping
Commit
·
252ec19
1
Parent(s):
edcde62
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import openai
|
| 3 |
+
|
| 4 |
+
# Initialize the OpenAI API
|
| 5 |
+
openai.api_key = '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'
|
| 6 |
+
|
| 7 |
+
KNOWN_MODELS = [
|
| 8 |
+
"Neural Networks", "Decision Trees", "Support Vector Machines",
|
| 9 |
+
"Random Forests", "Linear Regression", "Reinforcement Learning"
|
| 10 |
+
]
|
| 11 |
+
|
| 12 |
+
def recommend_ai_model_via_gpt(description):
|
| 13 |
+
# ... [same as before]
|
| 14 |
+
|
| 15 |
+
def explain_recommendation(model_name):
|
| 16 |
+
# ... [same as before]
|
| 17 |
+
|
| 18 |
+
# Streamlit UI
|
| 19 |
+
st.title('AI Model Recommender')
|
| 20 |
+
|
| 21 |
+
description = st.text_area("Describe your application:", "")
|
| 22 |
+
if st.button("Recommend AI Model"):
|
| 23 |
+
if description:
|
| 24 |
+
recommended_model = recommend_ai_model_via_gpt(description)
|
| 25 |
+
|
| 26 |
+
# Validate recommended model
|
| 27 |
+
if recommended_model not in KNOWN_MODELS:
|
| 28 |
+
st.warning("The recommendation is ambiguous. Please refine your description or consult an expert.")
|
| 29 |
+
else:
|
| 30 |
+
st.subheader(f"Recommended AI Model: {recommended_model}")
|
| 31 |
+
explanation = explain_recommendation(recommended_model)
|
| 32 |
+
st.write("Reason:", explanation)
|
| 33 |
+
|
| 34 |
+
# Collecting rating and feedback through Streamlit
|
| 35 |
+
rating = st.slider("Rate the explanation from 1 (worst) to 5 (best):", 1, 5)
|
| 36 |
+
feedback = st.text_input("Any additional feedback?")
|
| 37 |
+
|
| 38 |
+
if st.button("Submit Feedback"):
|
| 39 |
+
st.success("Thank you for your feedback!")
|
| 40 |
+
else:
|
| 41 |
+
st.warning("Please provide a description.")
|
| 42 |
+
|