Aspik101 commited on
Commit
dac0248
1 Parent(s): 483868d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -7,13 +7,14 @@ from dl_hf_model import dl_hf_model
7
 
8
  params = {
9
  "max_new_tokens":512,
10
- "stop":["<end>" ,"<|endoftext|>"],
11
  "temperature":0.7,
12
  "top_p":0.8,
13
  "stream":True,
14
  "batch_size": 8}
15
 
16
- url = "https://huggingface.co/Aspik101/trurl-2-13b-GGML/blob/main/trurl-2-13b.ggmlv3.q8_0.bin"
 
17
  #model_loc, file_size = dl_hf_model(url)
18
  llm = AutoModelForCausalLM.from_pretrained("Aspik101/trurl-2-13b-GGML", model_type="llama")
19
 
@@ -25,11 +26,19 @@ with gr.Blocks() as demo:
25
  def user(user_message, history):
26
  return "", history + [[user_message, None]]
27
 
 
 
 
 
 
 
 
 
28
  def bot(history):
29
- print(history)
30
- stream = llm(prompt = f"Jesteś AI assystentem. Odpowiadaj po polsku. <user>: {history}. <assistant>:", **params)
31
- #stream = llm(prompt = f"{history}", **params)
32
- #stream = llm(prompt = f"Jesteś AI assystentem. Odpowiadaj po polsku. {history}.", **params)
33
  history[-1][1] = ""
34
  answer_save = ""
35
  for character in stream:
@@ -38,8 +47,7 @@ with gr.Blocks() as demo:
38
  time.sleep(0.005)
39
  yield history
40
 
41
- print(answer_save)
42
-
43
  msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
44
  bot, chatbot, chatbot
45
  )
 
7
 
8
  params = {
9
  "max_new_tokens":512,
10
+ "stop":["<end>" ,"<|endoftext|>","["],
11
  "temperature":0.7,
12
  "top_p":0.8,
13
  "stream":True,
14
  "batch_size": 8}
15
 
16
+
17
+ #url = "https://huggingface.co/Aspik101/trurl-2-7b-GGML/blob/main/trurl-2-7b.ggmlv3.q8_0.bin"
18
  #model_loc, file_size = dl_hf_model(url)
19
  llm = AutoModelForCausalLM.from_pretrained("Aspik101/trurl-2-13b-GGML", model_type="llama")
20
 
 
26
  def user(user_message, history):
27
  return "", history + [[user_message, None]]
28
 
29
+ def parse_history(hist):
30
+ history_ = ""
31
+ for q, a in hist:
32
+ history_ += f"<user>: {q } \n"
33
+ if a:
34
+ history_ += f"<assistant>: {a} \n"
35
+ return history_
36
+
37
  def bot(history):
38
+ print("history: ",history)
39
+ prompt = f"Jesteś AI assystentem. Odpowiadaj po polsku. {parse_history(history)}. <assistant>:"
40
+ print("prompt: ",prompt)
41
+ stream = llm(prompt, **params)
42
  history[-1][1] = ""
43
  answer_save = ""
44
  for character in stream:
 
47
  time.sleep(0.005)
48
  yield history
49
 
50
+ print("answer_save: ",answer_save)
 
51
  msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
52
  bot, chatbot, chatbot
53
  )