Spaces:
Paused
Paused
File size: 992 Bytes
68bd3bf 0ec69bc 68bd3bf b483e5c 1fedbb8 d4b473f 68bd3bf 1fedbb8 83071ea 855b245 e6f7c3d 1fedbb8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
import backgammon
def greet(original_string):
delimiter = "}}"
# Split the string based on the delimiter
split_parts = original_string.split(delimiter, 1)
# Check if the delimiter is found and handle potential errors
if len(split_parts) < 2:
return "Input string is incorrectly formatted. Missing delimiter."
part1 = split_parts[0]
part2 = delimiter + split_parts[1]
part2 = part2.replace("}}", "")
# Ensure backgammon.Backgammon accepts these arguments
b = backgammon.Backgammon(part1, part2)
# Generate plays and return moves
moves = [play.moves for play in b.generate_plays()]
if not moves: # If no moves are generated
return "No moves available."
return moves[0] # Return the first move as an example
# Ensure the inputs and outputs match what `greet` returns
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.queue(api_open=True)
demo.launch()
|