Spaces:
Build error
Build error
Samuel L Meyers
commited on
Commit
·
9a75ff9
1
Parent(s):
aed5924
NOW. We say hello to the future.
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ import torch
|
|
| 6 |
|
| 7 |
from conversation import get_default_conv_template
|
| 8 |
import gradio as gr
|
| 9 |
-
from llama_cpp import Llama
|
| 10 |
import json
|
| 11 |
|
| 12 |
"""
|
|
@@ -37,12 +37,15 @@ def m3b_talk(text):
|
|
| 37 |
resp = ""
|
| 38 |
formattedQuery = "<s> [|User|]" + text + "</s> [|Assistant|]"
|
| 39 |
|
| 40 |
-
for token in lcpp_model(formattedQuery, stop=["[|User|]", "\n"], echo=True):
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
| 42 |
print(resp)
|
| 43 |
-
jsn = json.loads(resp)
|
| 44 |
-
answer = jsn["choices"][0]["text"].replace(formattedQuery, "")
|
| 45 |
-
return
|
| 46 |
|
| 47 |
def main():
|
| 48 |
logging.basicConfig(level=logging.INFO)
|
|
@@ -59,7 +62,7 @@ def main():
|
|
| 59 |
|
| 60 |
m3b_talk_btn.click(m3b_talk, inputs=m3b_talk_input, outputs=m3b_talk_output, api_name="talk_m3b")
|
| 61 |
|
| 62 |
-
demo.queue(
|
| 63 |
|
| 64 |
|
| 65 |
if __name__ == "__main__":
|
|
|
|
| 6 |
|
| 7 |
from conversation import get_default_conv_template
|
| 8 |
import gradio as gr
|
| 9 |
+
from llama_cpp import Llama, CompletionChunk
|
| 10 |
import json
|
| 11 |
|
| 12 |
"""
|
|
|
|
| 37 |
resp = ""
|
| 38 |
formattedQuery = "<s> [|User|]" + text + "</s> [|Assistant|]"
|
| 39 |
|
| 40 |
+
# for token in lcpp_model(formattedQuery, stop=["[|User|]", "\n"], echo=True):
|
| 41 |
+
# resp += lccp_model.detokenize(token)
|
| 42 |
+
r = lcpp_model(formattedQuery, stop=["[|User|]", "\n"], echo=True)
|
| 43 |
+
for c in r["choices"]:
|
| 44 |
+
resp += c["text"]
|
| 45 |
print(resp)
|
| 46 |
+
# jsn = json.loads(resp)
|
| 47 |
+
# answer = jsn["choices"][0]["text"].replace(formattedQuery, "")
|
| 48 |
+
return resp.replace(formattedQuery, "")
|
| 49 |
|
| 50 |
def main():
|
| 51 |
logging.basicConfig(level=logging.INFO)
|
|
|
|
| 62 |
|
| 63 |
m3b_talk_btn.click(m3b_talk, inputs=m3b_talk_input, outputs=m3b_talk_output, api_name="talk_m3b")
|
| 64 |
|
| 65 |
+
demo.queue().launch()
|
| 66 |
|
| 67 |
|
| 68 |
if __name__ == "__main__":
|