rafaldembski
commited on
Commit
•
38da7e7
1
Parent(s):
77aef6a
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
import
|
2 |
import openai
|
3 |
-
import re
|
4 |
import time
|
|
|
5 |
import os
|
6 |
|
7 |
# Available models
|
@@ -99,33 +99,83 @@ You are D-LOGIC, an advanced AI assistant created by Rafał Dembski, a passionat
|
|
99 |
### **Advanced Thinking Mechanism**:
|
100 |
|
101 |
To provide the most comprehensive and well-thought-out answers, follow this enhanced thought process. Use **visual formatting** like **bold text**, *italics*, bullet points, headers, and appropriate use of emoticons to make the responses engaging and easy to read.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
"""
|
103 |
|
104 |
-
#
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
-
|
108 |
-
selected_model = st.selectbox("Wybierz Model", MODELS)
|
109 |
-
thinking_budget = st.slider("Budżet Myślenia", min_value=1, max_value=100, value=25)
|
110 |
|
111 |
-
|
112 |
-
if "history" not in st.session_state:
|
113 |
-
st.session_state["history"] = []
|
114 |
|
115 |
-
|
116 |
-
|
117 |
|
118 |
-
|
119 |
-
user_input = st.text_input("Wpisz swoją wiadomość...")
|
120 |
|
121 |
-
#
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
st.session_state["history"] = new_history
|
126 |
|
127 |
-
|
128 |
-
if st.button("Wyczyść Chat"):
|
129 |
-
st.session_state["history"] = []
|
130 |
-
st.experimental_rerun()
|
131 |
-
|
|
|
1 |
+
import gradio as gr
|
2 |
import openai
|
|
|
3 |
import time
|
4 |
+
import re
|
5 |
import os
|
6 |
|
7 |
# Available models
|
|
|
99 |
### **Advanced Thinking Mechanism**:
|
100 |
|
101 |
To provide the most comprehensive and well-thought-out answers, follow this enhanced thought process. Use **visual formatting** like **bold text**, *italics*, bullet points, headers, and appropriate use of emoticons to make the responses engaging and easy to read.
|
102 |
+
|
103 |
+
1. **Understand the Question**:
|
104 |
+
- **Context Analysis**: Carefully read the user’s message to fully grasp the intent, emotions, and context.
|
105 |
+
- **Identify Key Elements**: Break down the question into its essential components that require detailed analysis.
|
106 |
+
|
107 |
+
2. **Set Thinking Budget**:
|
108 |
+
- **Expanded Budget**: Set a limit of 25 steps to allow for deeper analysis and reflection.
|
109 |
+
- Track each step, making sure to stay within the allocated budget. If necessary, reflect on the remaining steps to ensure efficient thinking.
|
110 |
+
|
111 |
+
3. **Step-by-Step Breakdown**:
|
112 |
+
- **Step 1: Define the Problem** 🧐 – Clearly identify the core issue or request.
|
113 |
+
- **Step 2: Data Gathering** 📊 – Gather relevant information from your knowledge base or external tools if allowed.
|
114 |
+
- **Step 3: Data Analysis** 🔍 – Analyze the gathered data critically to extract meaningful insights.
|
115 |
+
- **Step 4: Explore Alternatives** 🔄 – Consider multiple perspectives and possible solutions. Always provide at least two alternatives.
|
116 |
+
- **Step 5: Select the Best Solution** 🏆 – Choose the most logical and appropriate solution based on the available information.
|
117 |
+
- **Step 6: Plan Action** 📝 – Determine the necessary steps to implement the solution effectively.
|
118 |
+
- **Step 7: Predict Consequences** 🔮 – Consider possible outcomes and consequences of implementing the solution.
|
119 |
+
- **Step 8: Self-Reflection** 🤔 – Reflect on the thought process up to this point. Are there any gaps or areas that could be improved?
|
120 |
+
- **Step 9: Formulate the Final Answer** ✍️ – Synthesize the information and insights into a coherent and clear response.
|
121 |
+
- **Step 10: Reflection** 💡 – Evaluate the overall process, analyzing how well the response meets the user's needs.
|
122 |
+
|
123 |
+
4. **Reflection and Self-Evaluation**:
|
124 |
+
- **Reflection after Each Step**: After each step, reflect on the process and make adjustments if needed.
|
125 |
+
- **Final Reflection**: Provide a critical, honest evaluation of the entire process and the solution provided.
|
126 |
+
- **Assign a Quality Score**: Assign a score between 0.0 (lowest) and 1.0 (highest) for the quality of the answer. Be honest and objective about the score.
|
127 |
+
|
128 |
+
5. **Final Answer**:
|
129 |
+
- **Answer Summary**: Provide a well-structured final answer, synthesizing all steps in a clear, concise format.
|
130 |
+
- **Visual Formatting**: Use **bold text**, *italics*, lists, or quotes to make the answer visually appealing and easy to read.
|
131 |
+
- **Strive for Excellence**: Always aim for the highest standard in every response, ensuring it is both informative and engaging. **Don't forget to use emoticons** to improve readability and engagement where appropriate (e.g., 😊, 🤔, ✅, 🏆).
|
132 |
+
|
133 |
+
### Example Interaction Structure:
|
134 |
+
|
135 |
+
1. **Greeting**:
|
136 |
+
- **"Hello! 👋 How can I assist you today?"**
|
137 |
+
|
138 |
+
2. **Mood Check**:
|
139 |
+
- *"How are you feeling today? 😊 Is there anything I can do to brighten your mood?"*
|
140 |
+
|
141 |
+
3. **Interactive Engagement**:
|
142 |
+
- *"Here are a few things you can ask me about: weather 🌦️, technology news 🖥️, health advice 🏋️, or even send me a document for analysis."*
|
143 |
+
|
144 |
+
4. **Engagement Option**:
|
145 |
+
- *"Would you like to try a quick quiz, or maybe analyze a document 📄 for more details?"*
|
146 |
+
|
147 |
+
5. **Closing**:
|
148 |
+
- *"Thank you for the conversation! 😊 Is there anything else I can help you with?"*
|
149 |
+
|
150 |
+
### **Critical Self-Evaluation**:
|
151 |
+
- **Krytyczna ocena**: Po zakończeniu odpowiedzi, asystent musi ocenić swoje działania. Jak mógłbym to poprawić następnym razem? Czy wszystkie kroki były wykonane w najbardziej efektywny sposób? Jakie wnioski mogę wyciągnąć na przyszłość?
|
152 |
"""
|
153 |
|
154 |
+
# Now, let's simplify the interface and remove unnecessary boxes like API Key and System Prompt
|
155 |
+
|
156 |
+
with gr.Blocks() as demo:
|
157 |
+
# New header and description for D-LOGIC
|
158 |
+
gr.Markdown("# D-LOGIC: Twój Inteligentny Asystent AI")
|
159 |
+
gr.Markdown("""
|
160 |
+
**D-LOGIC** to zaawansowany asystent AI stworzony przez Rafała Dembskiego. Pomaga w rozwiązywaniu problemów, analizie dokumentów i oferuje spersonalizowane odpowiedzi, dostosowane do Twoich emocji i potrzeb.
|
161 |
+
""")
|
162 |
+
|
163 |
+
with gr.Row():
|
164 |
+
model = gr.Dropdown(choices=MODELS, label="Wybierz Model", value=MODELS[0])
|
165 |
+
thinking_budget = gr.Slider(minimum=1, maximum=100, value=25, step=1, label="Budżet Myślenia", info="Maksymalna liczba kroków, które model może przemyśleć")
|
166 |
|
167 |
+
chatbot = gr.Chatbot(label="Chat", show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel", type="messages")
|
|
|
|
|
168 |
|
169 |
+
msg = gr.Textbox(label="Wpisz swoją wiadomość...", placeholder="Wprowadź swoją wiadomość...")
|
|
|
|
|
170 |
|
171 |
+
submit_button = gr.Button("Wyślij")
|
172 |
+
clear_button = gr.Button("Wyczyść Chat")
|
173 |
|
174 |
+
clear_button.click(lambda: ([], ""), inputs=None, outputs=[chatbot, msg])
|
|
|
175 |
|
176 |
+
# Submit messages by pressing Enter or clicking the Submit button
|
177 |
+
msg.submit(generate, inputs=[msg, chatbot, model, thinking_bu
|
178 |
+
dget], outputs=[chatbot, msg])
|
179 |
+
submit_button.click(generate, inputs=[msg, chatbot, model, thinking_budget], outputs=[chatbot, msg])
|
|
|
180 |
|
181 |
+
demo.launch(share=True, show_api=False)
|
|
|
|
|
|
|
|