broadfield commited on
Commit
322f7aa
·
verified ·
1 Parent(s): 185bc9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -5
app.py CHANGED
@@ -27,6 +27,20 @@ clients = [
27
  {'type':'text','name':'meta-llama/Llama-3.3-70B-Instruct','rank':'pro','max_tokens':16384,'schema':{'bos':'<|im_start|>','eos':'<|im_end|>'}},
28
  {'type':'text','name':'mistralai/Mixtral-8x7B-Instruct-v0.1','rank':'op','max_tokens':40000,'schema':{'bos':'<s>','eos':'</s>'}},
29
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  def generate(prompt,history,mod=2,tok=4000,seed=1,role="ASSISTANT",data=None):
31
  #print("#####",history,"######")
32
  gen_images=False
@@ -45,17 +59,17 @@ def generate(prompt,history,mod=2,tok=4000,seed=1,role="ASSISTANT",data=None):
45
  lod=[]
46
  if role == "ASSISTANT":
47
  system_prompt = prompts.ASSISTANT
48
- formatted_prompt = format_prompt(f'USER:{prompt}', history, system_prompt)
49
  elif role == "CREATE_FILE":
50
  system_prompt = prompts.CREATE_FILE.replace("**FILENAME**",str(data[4]))
51
- formatted_prompt = format_prompt(prompt, history, system_prompt)
52
  elif role == "MANAGER":
53
  system_prompt = prompts.MANAGER.replace("**TIMELINE**",data[4]).replace("**HISTORY**",str(history))
54
- formatted_prompt = format_prompt(prompt, history, system_prompt)
55
  elif role == "SEARCH":
56
  system_prompt = prompts.SEARCH.replace("**DATA**",data)
57
- formatted_prompt = format_prompt(f'USER:{prompt}', history, system_prompt)
58
- else: system_prompt = "";formatted_prompt = format_prompt(f'USER:{prompt}', history, system_prompt)
59
 
60
  if tok==None:tok=client_tok-len(formatted_prompt)+10
61
  print("tok",tok)
 
27
  {'type':'text','name':'meta-llama/Llama-3.3-70B-Instruct','rank':'pro','max_tokens':16384,'schema':{'bos':'<|im_start|>','eos':'<|im_end|>'}},
28
  {'type':'text','name':'mistralai/Mixtral-8x7B-Instruct-v0.1','rank':'op','max_tokens':40000,'schema':{'bos':'<s>','eos':'</s>'}},
29
  ]
30
+
31
+ def format_prompt(message, mod, system):
32
+ eos=f"{clients[int(mod)]['schema']['eos']}\n"
33
+ bos=f"{clients[int(mod)]['schema']['bos']}\n"
34
+ print("^^^^^^^",history,"^^^^^^^^")
35
+ prompt=""
36
+ prompt+=bos
37
+ prompt+=system
38
+ prompt+=eos
39
+ prompt+=bos
40
+ prompt += f"[INST] {message} [/INST]"
41
+ prompt+=eos
42
+ prompt+=bos
43
+ return prompt
44
  def generate(prompt,history,mod=2,tok=4000,seed=1,role="ASSISTANT",data=None):
45
  #print("#####",history,"######")
46
  gen_images=False
 
59
  lod=[]
60
  if role == "ASSISTANT":
61
  system_prompt = prompts.ASSISTANT
62
+ formatted_prompt = format_prompt(f'USER:{prompt}', mod, system_prompt)
63
  elif role == "CREATE_FILE":
64
  system_prompt = prompts.CREATE_FILE.replace("**FILENAME**",str(data[4]))
65
+ formatted_prompt = format_prompt(prompt, mod, system_prompt)
66
  elif role == "MANAGER":
67
  system_prompt = prompts.MANAGER.replace("**TIMELINE**",data[4]).replace("**HISTORY**",str(history))
68
+ formatted_prompt = format_prompt(prompt, mod, system_prompt)
69
  elif role == "SEARCH":
70
  system_prompt = prompts.SEARCH.replace("**DATA**",data)
71
+ formatted_prompt = format_prompt(f'USER:{prompt}', mod, system_prompt)
72
+ else: system_prompt = "";formatted_prompt = format_prompt(f'USER:{prompt}', mod, system_prompt)
73
 
74
  if tok==None:tok=client_tok-len(formatted_prompt)+10
75
  print("tok",tok)