Lyte commited on
Commit
60bd67d
·
verified ·
1 Parent(s): d208f1e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -342,8 +342,17 @@ def create_interface():
342
  value='<div id="ai-reasoning">Waiting for your move...</div>',
343
  elem_id="ai-reasoning-container"
344
  )
 
 
 
 
 
 
 
 
 
345
 
346
- def handle_move(col):
347
  if game.game_over:
348
  return [
349
  render_board(game.board),
@@ -373,18 +382,17 @@ def create_interface():
373
  # AI move
374
  game.current_player = 2
375
 
376
- # NEW FORMAT: Use the new game state formatting
377
  game_state = game.format_game_state()
378
- #print("Sending game state to model:")
379
  print(game_state)
380
 
381
- # Get AI response
382
  response = model.create_chat_completion(
383
  messages=[
384
  {"role": "system", "content": SYSTEM_PROMPT},
385
  {"role": "user", "content": game_state}
386
  ],
387
- temperature=0.7,
388
  top_p=0.95,
389
  max_tokens=1024
390
  )
@@ -460,7 +468,10 @@ def create_interface():
460
  for i, btn in enumerate(col_buttons):
461
  btn.click(
462
  fn=handle_move,
463
- inputs=[gr.Number(value=i, visible=False)],
 
 
 
464
  outputs=[board_display, status, reasoning_display]
465
  )
466
 
 
342
  value='<div id="ai-reasoning">Waiting for your move...</div>',
343
  elem_id="ai-reasoning-container"
344
  )
345
+ with gr.Row():
346
+ temperature_slider = gr.Slider(
347
+ minimum=0.0,
348
+ maximum=1.0,
349
+ value=0.8,
350
+ step=0.1,
351
+ label="Temperature",
352
+ info="Lower values make AI more deterministic, higher values more creative"
353
+ )
354
 
355
+ def handle_move(col, temperature=0.8):
356
  if game.game_over:
357
  return [
358
  render_board(game.board),
 
382
  # AI move
383
  game.current_player = 2
384
 
385
+ # Use the new game state formatting
386
  game_state = game.format_game_state()
 
387
  print(game_state)
388
 
389
+ # Get AI response with user-defined temperature
390
  response = model.create_chat_completion(
391
  messages=[
392
  {"role": "system", "content": SYSTEM_PROMPT},
393
  {"role": "user", "content": game_state}
394
  ],
395
+ temperature=temperature,
396
  top_p=0.95,
397
  max_tokens=1024
398
  )
 
468
  for i, btn in enumerate(col_buttons):
469
  btn.click(
470
  fn=handle_move,
471
+ inputs=[
472
+ gr.Number(value=i, visible=False),
473
+ temperature_slider
474
+ ],
475
  outputs=[board_display, status, reasoning_display]
476
  )
477