Spaces:
Running
Running
Commit
·
c8d6d95
1
Parent(s):
d30ccfe
Remove useless styling & create public link
Browse files
app.py
CHANGED
@@ -30,39 +30,34 @@ async def respond(message, history, thread_state):
|
|
30 |
response += token
|
31 |
yield history + [(message, response)], thread_state
|
32 |
|
|
|
|
|
|
|
33 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
34 |
-
with gr.
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
show_label=False,
|
|
|
|
|
49 |
)
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
)
|
57 |
-
submit_btn = gr.Button("Envoyer", scale=1)
|
58 |
-
|
59 |
-
with gr.Row():
|
60 |
-
clear_btn = gr.Button("Effacer la conversation")
|
61 |
-
|
62 |
-
thread_state = gr.State(value=None)
|
63 |
-
|
64 |
-
def clear_conversation():
|
65 |
-
return [], None
|
66 |
|
67 |
txt.submit(
|
68 |
respond,
|
@@ -70,7 +65,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
70 |
[chatbot, thread_state],
|
71 |
api_name=False
|
72 |
).then(
|
73 |
-
lambda: "",
|
74 |
None,
|
75 |
[txt]
|
76 |
)
|
@@ -81,7 +76,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
81 |
[chatbot, thread_state],
|
82 |
api_name=False
|
83 |
).then(
|
84 |
-
lambda: "",
|
85 |
None,
|
86 |
[txt]
|
87 |
)
|
@@ -93,29 +88,5 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
93 |
api_name=False
|
94 |
)
|
95 |
|
96 |
-
gr.Markdown("""
|
97 |
-
<style>
|
98 |
-
.gradio-container {
|
99 |
-
background-color: #f5f7f5;
|
100 |
-
}
|
101 |
-
.contain {
|
102 |
-
max-width: 1200px !important;
|
103 |
-
margin: auto;
|
104 |
-
}
|
105 |
-
.message {
|
106 |
-
padding: 15px;
|
107 |
-
border-radius: 10px;
|
108 |
-
margin-bottom: 10px;
|
109 |
-
}
|
110 |
-
.user-message {
|
111 |
-
background-color: #e6f3ff;
|
112 |
-
}
|
113 |
-
.bot-message {
|
114 |
-
background-color: #f5f5f5;
|
115 |
-
}
|
116 |
-
footer {display: none !important}
|
117 |
-
</style>
|
118 |
-
""")
|
119 |
-
|
120 |
if __name__ == "__main__":
|
121 |
-
demo.launch()
|
|
|
30 |
response += token
|
31 |
yield history + [(message, response)], thread_state
|
32 |
|
33 |
+
def clear_conversation():
|
34 |
+
return [], None
|
35 |
+
|
36 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
37 |
+
with gr.Column(scale=3):
|
38 |
+
gr.Markdown("### Assistant R&D Agricole")
|
39 |
+
chatbot = gr.Chatbot(
|
40 |
+
height=600,
|
41 |
+
avatar_images=(
|
42 |
+
"https://em-content.zobj.net/source/microsoft-teams/337/farmer_1f9d1-200d-1f33e.png",
|
43 |
+
"https://em-content.zobj.net/source/microsoft-teams/363/robot_1f916.png"
|
44 |
+
),
|
45 |
+
container=True,
|
46 |
+
show_label=False,
|
47 |
+
)
|
48 |
+
with gr.Row():
|
49 |
+
txt = gr.Textbox(
|
50 |
+
placeholder="Posez votre question ici concernant les données R&D agricoles...",
|
51 |
show_label=False,
|
52 |
+
container=False,
|
53 |
+
scale=9,
|
54 |
)
|
55 |
+
submit_btn = gr.Button("Envoyer", scale=1)
|
56 |
+
|
57 |
+
with gr.Row():
|
58 |
+
clear_btn = gr.Button("Effacer la conversation")
|
59 |
+
|
60 |
+
thread_state = gr.State()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
txt.submit(
|
63 |
respond,
|
|
|
65 |
[chatbot, thread_state],
|
66 |
api_name=False
|
67 |
).then(
|
68 |
+
lambda: "",
|
69 |
None,
|
70 |
[txt]
|
71 |
)
|
|
|
76 |
[chatbot, thread_state],
|
77 |
api_name=False
|
78 |
).then(
|
79 |
+
lambda: "",
|
80 |
None,
|
81 |
[txt]
|
82 |
)
|
|
|
88 |
api_name=False
|
89 |
)
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
if __name__ == "__main__":
|
92 |
+
demo.launch(share=True)
|