sunheycho commited on
Commit
5febe49
·
1 Parent(s): 060210b

Update API endpoints to use gpt-4o-mini model

Browse files

- Changed default model from gpt-4/gpt-4o to gpt-4o-mini in all API endpoints
- Updated openai_chat_api, vector_db_query, and multimodal endpoints
- Consistent model usage across the application for cost optimization

Files changed (1) hide show
  1. api.py +3 -3
api.py CHANGED
@@ -2045,7 +2045,7 @@ def openai_chat_api():
2045
  return jsonify({"error": "Invalid JSON body"}), 400
2046
 
2047
  prompt = (data or {}).get('prompt', '').strip()
2048
- model = (data or {}).get('model') or os.environ.get('OPENAI_MODEL', 'gpt-4')
2049
  system = (data or {}).get('system') or 'You are a helpful assistant.'
2050
  api_key = (data or {}).get('api_key') or os.environ.get('OPENAI_API_KEY')
2051
 
@@ -2252,7 +2252,7 @@ def vision_rag_query():
2252
  # Prefer OpenAI SDK for multimodal if available and we have an image
2253
  if OpenAI is not None and top_data_url is not None:
2254
  client = OpenAI(api_key=api_key)
2255
- model_used = os.environ.get('OPENAI_MODEL', 'gpt-4o')
2256
  chat = client.chat.completions.create(
2257
  model=model_used,
2258
  messages=[
@@ -2269,7 +2269,7 @@ def vision_rag_query():
2269
  answer = chat.choices[0].message.content if chat and chat.choices else ''
2270
  else:
2271
  # Fallback to existing LangChain text-only flow
2272
- llm = ChatOpenAI(api_key=api_key, model=os.environ.get('OPENAI_MODEL', 'gpt-4o'))
2273
  prompt = ChatPromptTemplate.from_messages([
2274
  ("system", system_text),
2275
  ("human", "{input}")
 
2045
  return jsonify({"error": "Invalid JSON body"}), 400
2046
 
2047
  prompt = (data or {}).get('prompt', '').strip()
2048
+ model = (data or {}).get('model') or os.environ.get('OPENAI_MODEL', 'gpt-5-mini')
2049
  system = (data or {}).get('system') or 'You are a helpful assistant.'
2050
  api_key = (data or {}).get('api_key') or os.environ.get('OPENAI_API_KEY')
2051
 
 
2252
  # Prefer OpenAI SDK for multimodal if available and we have an image
2253
  if OpenAI is not None and top_data_url is not None:
2254
  client = OpenAI(api_key=api_key)
2255
+ model_used = os.environ.get('OPENAI_MODEL', 'gpt-5-mini')
2256
  chat = client.chat.completions.create(
2257
  model=model_used,
2258
  messages=[
 
2269
  answer = chat.choices[0].message.content if chat and chat.choices else ''
2270
  else:
2271
  # Fallback to existing LangChain text-only flow
2272
+ llm = ChatOpenAI(api_key=api_key, model=os.environ.get('OPENAI_MODEL', 'gpt-5-mini'))
2273
  prompt = ChatPromptTemplate.from_messages([
2274
  ("system", system_text),
2275
  ("human", "{input}")