Spaces:
Sleeping
Sleeping
Commit
·
1e4e3dc
1
Parent(s):
b2d1132
Update app.py
Browse files
app.py
CHANGED
@@ -44,38 +44,14 @@ KNOWN_MODELS = [
|
|
44 |
|
45 |
def recommend_ai_model_via_gpt(description, dataset_description):
|
46 |
combined_description = f"{description} Dataset: {dataset_description}"
|
47 |
-
messages = [
|
48 |
-
|
49 |
-
]
|
50 |
-
response = openai.ChatCompletion.create(
|
51 |
-
model="gpt-4",
|
52 |
-
messages=messages
|
53 |
-
)
|
54 |
return response['choices'][0]['message']['content'].strip()
|
55 |
|
56 |
-
#except openai.APIError as e:
|
57 |
-
# return f"Error: {e}"
|
58 |
-
#except openai.RateLimitError as e:
|
59 |
-
# return f"Rate limit exceeded: {e}"
|
60 |
-
#except openai.APIConnectionError as e:
|
61 |
-
# return f"Connection error: {e}"
|
62 |
-
|
63 |
-
|
64 |
def explain_recommendation(model_name):
|
65 |
-
messages = [
|
66 |
-
|
67 |
-
]
|
68 |
-
response = openai.ChatCompletion.create(
|
69 |
-
model="gpt-4",
|
70 |
-
messages=messages
|
71 |
-
)
|
72 |
return response['choices'][0]['message']['content'].strip()
|
73 |
-
#except openai.APIError as e:
|
74 |
-
# return f"Error: {e}"
|
75 |
-
#except openai.RateLimitError as e:
|
76 |
-
# return f"Rate limit exceeded: {e}"
|
77 |
-
#except openai.APIConnectionError as e:
|
78 |
-
# return f"Connection error: {e}"
|
79 |
|
80 |
# Streamlit UI
|
81 |
st.image("./A8title2.png")
|
@@ -85,39 +61,18 @@ description = st.text_area("Describe your application:")
|
|
85 |
|
86 |
if description:
|
87 |
dataset_description = st.text_area("Describe the dataset you want to use for fine-tuning your model:")
|
88 |
-
|
89 |
if dataset_description:
|
90 |
if st.button("Recommend AI Model", key="recommend_model_button"):
|
91 |
recommended_model = recommend_ai_model_via_gpt(description, dataset_description)
|
92 |
st.subheader(f"Recommended: {recommended_model}")
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
if
|
100 |
-
|
101 |
-
|
102 |
-
if st.button("Recommend AI Model", key="another_unique_key"):
|
103 |
-
st.session_state.rec_model_pressed = True
|
104 |
-
|
105 |
-
if st.session_state.rec_model_pressed:
|
106 |
-
if description and dataset_description:
|
107 |
-
combined_query = f"{description} Dataset: {dataset_description}"
|
108 |
-
recommended_model = recommend_ai_model_via_gpt(combined_query)
|
109 |
-
st.subheader(f"Recommended: {recommended_model}")
|
110 |
-
explanation = explain_recommendation(recommended_model)
|
111 |
-
st.write("Reason:", explanation)
|
112 |
-
|
113 |
-
rating = st.slider("Rate the explanation from 1 (worst) to 5 (best):", 1, 5)
|
114 |
-
feedback = st.text_input("Any additional feedback?")
|
115 |
-
|
116 |
-
if st.button("Submit Feedback", key="submit_feedback_key"):
|
117 |
-
st.session_state.feedback_submitted = True
|
118 |
-
|
119 |
-
if st.session_state.feedback_submitted:
|
120 |
-
st.success("Thank you for your feedback!")
|
121 |
|
122 |
else:
|
123 |
st.warning("Please provide a description and dataset details.")
|
|
|
44 |
|
45 |
def recommend_ai_model_via_gpt(description, dataset_description):
|
46 |
combined_description = f"{description} Dataset: {dataset_description}"
|
47 |
+
messages = [{"role": "user", "content": combined_description}]
|
48 |
+
response = openai.ChatCompletion.create(model="gpt-4", messages=messages)
|
|
|
|
|
|
|
|
|
|
|
49 |
return response['choices'][0]['message']['content'].strip()
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
def explain_recommendation(model_name):
|
52 |
+
messages = [{"role": "user", "content": f"Why would {model_name} be a suitable choice for the application?"}]
|
53 |
+
response = openai.ChatCompletion.create(model="gpt-4", messages=messages)
|
|
|
|
|
|
|
|
|
|
|
54 |
return response['choices'][0]['message']['content'].strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
# Streamlit UI
|
57 |
st.image("./A8title2.png")
|
|
|
61 |
|
62 |
if description:
|
63 |
dataset_description = st.text_area("Describe the dataset you want to use for fine-tuning your model:")
|
|
|
64 |
if dataset_description:
|
65 |
if st.button("Recommend AI Model", key="recommend_model_button"):
|
66 |
recommended_model = recommend_ai_model_via_gpt(description, dataset_description)
|
67 |
st.subheader(f"Recommended: {recommended_model}")
|
68 |
+
explanation = explain_recommendation(recommended_model)
|
69 |
+
st.write("Reason:", explanation)
|
70 |
+
rating = st.slider("Rate the explanation from 1 (worst) to 5 (best):", 1, 5)
|
71 |
+
feedback = st.text_input("Any additional feedback?")
|
72 |
+
if st.button("Submit Feedback", key="submit_feedback_key"):
|
73 |
+
st.session_state.feedback_submitted = True
|
74 |
+
if st.session_state.feedback_submitted:
|
75 |
+
st.success("Thank you for your feedback!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
else:
|
78 |
st.warning("Please provide a description and dataset details.")
|