bradnow commited on
Commit
6ab0b47
·
1 Parent(s): e1ad79b

Update model temperature setting

Browse files
Files changed (2) hide show
  1. app.py +6 -5
  2. utils.py +2 -1
app.py CHANGED
@@ -14,7 +14,7 @@ from utils import COMMUNITY_POSTFIX_URL, get_model_config, check_format, models_
14
  logged_event_handler, DEBUG_MODE, DEBUG_MODEL, log_debug, log_info, log_error, log_warning
15
  from log_chat import log_chat
16
 
17
- MODEL_TEMPERATURE = 0.8
18
  BUTTON_WIDTH = 160
19
  DEFAULT_OPT_OUT_VALUE = DEBUG_MODE
20
 
@@ -114,10 +114,11 @@ def run_chat_inference(history, message, state):
114
  state["stop_flag"] = False
115
  error = None
116
  model_name = model_config.get('MODEL_NAME')
 
117
 
118
  # Reinitialize the OpenAI client with a random endpoint from the list
119
  setup_model(model_config.get('MODEL_KEY'))
120
- log_info(f"Using model {model_name} with endpoint {model_config.get('base_url')}")
121
 
122
  if len(history) == 0:
123
  state["chat_id"] = uuid4().hex
@@ -372,7 +373,7 @@ def run_chat_inference(history, message, state):
372
  stream = openai_client.chat.completions.create(
373
  model=model_name,
374
  messages=api_messages,
375
- temperature=MODEL_TEMPERATURE,
376
  stream=True
377
  )
378
  except Exception as e:
@@ -387,7 +388,7 @@ def run_chat_inference(history, message, state):
387
  model_name=model_name,
388
  prompt=message,
389
  history=history,
390
- info={"is_reasoning": model_config.get("REASONING"), "temperature": MODEL_TEMPERATURE,
391
  "stopped": True, "error": str(e)},
392
  )
393
  else:
@@ -477,7 +478,7 @@ def run_chat_inference(history, message, state):
477
  model_name=model_name,
478
  prompt=message,
479
  history=history,
480
- info={"is_reasoning": model_config.get("REASONING"), "temperature": MODEL_TEMPERATURE,
481
  "stopped": state["stop_flag"]},
482
  )
483
 
 
14
  logged_event_handler, DEBUG_MODE, DEBUG_MODEL, log_debug, log_info, log_error, log_warning
15
  from log_chat import log_chat
16
 
17
+ DEFAULT_MODEL_TEMPERATURE = 0.6
18
  BUTTON_WIDTH = 160
19
  DEFAULT_OPT_OUT_VALUE = DEBUG_MODE
20
 
 
114
  state["stop_flag"] = False
115
  error = None
116
  model_name = model_config.get('MODEL_NAME')
117
+ temperature = model_config.get('TEMPERATURE', DEFAULT_MODEL_TEMPERATURE)
118
 
119
  # Reinitialize the OpenAI client with a random endpoint from the list
120
  setup_model(model_config.get('MODEL_KEY'))
121
+ log_info(f"Using model {model_name} (temperature: {temperature}) with endpoint {model_config.get('base_url')}")
122
 
123
  if len(history) == 0:
124
  state["chat_id"] = uuid4().hex
 
373
  stream = openai_client.chat.completions.create(
374
  model=model_name,
375
  messages=api_messages,
376
+ temperature=temperature,
377
  stream=True
378
  )
379
  except Exception as e:
 
388
  model_name=model_name,
389
  prompt=message,
390
  history=history,
391
+ info={"is_reasoning": model_config.get("REASONING"), "temperature": temperature,
392
  "stopped": True, "error": str(e)},
393
  )
394
  else:
 
478
  model_name=model_name,
479
  prompt=message,
480
  history=history,
481
+ info={"is_reasoning": model_config.get("REASONING"), "temperature": temperature,
482
  "stopped": state["stop_flag"]},
483
  )
484
 
utils.py CHANGED
@@ -20,7 +20,8 @@ models_config = {
20
  "VLLM_API_URL_LIST": os.environ.get("VLLM_API_URL_LIST_APRIEL_1_5_15B"),
21
  "AUTH_TOKEN": os.environ.get("AUTH_TOKEN"),
22
  "REASONING": True,
23
- "MULTIMODAL": True
 
24
  },
25
  # "Apriel-Nemotron-15b-Thinker": {
26
  # "MODEL_DISPLAY_NAME": "Apriel-Nemotron-15b-Thinker",
 
20
  "VLLM_API_URL_LIST": os.environ.get("VLLM_API_URL_LIST_APRIEL_1_5_15B"),
21
  "AUTH_TOKEN": os.environ.get("AUTH_TOKEN"),
22
  "REASONING": True,
23
+ "MULTIMODAL": True,
24
+ "TEMPERATURE": 0.6
25
  },
26
  # "Apriel-Nemotron-15b-Thinker": {
27
  # "MODEL_DISPLAY_NAME": "Apriel-Nemotron-15b-Thinker",