Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import g4f
|
| 2 |
+
import g4f.api
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
# Your existing g4f server code
|
| 6 |
+
if __name__ == "__main__":
|
| 7 |
+
print(f'Starting server... [g4f v-{g4f.version}]')
|
| 8 |
+
g4f.api.Api(engine=g4f, debug=True).run(ip="127.0.0.1:1337")
|
| 9 |
+
|
| 10 |
+
# Gradio Interface
|
| 11 |
+
iface = gr.Interface(
|
| 12 |
+
fn=None, # You should replace None with your function that interacts with the g4f engine
|
| 13 |
+
live=True,
|
| 14 |
+
capture_session=True,
|
| 15 |
+
inputs=[gr.Textbox("Input text", default="")],
|
| 16 |
+
outputs="text",
|
| 17 |
+
title="g4f Gradio Interface",
|
| 18 |
+
description="Interact with g4f engine through Gradio.",
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
iface.launch()
|