Spaces:
Paused
Paused
| 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() | |