Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -37,33 +37,6 @@ with open("./TA_prompt_v0.txt", "r") as f:
|
|
37 |
|
38 |
NO_PROMPT = ""
|
39 |
|
40 |
-
FIM_PREFIX = "<fim_prefix>"
|
41 |
-
FIM_MIDDLE = "<fim_middle>"
|
42 |
-
FIM_SUFFIX = "<fim_suffix>"
|
43 |
-
|
44 |
-
FIM_INDICATOR = "<FILL_HERE>"
|
45 |
-
|
46 |
-
theme = gr.themes.Monochrome(
|
47 |
-
primary_hue="indigo",
|
48 |
-
secondary_hue="blue",
|
49 |
-
neutral_hue="slate",
|
50 |
-
radius_size=gr.themes.sizes.radius_sm,
|
51 |
-
font=[
|
52 |
-
gr.themes.GoogleFont("Open Sans"),
|
53 |
-
"ui-sans-serif",
|
54 |
-
"system-ui",
|
55 |
-
"sans-serif",
|
56 |
-
],
|
57 |
-
)
|
58 |
-
|
59 |
-
client_g = Client(
|
60 |
-
API_URL_G, headers={"Authorization": f"Bearer {HF_TOKEN}"},
|
61 |
-
)
|
62 |
-
|
63 |
-
client_s = Client(
|
64 |
-
API_URL_S, headers={"Authorization": f"Bearer {HF_TOKEN}"},
|
65 |
-
)
|
66 |
-
|
67 |
def randomize_seed_generator():
|
68 |
seed = random.randint(0, 1000000)
|
69 |
return seed
|
@@ -124,21 +97,21 @@ def get_inference_prompt(messages, model_name):
|
|
124 |
for message in messages :
|
125 |
if message["role"] == "user" :
|
126 |
prompt += f"<|user|>\n{message['content']}<|endoftext|>\n<|assistant|>"
|
127 |
-
else : #message["role"] == "assistant"
|
128 |
prompt += f"{message['content']}<|endoftext|>\n"
|
129 |
elif model_name == "starChat-alpha" :
|
130 |
prompt = "<|system|>\n<|end|>\n"
|
131 |
for message in messages :
|
132 |
if message["role"] == "user" :
|
133 |
prompt += f"<|user|>\n{message['content']}<|end|>\n<|assistant|>"
|
134 |
-
else : #message["role"] == "assistant"
|
135 |
prompt += f"{message['content']}<|end|>\n"
|
136 |
else : # starCoder-gradio
|
137 |
prompt = ""
|
138 |
for message in messages :
|
139 |
if message["role"] == "user" :
|
140 |
-
prompt += f"Question: {message['content']}\n\nAnswer:"
|
141 |
-
else : #message["role"] == "assistant"
|
142 |
prompt += f"{message['content']}\n\n"
|
143 |
return prompt
|
144 |
|
|
|
37 |
|
38 |
NO_PROMPT = ""
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
def randomize_seed_generator():
|
41 |
seed = random.randint(0, 1000000)
|
42 |
return seed
|
|
|
97 |
for message in messages :
|
98 |
if message["role"] == "user" :
|
99 |
prompt += f"<|user|>\n{message['content']}<|endoftext|>\n<|assistant|>"
|
100 |
+
else : # message["role"] == "assistant"
|
101 |
prompt += f"{message['content']}<|endoftext|>\n"
|
102 |
elif model_name == "starChat-alpha" :
|
103 |
prompt = "<|system|>\n<|end|>\n"
|
104 |
for message in messages :
|
105 |
if message["role"] == "user" :
|
106 |
prompt += f"<|user|>\n{message['content']}<|end|>\n<|assistant|>"
|
107 |
+
else : # message["role"] == "assistant"
|
108 |
prompt += f"{message['content']}<|end|>\n"
|
109 |
else : # starCoder-gradio
|
110 |
prompt = ""
|
111 |
for message in messages :
|
112 |
if message["role"] == "user" :
|
113 |
+
prompt += f"Question: {message['content']}\n\nAnswer: "
|
114 |
+
else : # message["role"] == "assistant"
|
115 |
prompt += f"{message['content']}\n\n"
|
116 |
return prompt
|
117 |
|