Spaces:
Runtime error
Runtime error
πwπ
Browse files
app.py
CHANGED
|
@@ -103,64 +103,6 @@ def talk(prompt,history):
|
|
| 103 |
outputs.append(text)
|
| 104 |
print(outputs)
|
| 105 |
yield "".join(outputs)
|
| 106 |
-
|
| 107 |
-
# def talk(message, history):
|
| 108 |
-
# print("history, ", history)
|
| 109 |
-
# print("message ", message)
|
| 110 |
-
# print("searching dataset ...")
|
| 111 |
-
# retrieved_examples = search(message)
|
| 112 |
-
# print("preparing prompt ...")
|
| 113 |
-
# message, metadata = prepare_prompt(message, retrieved_examples)
|
| 114 |
-
# resources = HEADER
|
| 115 |
-
# print("preparing metadata ...")
|
| 116 |
-
# for title, url in metadata:
|
| 117 |
-
# resources += f"[{title}]({url}), "
|
| 118 |
-
# print("preparing chat template ...")
|
| 119 |
-
# chat = []
|
| 120 |
-
# for item in history:
|
| 121 |
-
# chat.append({"role": "user", "content": item[0]})
|
| 122 |
-
# cleaned_past = item[1].split(HEADER)[0]
|
| 123 |
-
# chat.append({"role": "assistant", "content": cleaned_past})
|
| 124 |
-
# chat.append({"role": "user", "content": message})
|
| 125 |
-
# messages = tokenizer.apply_chat_template(
|
| 126 |
-
# chat, tokenize=False, add_generation_prompt=True
|
| 127 |
-
# )
|
| 128 |
-
# print("chat template prepared, ", messages)
|
| 129 |
-
# print("tokenizing input ...")
|
| 130 |
-
# # Tokenize the messages string
|
| 131 |
-
# model_inputs = tokenizer([messages], return_tensors="pt").to(device)
|
| 132 |
-
# streamer = TextIteratorStreamer(
|
| 133 |
-
# tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True
|
| 134 |
-
# )
|
| 135 |
-
# generate_kwargs = dict(
|
| 136 |
-
# model_inputs,
|
| 137 |
-
# streamer=streamer,
|
| 138 |
-
# max_new_tokens=1024,
|
| 139 |
-
# do_sample=True,
|
| 140 |
-
# top_p=0.95,
|
| 141 |
-
# top_k=1000,
|
| 142 |
-
# temperature=0.75,
|
| 143 |
-
# num_beams=1,
|
| 144 |
-
# )
|
| 145 |
-
# print("initializing thread ...")
|
| 146 |
-
# t = Thread(target=model.generate, kwargs=generate_kwargs)
|
| 147 |
-
# t.start()
|
| 148 |
-
# time.sleep(1)
|
| 149 |
-
# # Initialize an empty string to store the generated text
|
| 150 |
-
# partial_text = ""
|
| 151 |
-
# i = 0
|
| 152 |
-
# while t.is_alive():
|
| 153 |
-
# try:
|
| 154 |
-
# for new_text in streamer:
|
| 155 |
-
# if new_text is not None:
|
| 156 |
-
# partial_text += new_text
|
| 157 |
-
# yield partial_text
|
| 158 |
-
# except Exception as e:
|
| 159 |
-
# print(f"retry number {i}\n LOGS:\n")
|
| 160 |
-
# i+=1
|
| 161 |
-
# print(e, e.args)
|
| 162 |
-
# partial_text += resources
|
| 163 |
-
# yield partial_text
|
| 164 |
|
| 165 |
|
| 166 |
TITLE = "# RAG"
|
|
|
|
| 103 |
outputs.append(text)
|
| 104 |
print(outputs)
|
| 105 |
yield "".join(outputs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
|
| 108 |
TITLE = "# RAG"
|