From 32ddce862eb0589ed5c82469a08feda093b5d2c6 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Fri, 26 Jan 2024 16:55:30 +0800 Subject: [PATCH] Update grade examples, add gradio app example --- examples/{gradio.php => gradio/client.php} | 0 examples/{gradio.py => gradio/client.py} | 0 examples/gradio/first.php | 12 ++++++++++++ examples/gradio/first.py | 12 ++++++++++++ examples/gradio/flagged/log.csv | 4 ++++ 5 files changed, 28 insertions(+) rename examples/{gradio.php => gradio/client.php} (100%) rename examples/{gradio.py => gradio/client.py} (100%) create mode 100644 examples/gradio/first.php create mode 100644 examples/gradio/first.py create mode 100644 examples/gradio/flagged/log.csv diff --git a/examples/gradio.php b/examples/gradio/client.php similarity index 100% rename from examples/gradio.php rename to examples/gradio/client.php diff --git a/examples/gradio.py b/examples/gradio/client.py similarity index 100% rename from examples/gradio.py rename to examples/gradio/client.py diff --git a/examples/gradio/first.php b/examples/gradio/first.php new file mode 100644 index 0000000..8d87e42 --- /dev/null +++ b/examples/gradio/first.php @@ -0,0 +1,12 @@ + $v) { + $os->environ[$k] = $v; +} +$gr = PyCore::import('gradio'); +$demo = $gr->Interface(fn: function ($name, $intensity) { + return str_repeat("Hello ", $intensity) . $name . "!"; +}, inputs: new PyList(["text", "slider"]), outputs: new PyList(["text"])); +$demo->launch(); diff --git a/examples/gradio/first.py b/examples/gradio/first.py new file mode 100644 index 0000000..fc81b43 --- /dev/null +++ b/examples/gradio/first.py @@ -0,0 +1,12 @@ +import gradio as gr + +def greet(name, intensity): + return "Hello " * intensity + name + "!" + +demo = gr.Interface( + fn=greet, + inputs=["text", "slider"], + outputs=["text"], +) + +demo.launch() diff --git a/examples/gradio/flagged/log.csv b/examples/gradio/flagged/log.csv new file mode 100644 index 0000000..a874b3f --- /dev/null +++ b/examples/gradio/flagged/log.csv @@ -0,0 +1,4 @@ +input 0,input 1,output,flag,username,timestamp +我的世界,6,Hello Hello Hello Hello Hello Hello 我的世界!,,,2024-01-26 16:44:04.555180 +我的世界,6,Hello Hello Hello Hello Hello Hello 我的世界!,,,2024-01-26 16:44:06.572989 +我的世界,6,Hello Hello Hello Hello Hello Hello 我的世界!,,,2024-01-26 16:44:16.036929