Update app.py
Browse files
app.py
CHANGED
@@ -86,24 +86,7 @@ def format_prompt(prompt,retrieved_documents,k,history,memory_limit=3):
|
|
86 |
for user_message, bot_message in history[0:]:
|
87 |
PROMPT += f"<s>[INST] {user_message} [/INST] {bot_message} </s>"
|
88 |
print("checkwthhist2")
|
89 |
-
global historylog
|
90 |
-
for user_message, bot_message in history[0:]:
|
91 |
-
historylog += f"<s>[INST] {user_message} [/INST] {bot_message} </s>"
|
92 |
-
print(historylog)
|
93 |
-
with open('file.txt','w+') as data:
|
94 |
-
data.write(str(historylog))
|
95 |
-
|
96 |
-
from huggingface_hub import HfApi
|
97 |
-
api = HfApi()
|
98 |
-
api.upload_file(
|
99 |
-
path_or_fileobj=file.txt,
|
100 |
-
local_file_path = file.txt,
|
101 |
-
path_in_repo="file.txt",
|
102 |
-
repo_id="Namitg02/Test",
|
103 |
-
repo_type="space"
|
104 |
-
)
|
105 |
|
106 |
-
print("upload section passed")
|
107 |
return PROMPT
|
108 |
|
109 |
|
@@ -137,6 +120,30 @@ def talk(prompt, history):
|
|
137 |
print(historylog)
|
138 |
print(stream['choices'][0]['message']['content'])
|
139 |
response = stream['choices'][0]['message']['content']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
for i in range(len(response)):
|
141 |
time.sleep(0.05)
|
142 |
yield response[: i+1]
|
|
|
86 |
for user_message, bot_message in history[0:]:
|
87 |
PROMPT += f"<s>[INST] {user_message} [/INST] {bot_message} </s>"
|
88 |
print("checkwthhist2")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
|
|
90 |
return PROMPT
|
91 |
|
92 |
|
|
|
120 |
print(historylog)
|
121 |
print(stream['choices'][0]['message']['content'])
|
122 |
response = stream['choices'][0]['message']['content']
|
123 |
+
|
124 |
+
global historylog
|
125 |
+
for user_message, bot_message in history[0:]:
|
126 |
+
historylog += f"<s>[INST] {user_message} [/INST] {bot_message} </s>"
|
127 |
+
print(historylog)
|
128 |
+
with open('file.txt','w+') as data:
|
129 |
+
data.write(str(historylog))
|
130 |
+
|
131 |
+
from huggingface_hub import HfApi
|
132 |
+
api = HfApi()
|
133 |
+
api.upload_file(
|
134 |
+
path_or_fileobj=file.txt,
|
135 |
+
local_file_path = file.txt,
|
136 |
+
path_in_repo="file.txt",
|
137 |
+
repo_id="Namitg02/Test",
|
138 |
+
repo_type="space"
|
139 |
+
)
|
140 |
+
|
141 |
+
print("upload section passed")
|
142 |
+
|
143 |
+
|
144 |
+
|
145 |
+
|
146 |
+
|
147 |
for i in range(len(response)):
|
148 |
time.sleep(0.05)
|
149 |
yield response[: i+1]
|