MartinKosela commited on
Commit
da0700d
·
1 Parent(s): 5b1e2fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import streamlit as st
2
  import openai
 
3
  import os
4
 
5
  # Securely fetch the OpenAI API key
@@ -45,9 +46,10 @@ def recommend_ai_model_via_gpt(description):
45
  )
46
  recommendation = response['choices'][0]['message']['content'].strip()
47
  return recommendation
48
- except openai.error.OpenAIError as e:
49
  return f"Error: {e}"
50
 
 
51
  def explain_recommendation(model_name):
52
  messages = [
53
  {"role": "user", "content": f"Why would {model_name} be a suitable choice for the application?"}
@@ -60,7 +62,7 @@ def explain_recommendation(model_name):
60
  )
61
  explanation = response['choices'][0]['message']['content'].strip()
62
  return explanation
63
- except openai.error.OpenAIError as e:
64
  return f"Error: {e}"
65
 
66
  # Streamlit UI
 
1
  import streamlit as st
2
  import openai
3
+ from openai.error import OpenAIError
4
  import os
5
 
6
  # Securely fetch the OpenAI API key
 
46
  )
47
  recommendation = response['choices'][0]['message']['content'].strip()
48
  return recommendation
49
+ except OpenAIError as e:
50
  return f"Error: {e}"
51
 
52
+
53
  def explain_recommendation(model_name):
54
  messages = [
55
  {"role": "user", "content": f"Why would {model_name} be a suitable choice for the application?"}
 
62
  )
63
  explanation = response['choices'][0]['message']['content'].strip()
64
  return explanation
65
+ except OpenAIError as e:
66
  return f"Error: {e}"
67
 
68
  # Streamlit UI