Spaces:
Runtime error
Runtime error
Commit
·
0f8a902
1
Parent(s):
2c4f22d
Update main.py
Browse files
main.py
CHANGED
@@ -4,6 +4,8 @@ import time
|
|
4 |
from flask_cors import CORS
|
5 |
import yaml
|
6 |
import re
|
|
|
|
|
7 |
|
8 |
|
9 |
# Model dependencies :
|
@@ -13,7 +15,6 @@ import qdrant_client
|
|
13 |
import os
|
14 |
from sentence_transformers import SentenceTransformer
|
15 |
|
16 |
-
|
17 |
#model = SentenceTransformer('sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2') # good so far
|
18 |
model = SentenceTransformer('/code/vectorizing_model', cache_folder='/')
|
19 |
|
@@ -46,7 +47,6 @@ def filtergpt(text):
|
|
46 |
gpt_results = [(law, str(int(article)) if article.is_integer() else str(article)) for law, article in law_article_list]
|
47 |
return gpt_results
|
48 |
|
49 |
-
import ast
|
50 |
|
51 |
def perform_search_and_get_results(collection_name, query, limit=30):
|
52 |
search_results = client.search(
|
@@ -326,6 +326,26 @@ def generateQuestions():
|
|
326 |
except Exception as e:
|
327 |
return jsonify({'error': str(e)}), 500
|
328 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
|
330 |
if __name__ == '__main__':
|
331 |
app.debug = True
|
|
|
4 |
from flask_cors import CORS
|
5 |
import yaml
|
6 |
import re
|
7 |
+
import ast
|
8 |
+
|
9 |
|
10 |
|
11 |
# Model dependencies :
|
|
|
15 |
import os
|
16 |
from sentence_transformers import SentenceTransformer
|
17 |
|
|
|
18 |
#model = SentenceTransformer('sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2') # good so far
|
19 |
model = SentenceTransformer('/code/vectorizing_model', cache_folder='/')
|
20 |
|
|
|
47 |
gpt_results = [(law, str(int(article)) if article.is_integer() else str(article)) for law, article in law_article_list]
|
48 |
return gpt_results
|
49 |
|
|
|
50 |
|
51 |
def perform_search_and_get_results(collection_name, query, limit=30):
|
52 |
search_results = client.search(
|
|
|
326 |
except Exception as e:
|
327 |
return jsonify({'error': str(e)}), 500
|
328 |
|
329 |
+
# Yazid Methode starts here
|
330 |
+
@app.route('/ask', methods=['OPTIONS'])
|
331 |
+
def options_ask():
|
332 |
+
response = make_response()
|
333 |
+
response.headers.add("Access-Control-Allow-Origin", "*")
|
334 |
+
response.headers.add("Access-Control-Allow-Methods", "POST")
|
335 |
+
response.headers.add("Access-Control-Allow-Headers", "Content-Type, Authorization")
|
336 |
+
response.headers.add("Access-Control-Allow-Credentials", "true")
|
337 |
+
return response
|
338 |
+
|
339 |
+
@app.route('/ask', methods=['POST'])
|
340 |
+
def ask_question():
|
341 |
+
data = request.get_json()
|
342 |
+
question = data.get('question', '')
|
343 |
+
|
344 |
+
# Call your conversation logic here
|
345 |
+
result = conversation.ask_question(question)
|
346 |
+
|
347 |
+
return jsonify(result)
|
348 |
+
# Yazid Methode ends here
|
349 |
|
350 |
if __name__ == '__main__':
|
351 |
app.debug = True
|