Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -99,6 +99,50 @@ def main():
|
|
99 |
|
100 |
demo.launch()
|
101 |
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
if __name__ == "__main__":
|
104 |
main()
|
|
|
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(("You", user_input))
|
108 |
+
response = "This is a placeholder response. Replace this with your AI logic."
|
109 |
+
chat_history.append(("Kadi Bot", response))
|
110 |
+
return chat_history, ""
|
111 |
+
|
112 |
+
def main():
|
113 |
+
with gr.Blocks() as demo:
|
114 |
+
gr.Markdown("## KadiAPY - AI Coding-Assistant")
|
115 |
+
gr.Markdown("AI assistant for KadiAPY based on RAG architecture powered by LLM")
|
116 |
+
|
117 |
+
with gr.Tab("KadiAPY - AI Assistant"):
|
118 |
+
with gr.Row():
|
119 |
+
with gr.Column(scale=10):
|
120 |
+
chatbot = gr.Chatbot([], elem_id="chatbot", label="Kadi Bot", bubble_full_width=False, show_copy_button=True, height=600)
|
121 |
+
user_txt = gr.Textbox(label="Question", placeholder="Type in your question and press Enter or click Submit")
|
122 |
+
|
123 |
+
with gr.Row():
|
124 |
+
with gr.Column(scale=1):
|
125 |
+
submit_btn = gr.Button("Submit", variant="primary")
|
126 |
+
with gr.Column(scale=1):
|
127 |
+
clear_btn = gr.Button("Clear", variant="stop")
|
128 |
+
|
129 |
+
gr.Examples(
|
130 |
+
examples=[
|
131 |
+
"Write me a python script with which can convert plain JSON to a Kadi4Mat-compatible extra metadata structure",
|
132 |
+
"I need a method to upload a file to a record. The id of the record is 3",
|
133 |
+
],
|
134 |
+
inputs=user_txt,
|
135 |
+
outputs=chatbot,
|
136 |
+
fn=add_text_to_chatbot,
|
137 |
+
label="Try asking...",
|
138 |
+
cache_examples=False,
|
139 |
+
examples_per_page=3,
|
140 |
+
)
|
141 |
+
|
142 |
+
submit_btn.click(add_text_to_chatbot, [chatbot, user_txt], [chatbot, user_txt])
|
143 |
+
clear_btn.click(lambda: ([], ""), None, [chatbot, user_txt])
|
144 |
+
|
145 |
+
demo.launch()
|
146 |
+
|
147 |
if __name__ == "__main__":
|
148 |
main()
|