MartinKosela commited on
Commit
81a7239
·
1 Parent(s): 37185e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -35
app.py CHANGED
@@ -42,54 +42,34 @@ KNOWN_MODELS = [
42
  "Attention Mechanisms", "Named Entity Recognition", "Text Summarization"
43
  ]
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
- if 'show_dataset_description' not in st.session_state:
58
- st.session_state.show_dataset_description = False
59
-
60
  st.image("./A8title.png")
61
  st.title('Discover the best model for your GenAI App')
62
 
63
- # Inserting blank space
64
- st.write("")
65
- st.write("")
66
  st.write("")
67
 
68
- st.markdown("<h4 style='font-size:20px;'>Outline below your app's functionality:</h4>", unsafe_allow_html=True)
69
  description = st.text_area("", key="app_description")
70
 
71
  if description:
72
- if st.button("Next", key="next_to_dataset"):
73
- st.session_state.show_dataset_description = True
74
-
75
- if 'show_dataset_description' in st.session_state and st.session_state.show_dataset_description:
76
- st.write("")
77
- st.write("")
78
- st.write("")
79
- st.markdown("<h4 style='font-size:20px;'>Detail your dataset for fine-tuning this model:</h4>", unsafe_allow_html=True)
80
- dataset_description = st.text_area("", key="dataset_description")
81
- if dataset_description:
82
- if st.button("Recommend AI Model", key="recommend_model_button"):
83
- recommended_model = recommend_ai_model_via_gpt(description, dataset_description)
84
- st.subheader(f"Recommended: {recommended_model}")
85
- explanation = explain_recommendation(recommended_model)
86
- st.write("Reason:", explanation)
87
- rating = st.slider("Rate the explanation from 1 (worst) to 5 (best):", 1, 5)
88
- feedback = st.text_input("Any additional feedback?")
89
- if st.button("Submit Feedback", key="submit_feedback_key"):
90
- st.session_state.feedback_submitted = True
91
- if st.session_state.feedback_submitted:
92
- st.success("Thank you for your feedback!")
93
-
94
- else:
95
- st.warning("Please provide a description of your application.")
 
42
  "Attention Mechanisms", "Named Entity Recognition", "Text Summarization"
43
  ]
44
 
45
+ def recommend_ai_model_via_gpt(description):
46
+ messages = [{"role": "user", "content": description}]
 
47
  response = openai.ChatCompletion.create(model="gpt-4", messages=messages)
48
  return response['choices'][0]['message']['content'].strip()
49
 
50
  def explain_recommendation(model_name):
51
+ messages = [{"role": "user", "content": f"Why is {model_name} the best choice for my application?"}]
52
  response = openai.ChatCompletion.create(model="gpt-4", messages=messages)
53
  return response['choices'][0]['message']['content'].strip()
54
 
55
  # Streamlit UI
 
 
 
56
  st.image("./A8title.png")
57
  st.title('Discover the best model for your GenAI App')
58
 
 
 
 
59
  st.write("")
60
 
61
+ st.markdown("<h4 style='font-size:20px;'>Outline Your Application's Functionality:</h4>", unsafe_allow_html=True)
62
  description = st.text_area("", key="app_description")
63
 
64
  if description:
65
+ if st.button("Recommend AI Model", key="recommend_model_button"):
66
+ recommended_model = recommend_ai_model_via_gpt(description)
67
+ st.subheader(f"Recommended: {recommended_model}")
68
+ explanation = explain_recommendation(recommended_model)
69
+ st.write("Explanation:", 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!")