kamkol commited on
Commit
f4ce103
·
1 Parent(s): 0be47a9

Fix ChatOpenAI initialization to handle proxy parameter issues

Browse files
Files changed (1) hide show
  1. streamlit_app.py +34 -8
streamlit_app.py CHANGED
@@ -95,18 +95,44 @@ def load_document_chunks():
95
  @st.cache_resource
96
  def get_chat_model():
97
  """Get the chat model for initial RAG."""
98
- return ChatOpenAI(
99
- model="gpt-4.1-mini",
100
- temperature=0,
101
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
  @st.cache_resource
104
  def get_agent_model():
105
  """Get the more powerful model for agent and evaluation."""
106
- return ChatOpenAI(
107
- model="gpt-4.1",
108
- temperature=0,
109
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
  @st.cache_resource
112
  def get_embedding_model():
 
95
  @st.cache_resource
96
  def get_chat_model():
97
  """Get the chat model for initial RAG."""
98
+ try:
99
+ # First attempt with minimal params
100
+ return ChatOpenAI(
101
+ model="gpt-4.1-mini",
102
+ temperature=0,
103
+ )
104
+ except Exception as e:
105
+ print(f"Error initializing chat model: {str(e)}")
106
+ # Try with just model name
107
+ try:
108
+ return ChatOpenAI(
109
+ model="gpt-4.1-mini"
110
+ )
111
+ except Exception as e2:
112
+ print(f"Final attempt for chat model: {str(e2)}")
113
+ # Last resort with no parameters
114
+ return ChatOpenAI()
115
 
116
  @st.cache_resource
117
  def get_agent_model():
118
  """Get the more powerful model for agent and evaluation."""
119
+ try:
120
+ # First attempt with minimal params
121
+ return ChatOpenAI(
122
+ model="gpt-4.1",
123
+ temperature=0,
124
+ )
125
+ except Exception as e:
126
+ print(f"Error initializing agent model: {str(e)}")
127
+ # Try with just model name
128
+ try:
129
+ return ChatOpenAI(
130
+ model="gpt-4.1"
131
+ )
132
+ except Exception as e2:
133
+ print(f"Final attempt for agent model: {str(e2)}")
134
+ # Last resort with no parameters
135
+ return ChatOpenAI()
136
 
137
  @st.cache_resource
138
  def get_embedding_model():