Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -48,65 +48,13 @@ def bot_kadi(history):
|
|
48 |
yield history
|
49 |
|
50 |
|
51 |
-
|
52 |
-
# Gradio utils
|
53 |
-
def check_input_text(text):
|
54 |
-
if not text:
|
55 |
-
gr.Warning("Please input a question.")
|
56 |
-
raise TypeError
|
57 |
-
return True
|
58 |
-
|
59 |
-
def add_text(history, text):
|
60 |
-
history = history + [(text, None)]
|
61 |
-
yield history, ""
|
62 |
-
|
63 |
-
|
64 |
-
import gradio as gr
|
65 |
-
|
66 |
-
def main():
|
67 |
-
with gr.Blocks() as demo:
|
68 |
-
gr.Markdown("## KadiAPY - AI Coding-Assistant")
|
69 |
-
gr.Markdown("AI assistant for KadiAPY based on RAG architecture powered by LLM")
|
70 |
-
|
71 |
-
with gr.Tab("KadiAPY - AI Assistant"):
|
72 |
-
with gr.Row():
|
73 |
-
with gr.Column(scale=10):
|
74 |
-
chatbot = gr.Chatbot([], elem_id="chatbot", label="Kadi Bot", bubble_full_width=False, show_copy_button=True, height=600)
|
75 |
-
user_txt = gr.Textbox(label="Question", placeholder="Type in your question and press Enter or click Submit")
|
76 |
-
|
77 |
-
with gr.Row():
|
78 |
-
with gr.Column(scale=1):
|
79 |
-
submit_btn = gr.Button("Submit", variant="primary")
|
80 |
-
with gr.Column(scale=1):
|
81 |
-
clear_btn = gr.Button("Clear", variant="stop")
|
82 |
-
|
83 |
-
gr.Examples(
|
84 |
-
examples=[
|
85 |
-
"Write me a python script with which can convert plain JSON to a Kadi4Mat-compatible extra metadata structure",
|
86 |
-
"I need a method to upload a file to a record. The id of the record is 3",
|
87 |
-
],
|
88 |
-
inputs=user_txt,
|
89 |
-
outputs=chatbot,
|
90 |
-
fn=add_text,
|
91 |
-
label="Try asking...",
|
92 |
-
cache_examples=False,
|
93 |
-
examples_per_page=3,
|
94 |
-
)
|
95 |
-
|
96 |
-
user_txt.submit(check_input_text, user_txt, None).success(add_text, [chatbot, user_txt], [chatbot, user_txt]).then(bot_kadi, [chatbot], [chatbot])
|
97 |
-
submit_btn.click(check_input_text, user_txt, None).success(add_text, [chatbot, user_txt], [chatbot, user_txt]).then(bot_kadi, [chatbot], [chatbot])
|
98 |
-
clear_btn.click(lambda: None, None, chatbot, queue=False)
|
99 |
-
|
100 |
-
demo.launch()
|
101 |
-
|
102 |
-
|
103 |
import gradio as gr
|
104 |
|
105 |
def add_text_to_chatbot(chat_history, user_input):
|
106 |
if user_input:
|
107 |
-
chat_history.append((
|
108 |
response = "This is a placeholder response. Replace this with your AI logic."
|
109 |
-
chat_history.append(("
|
110 |
return chat_history, ""
|
111 |
|
112 |
def main():
|
|
|
48 |
yield history
|
49 |
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
import gradio as gr
|
52 |
|
53 |
def add_text_to_chatbot(chat_history, user_input):
|
54 |
if user_input:
|
55 |
+
chat_history.append((None, user_input))
|
56 |
response = "This is a placeholder response. Replace this with your AI logic."
|
57 |
+
chat_history.append(("response", None))
|
58 |
return chat_history, ""
|
59 |
|
60 |
def main():
|