Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,9 @@ import spacy
|
|
6 |
spacy.cli.download('en_core_web_sm')
|
7 |
nlp = spacy.load('en_core_web_sm')
|
8 |
|
|
|
|
|
|
|
9 |
from rake_nltk import Rake
|
10 |
r = Rake()
|
11 |
|
@@ -74,7 +77,13 @@ def merlin_chat(message, history):
|
|
74 |
user_msg = {'role': 'user', 'content': message}
|
75 |
prompt = "[" + json.dumps(system_msg) + chat_json + json.dumps(user_msg) + "{'role': 'assistant, 'content': '*recalls \""
|
76 |
for attempt in range(3):
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
start = 0
|
79 |
end = 0
|
80 |
cleanStr = response.lstrip()
|
@@ -90,6 +99,6 @@ def merlin_chat(message, history):
|
|
90 |
if message['role'] != 'assistant':
|
91 |
continue
|
92 |
return message['content']
|
93 |
-
return "
|
94 |
|
95 |
gr.ChatInterface(merlin_chat).launch()
|
|
|
6 |
spacy.cli.download('en_core_web_sm')
|
7 |
nlp = spacy.load('en_core_web_sm')
|
8 |
|
9 |
+
import nltk
|
10 |
+
nltk.download('stopwords')
|
11 |
+
|
12 |
from rake_nltk import Rake
|
13 |
r = Rake()
|
14 |
|
|
|
77 |
user_msg = {'role': 'user', 'content': message}
|
78 |
prompt = "[" + json.dumps(system_msg) + chat_json + json.dumps(user_msg) + "{'role': 'assistant, 'content': '*recalls \""
|
79 |
for attempt in range(3):
|
80 |
+
result = model(
|
81 |
+
prompt,
|
82 |
+
return_full_text=False,
|
83 |
+
max_length=250,
|
84 |
+
handle_long_generation="hole"
|
85 |
+
)
|
86 |
+
response = result[0]['generated_text']
|
87 |
start = 0
|
88 |
end = 0
|
89 |
cleanStr = response.lstrip()
|
|
|
99 |
if message['role'] != 'assistant':
|
100 |
continue
|
101 |
return message['content']
|
102 |
+
return "🤔"
|
103 |
|
104 |
gr.ChatInterface(merlin_chat).launch()
|