Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,29 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import backgammon
|
| 3 |
|
| 4 |
-
|
| 5 |
def greet(original_string):
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
|
|
|
| 17 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 18 |
demo.queue(api_open=True)
|
| 19 |
|
| 20 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import backgammon
|
| 3 |
|
|
|
|
| 4 |
def greet(original_string):
|
| 5 |
+
delimiter = "}}"
|
| 6 |
+
|
| 7 |
+
# Split the string based on the delimiter
|
| 8 |
+
split_parts = original_string.split(delimiter, 1)
|
| 9 |
+
|
| 10 |
+
# Check if the delimiter is found and handle potential errors
|
| 11 |
+
if len(split_parts) < 2:
|
| 12 |
+
return "Input string is incorrectly formatted. Missing delimiter."
|
| 13 |
+
|
| 14 |
+
part1 = split_parts[0]
|
| 15 |
+
part2 = delimiter + split_parts[1]
|
| 16 |
+
part2 = part2.replace("}}", "")
|
| 17 |
+
|
| 18 |
+
# Ensure backgammon.Backgammon accepts these arguments
|
| 19 |
+
b = backgammon.Backgammon(part1, part2)
|
| 20 |
+
|
| 21 |
+
# Generate plays and return moves
|
| 22 |
+
for play in b.generate_plays():
|
| 23 |
+
return play.moves # Ensure play.moves is a string
|
| 24 |
|
| 25 |
+
# Ensure the inputs and outputs match what `greet` returns
|
| 26 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 27 |
demo.queue(api_open=True)
|
| 28 |
|
| 29 |
+
demo.launch()
|