om4r932 commited on
Commit
2371252
·
1 Parent(s): 2889d8b

Change KIG (from hardcoded to real gen) + create local endpoints

Browse files
Files changed (2) hide show
  1. app.py +54 -28
  2. static/script.js +2 -2
app.py CHANGED
@@ -339,6 +339,60 @@ def extract_insights(patent_background, url, data_type="pdf"):
339
  def home():
340
  return render_template('index.html')
341
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
  @app.route('/chat', methods=['POST'])
343
  def chat():
344
  user_message = request.form.get('message')
@@ -595,33 +649,5 @@ ALL AVAILABLE INSIGHTS:
595
  print(f"Error in AI insight selection: {e}")
596
  return jsonify({'error': str(e), 'selected_insights': []})
597
 
598
- @app.route('/generate-key-issues', methods=['POST'])
599
- def generate_key_issues():
600
- data = request.json
601
- if not data or 'query' not in data:
602
- return jsonify({'error': 'No query provided', 'key_issues': []})
603
-
604
- try:
605
- query = data['query']
606
-
607
- # Make a request to the external API
608
- API_URL = "https://organizedprogrammers-fastapi-kig.hf.space/"
609
- endpoint = f"{API_URL}/key-issue-format"
610
- api_data = {"query": query}
611
-
612
- response = requests.post(endpoint, json=api_data, verify=False)
613
- if response.status_code == 200:
614
- result = response.json()
615
- return jsonify(result)
616
- else:
617
- return jsonify({
618
- 'error': f"API Error: {response.status_code}",
619
- 'key_issues': []
620
- })
621
-
622
- except Exception as e:
623
- print(f"Error generating key issues: {e}")
624
- return jsonify({'error': str(e), 'key_issues': []})
625
-
626
  if __name__ == '__main__':
627
  app.run(host="0.0.0.0", port=7860)
 
339
  def home():
340
  return render_template('index.html')
341
 
342
+ @app.route('/create-several-probdesc', methods=['POST'])
343
+ def create_several_probdesc():
344
+ data = request.json
345
+ if not data or 'descriptions' not in data or 'challenges' not in data or 'technical_topic' not in data:
346
+ return jsonify({'error': 'Missing required parameters', 'queries': []})
347
+
348
+ try:
349
+ # Make a request to the external API
350
+ API_URL = "https://organizedprogrammers-fastapi-kig.hf.space/"
351
+ endpoint = f"{API_URL}/create-several-probdesc"
352
+ api_data = data
353
+
354
+ response = requests.post(endpoint, json=api_data, verify=False)
355
+ if response.status_code == 200:
356
+ result = response.json()
357
+ return jsonify(result)
358
+ else:
359
+ return jsonify({
360
+ 'error': f"API Error: {response.status_code}",
361
+ 'queries': []
362
+ })
363
+
364
+ except Exception as e:
365
+ print(f"Error generating key issues: {e}")
366
+ return jsonify({'error': str(e), 'queries': []})
367
+
368
+ @app.route('/generate-key-issues', methods=['POST'])
369
+ def generate_key_issues():
370
+ data = request.json
371
+ if not data or 'query' not in data:
372
+ return jsonify({'error': 'No query provided', 'key_issues': []})
373
+
374
+ try:
375
+ query = data['query']
376
+
377
+ # Make a request to the external API
378
+ API_URL = "https://organizedprogrammers-fastapi-kig.hf.space/"
379
+ endpoint = f"{API_URL}/generate-key-issues"
380
+ api_data = {"query": query}
381
+
382
+ response = requests.post(endpoint, json=api_data, verify=False)
383
+ if response.status_code == 200:
384
+ result = response.json()
385
+ return jsonify(result)
386
+ else:
387
+ return jsonify({
388
+ 'error': f"API Error: {response.status_code}",
389
+ 'key_issues': []
390
+ })
391
+
392
+ except Exception as e:
393
+ print(f"Error generating key issues: {e}")
394
+ return jsonify({'error': str(e), 'key_issues': []})
395
+
396
  @app.route('/chat', methods=['POST'])
397
  def chat():
398
  user_message = request.form.get('message')
 
649
  print(f"Error in AI insight selection: {e}")
650
  return jsonify({'error': str(e), 'selected_insights': []})
651
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
652
  if __name__ == '__main__':
653
  app.run(host="0.0.0.0", port=7860)
static/script.js CHANGED
@@ -50,7 +50,7 @@ function generateQueries(event) {
50
  document.getElementById('globalLoadingOverlay').style.display = 'flex';
51
 
52
  // Send message to Flask backend
53
- fetch('https://organizedprogrammers-fastapi-kig.hf.space/key-issue-format', {
54
  method: 'POST',
55
  body: JSON.stringify({ 'query': userInput }),
56
  headers: { 'Content-Type': 'application/json' }
@@ -2009,7 +2009,7 @@ function generateProblemDescriptions(){
2009
  document.getElementById('globalLoadingOverlay').style.display = 'flex';
2010
 
2011
  // Send message to Flask backend
2012
- fetch('https://organizedprogrammers-fastapi-kig.hf.space/create-several-probdesc', {
2013
  method: 'POST',
2014
  body: JSON.stringify(result),
2015
  headers: { 'Content-Type': 'application/json' }
 
50
  document.getElementById('globalLoadingOverlay').style.display = 'flex';
51
 
52
  // Send message to Flask backend
53
+ fetch('/generate-key-issues', {
54
  method: 'POST',
55
  body: JSON.stringify({ 'query': userInput }),
56
  headers: { 'Content-Type': 'application/json' }
 
2009
  document.getElementById('globalLoadingOverlay').style.display = 'flex';
2010
 
2011
  // Send message to Flask backend
2012
+ fetch('/create-several-probdesc', {
2013
  method: 'POST',
2014
  body: JSON.stringify(result),
2015
  headers: { 'Content-Type': 'application/json' }