Update app.py
Browse files
app.py
CHANGED
@@ -7,8 +7,8 @@ from flask import send_from_directory
|
|
7 |
import json
|
8 |
import numpy as np
|
9 |
import moduli
|
10 |
-
from hugchat import hugchat
|
11 |
-
from hugchat.login import Login
|
12 |
from numpy.linalg import norm
|
13 |
import datetime
|
14 |
import tensorflow as tf
|
@@ -42,7 +42,7 @@ def support_jsonp(func):
|
|
42 |
@app.route("/")
|
43 |
def flask_app():
|
44 |
return '<br>' \
|
45 |
-
'<h3><a href="
|
46 |
'<br>' \
|
47 |
'<h3><a href="https://www.ftintelligence.altervista.org/qa.php" target="_blank">Vai alla Question Answering Demo!</a></h3>'
|
48 |
|
@@ -66,42 +66,5 @@ def tasksSearch():
|
|
66 |
response = jsonify(output)
|
67 |
return response
|
68 |
|
69 |
-
@app.route('/predict', methods=['POST','GET'])
|
70 |
-
@support_jsonp
|
71 |
-
def predict():
|
72 |
-
#context=request.args.get('testo').strip()
|
73 |
-
#question=request.args.get('testo_domanda').strip()
|
74 |
-
context='il siena ha vinto lo scudetto'
|
75 |
-
question='cosa ha vinto il siena'
|
76 |
-
#question=str(request.form['testo_domanda']).strip()
|
77 |
-
#w=str(moduli.la7_Bot(context,question,hugchat))
|
78 |
-
#chatbot = hugchat.ChatBot(cookie_path="cookies.json")
|
79 |
-
#https://github.com/Soulter/hugging-chat-api
|
80 |
-
#sign = Login(os.environ.get('email'), os.environ.get('password'))
|
81 |
-
#cookies = sign.login()
|
82 |
-
#print('----------')
|
83 |
-
#print(os.environ.get('hugcookie'))
|
84 |
-
#print('----------')
|
85 |
-
prompt="Rispondi alla domanda in base al seguente contesto:\n\nContesto:"+context+"\n\nDomanda: "+question
|
86 |
-
#chatbot = hugchat.ChatBot(cookies=cookies.get_dict())
|
87 |
-
#chatbot = hugchat.ChatBot()
|
88 |
-
chatbot = hugchat.ChatBot(cookies=os.environ.get('hugcookie'))
|
89 |
-
# Log in to huggingface and grant authorization to huggingchat
|
90 |
-
# Nuova a conversazione
|
91 |
-
#id = chatbot.new_conversation()
|
92 |
-
#chatbot.change_conversation(id)
|
93 |
-
creativity=0.1
|
94 |
-
#w=chatbot.chat(prompt,temperature=creativity)
|
95 |
-
#w=chatbot.chat("HI")
|
96 |
-
w='hhhhh'
|
97 |
-
print(w)
|
98 |
-
d={}
|
99 |
-
d['risultato']=w
|
100 |
-
d['nome']='ok'
|
101 |
-
data=jsonify(d)
|
102 |
-
data.headers.add('Access-Control-Allow-Origin', '*')
|
103 |
-
return data
|
104 |
-
|
105 |
-
|
106 |
if __name__ == "__main__":
|
107 |
app.run(host='0.0.0.0', port=7860)
|
|
|
7 |
import json
|
8 |
import numpy as np
|
9 |
import moduli
|
10 |
+
#from hugchat import hugchat
|
11 |
+
#from hugchat.login import Login
|
12 |
from numpy.linalg import norm
|
13 |
import datetime
|
14 |
import tensorflow as tf
|
|
|
42 |
@app.route("/")
|
43 |
def flask_app():
|
44 |
return '<br>' \
|
45 |
+
'<h3><a href="http://15.160.75.206:5000" target="_blank">Vai alla 7Demo!</a></h3>' \
|
46 |
'<br>' \
|
47 |
'<h3><a href="https://www.ftintelligence.altervista.org/qa.php" target="_blank">Vai alla Question Answering Demo!</a></h3>'
|
48 |
|
|
|
66 |
response = jsonify(output)
|
67 |
return response
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
if __name__ == "__main__":
|
70 |
app.run(host='0.0.0.0', port=7860)
|