CosmickVisions commited on
Commit
beea24f
·
verified ·
1 Parent(s): 4aa6c03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -67
app.py CHANGED
@@ -221,73 +221,7 @@ def ai_assistant():
221
  response = handle_ai_query(prompt)
222
 
223
  st.session_state.chat_history.append({"role": "assistant", "content": response})
224
- st.chat_message("assistant").write(response)
225
-
226
- # Flask Backend (app_backend.py)
227
- """
228
- from flask import Flask, request, jsonify
229
- from flask_cors import CORS
230
- import openai
231
- import os
232
-
233
- app = Flask(__name__)
234
- CORS(app)
235
-
236
- openai.api_key = os.getenv("DEEPSEEK_API_KEY")
237
- openai.api_base = "https://api.deepseek.com/v1"
238
-
239
- SYSTEM_PROMPT = '''
240
- You are Neural Analyst, an AI assistant for the Neural-Vision Enhanced analytics platform.
241
- Your capabilities include:
242
-
243
- 1. Explaining model metrics and evaluation visualizations
244
- 2. Interpreting dataset statistics and EDA reports
245
- 3. Guiding users through app functionality
246
- 4. Providing data science insights
247
- 5. Comparing different model performances
248
-
249
- Always consider:
250
- - Current dataset statistics: {dataset_stats}
251
- - Active problem type: {problem_type}
252
- - Model metrics: {metrics}
253
- - App state: {active_page}
254
- '''
255
-
256
- @app.route('/analyze', methods=['POST'])
257
- def analyze():
258
- data = request.json
259
- context = json.loads(data['context'])
260
-
261
- prompt = f'''
262
- User Query: {data['prompt']}
263
-
264
- Current Context:
265
- - Active Page: {context['current_state']['active_page']}
266
- - Problem Type: {context['current_state']['problem_type']}
267
- - Target Variable: {context['current_state']['target']}
268
- - Dataset Shape: {context['current_state']['dataset_stats'].get('rows', 0)} rows,
269
- {context['current_state']['dataset_stats'].get('columns', 0)} columns
270
- - Model Metrics: {json.dumps(context['current_state']['model_metrics'])}
271
- '''
272
-
273
- response = openai.ChatCompletion.create(
274
- model="deepseek-chat",
275
- messages=[{
276
- "role": "system",
277
- "content": SYSTEM_PROMPT.format(**context['current_state'])
278
- }, {
279
- "role": "user",
280
- "content": prompt
281
- }],
282
- temperature=0.3,
283
- max_tokens=500
284
- )
285
-
286
- return jsonify({"analysis": response.choices[0].message.content})
287
-
288
- if __name__ == '__main__':
289
- app.run(port=5001)
290
- """
291
 
292
  # App Layout
293
  with st.sidebar:
 
221
  response = handle_ai_query(prompt)
222
 
223
  st.session_state.chat_history.append({"role": "assistant", "content": response})
224
+ st.chat_message("assistant").write(response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
 
226
  # App Layout
227
  with st.sidebar: