File size: 1,198 Bytes
98ac1af
 
 
d7193c8
 
 
 
 
98ac1af
09f853e
 
 
d7193c8
98ac1af
 
 
d7193c8
 
 
 
 
 
 
 
 
09f853e
 
98ac1af
 
09f853e
 
98ac1af
 
 
 
 
 
 
09f853e
 
 
d7193c8
98ac1af
36e3bd8
98ac1af
 
 
 
09f853e
98ac1af
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
import gradio as gr

try:
    import spaces
except ImportError:
    spaces = None


BUILD_MARKER = "space-build-2026-07-27-1538"


def _respond_impl(message, history):
    response = f"You said: {message}\nAnd I say I love learning AI Engineering!"
    return response


if spaces is not None:
    @spaces.GPU
    def respond(message, history):
        return _respond_impl(message, history)
else:
    def respond(message, history):
        return _respond_impl(message, history)

chatbot = gr.Chatbot(type="messages")

demo = gr.ChatInterface(
    fn=respond,
    type="messages",
    chatbot=chatbot,
    title="My First Space",
    description="This is my first space using Gradio.",
)


if __name__ == "__main__":
    port = int(os.getenv("PORT", "7860"))
    print(f"Build marker: {BUILD_MARKER}")
    print(f"Gradio version: {gr.__version__}")
    print(f"App file: {__file__}")
    print(f"spaces module loaded: {spaces is not None}")
    print(f"Starting Gradio on 0.0.0.0:{port}")
    demo.launch(
        server_name="0.0.0.0",
        server_port=port,
        share=False,
        show_error=True,
        ssr_mode=False,
    )