Ctaake commited on
Commit
18d2d35
·
verified ·
1 Parent(s): 88db26a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -45,6 +45,16 @@ def format_prompt_gemma(message,chatbot,sytem_prompt):
45
  messages, tokenize=False, add_generation_prompt=True, return_tensors="pt")
46
  return newPrompt
47
 
 
 
 
 
 
 
 
 
 
 
48
  def inference(message, history, systemPrompt=SYSTEM_PROMPT+SYSTEM_PROMPT_PLUS, temperature=0.9, maxTokens=512, topP=0.9, repPenalty=1.1):
49
  # Updating the settings for the generation
50
  client_settings = dict(
@@ -59,7 +69,7 @@ def inference(message, history, systemPrompt=SYSTEM_PROMPT+SYSTEM_PROMPT_PLUS, t
59
  seed=random.randint(0, 999999999),
60
  )
61
  # Generating the response by passing the prompt in right format plus the client settings
62
- stream = client.text_generation(format_prompt(message, history, systemPrompt),
63
  **client_settings)
64
  # Reading the stream
65
  partial_response = ""
 
45
  messages, tokenize=False, add_generation_prompt=True, return_tensors="pt")
46
  return newPrompt
47
 
48
+ def format_prompt_nous(message,chatbot,sytem_prompt):
49
+ fullPrompt =f"<|im_start|>system/n{sytem_prompt}<|im_end|>/n"
50
+ for user_message, bot_message in chatbot:
51
+ fullPrompt +=f"<|im_start|>user/n{user_message}<|im_end|>/n"
52
+ fullPrompt +=f"<|im_start|>assistant/n{bot_message}<|im_end|>/n"
53
+ fullPrompt +=f"<|im_start|>user/n{message}<|im_end|>/n"
54
+ fullPrompt +=f"<|im_start|>assistant"
55
+ return newPrompt
56
+
57
+
58
  def inference(message, history, systemPrompt=SYSTEM_PROMPT+SYSTEM_PROMPT_PLUS, temperature=0.9, maxTokens=512, topP=0.9, repPenalty=1.1):
59
  # Updating the settings for the generation
60
  client_settings = dict(
 
69
  seed=random.randint(0, 999999999),
70
  )
71
  # Generating the response by passing the prompt in right format plus the client settings
72
+ stream = client.text_generation(format_prompt_nous(message, history, systemPrompt),
73
  **client_settings)
74
  # Reading the stream
75
  partial_response = ""