Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -75,65 +75,51 @@ initialize()
|
|
75 |
|
76 |
|
77 |
|
78 |
-
|
79 |
-
user_query = history[-1][0]
|
80 |
-
response = kadiAPY_bot.process_query(user_query)
|
81 |
-
history[-1] = (user_query, response)
|
82 |
-
|
83 |
-
yield history
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
# Gradio utils
|
88 |
-
def check_input_text(text):
|
89 |
-
if not text:
|
90 |
-
gr.Warning("Please input a question.")
|
91 |
-
raise TypeError
|
92 |
-
return True
|
93 |
-
|
94 |
-
def add_text(history, text):
|
95 |
-
history = history + [(text, None)]
|
96 |
-
yield history, ""
|
97 |
-
|
98 |
-
|
99 |
-
import gradio as gr
|
100 |
|
101 |
def main():
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
-
|
138 |
if __name__ == "__main__":
|
139 |
-
main()
|
|
|
75 |
|
76 |
|
77 |
|
78 |
+
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
def main():
|
81 |
+
st.set_page_config(page_title="KadiAPY - AI Coding-Assistant", layout="wide")
|
82 |
+
|
83 |
+
st.title("KadiAPY - AI Coding-Assistant")
|
84 |
+
st.markdown("AI assistant for KadiAPY based on RAG architecture powered by LLM")
|
85 |
+
|
86 |
+
tab1, tab2 = st.tabs(["KadiAPY - AI Assistant", "Try Asking"])
|
87 |
+
|
88 |
+
with tab1:
|
89 |
+
st.write("### Kadi Bot")
|
90 |
+
|
91 |
+
if "chat_history" not in st.session_state:
|
92 |
+
st.session_state.chat_history = []
|
93 |
+
|
94 |
+
# Chatbot
|
95 |
+
chatbot_placeholder = st.empty()
|
96 |
+
question = st.text_input("Question", placeholder="Type in your question and press Enter")
|
97 |
+
|
98 |
+
if st.button("Submit"):
|
99 |
+
if question:
|
100 |
+
st.session_state.chat_history.append({"User": question})
|
101 |
+
response = bot_kadi(question) # Replace `bot_kadi` with your response generation function
|
102 |
+
st.session_state.chat_history.append({"Kadi Bot": response})
|
103 |
+
|
104 |
+
if st.button("Clear"):
|
105 |
+
st.session_state.chat_history = []
|
106 |
+
|
107 |
+
for exchange in st.session_state.chat_history:
|
108 |
+
for speaker, text in exchange.items():
|
109 |
+
st.write(f"**{speaker}:** {text}")
|
110 |
+
|
111 |
+
with tab2:
|
112 |
+
st.write("### Try Asking...")
|
113 |
+
examples = [
|
114 |
+
"Write me a python script which can convert plain JSON to a Kadi4Mat-compatible extra metadata structure",
|
115 |
+
"I need a method to upload a file to a record. The id of the record is 3",
|
116 |
+
]
|
117 |
+
for example in examples:
|
118 |
+
st.write(f"- {example}")
|
119 |
+
|
120 |
+
def bot_kadi(question):
|
121 |
+
# Dummy function for the AI response, replace with your logic
|
122 |
+
return "This is a placeholder response from Kadi Bot."
|
123 |
|
|
|
124 |
if __name__ == "__main__":
|
125 |
+
main()
|