Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -622,5 +622,38 @@ def generate_key_issues():
|
|
622 |
print(f"Error generating key issues: {e}")
|
623 |
return jsonify({'error': str(e), 'key_issues': []})
|
624 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
625 |
if __name__ == '__main__':
|
626 |
app.run(host="0.0.0.0", port=7860)
|
|
|
622 |
print(f"Error generating key issues: {e}")
|
623 |
return jsonify({'error': str(e), 'key_issues': []})
|
624 |
|
625 |
+
@app.route('/generate-prior-art', methods=['POST'])
|
626 |
+
def generate_prior_art():
|
627 |
+
data = request.json
|
628 |
+
if not data or 'keys_issues' not in data or 'technical_topic' not in data:
|
629 |
+
return jsonify({'error': 'Missing required parameters', 'results': []})
|
630 |
+
|
631 |
+
try:
|
632 |
+
keys_issues = data['keys_issues']
|
633 |
+
technical_topic = data['technical_topic']
|
634 |
+
|
635 |
+
# Make a request to the external API
|
636 |
+
API_URL = "https://organizedprogrammers-fastapi-kig.hf.space"
|
637 |
+
endpoint = f"{API_URL}/create-several-probdesc"
|
638 |
+
api_data = {
|
639 |
+
"keys_issues": keys_issues,
|
640 |
+
"technical_topic": technical_topic
|
641 |
+
}
|
642 |
+
print(api_data)
|
643 |
+
response = requests.post(endpoint, json=api_data, verify=False)
|
644 |
+
if response.status_code == 200:
|
645 |
+
result = response.json()
|
646 |
+
return jsonify(result)
|
647 |
+
else:
|
648 |
+
return jsonify({
|
649 |
+
'error': f"API Error: {response.status_code}",
|
650 |
+
'results': []
|
651 |
+
})
|
652 |
+
|
653 |
+
except Exception as e:
|
654 |
+
print(f"Error generating prior art: {e}")
|
655 |
+
return jsonify({'error': str(e), 'results': []})
|
656 |
+
|
657 |
+
|
658 |
if __name__ == '__main__':
|
659 |
app.run(host="0.0.0.0", port=7860)
|