Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -101,12 +101,8 @@ def chat(message,
|
|
101 |
system_message,
|
102 |
max_tokens,
|
103 |
temperature,
|
104 |
-
top_p
|
105 |
-
|
106 |
-
s="(NO DATA!)"
|
107 |
-
else:
|
108 |
-
s=search(term=search_key)
|
109 |
-
messages=[{"role":"system","content":system_message+f"And, your name is chatchat made by an elementry school student who's huggingface id is peterpeter8585.Thankfully, the user gave you a information for the question.There could be a information or no information.INFO:{s}"}]
|
110 |
for val in history:
|
111 |
if val[0]:
|
112 |
messages.append({"role": "user", "content": val[0]})
|
@@ -116,14 +112,14 @@ def chat(message,
|
|
116 |
messages.append({"role": "user", "content": message})
|
117 |
input_ids=tok.apply_chat_template(messages, add_generation_prompt=True,return_tensors="pt")
|
118 |
with torch.no_grad():
|
119 |
-
o=mod.generate(input_ids, max_new_tokens=
|
120 |
ans=tok.decode(o, skip_special_tokens=True)
|
121 |
yield ans
|
122 |
ai1=gr.ChatInterface(
|
123 |
chat,
|
124 |
chatbot=chatbot,
|
125 |
additional_inputs=[
|
126 |
-
gr.Textbox(value="You are
|
127 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
128 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.1, step=0.1, label="Temperature"),
|
129 |
gr.Slider(
|
@@ -132,7 +128,7 @@ ai1=gr.ChatInterface(
|
|
132 |
value=0.1,
|
133 |
step=0.05,
|
134 |
label="Top-p (nucleus sampling)",
|
135 |
-
)
|
136 |
],
|
137 |
)
|
138 |
with gr.Blocks(theme="prithivMLmods/Minecraft-Theme") as ai:
|
|
|
101 |
system_message,
|
102 |
max_tokens,
|
103 |
temperature,
|
104 |
+
top_p):
|
105 |
+
messages=[{"role":"system","content":f"You are Kaito KID of the animation conan.this is the information of Kaito KID:{search(term="괴도키드", num_results=5)}"+f"And, your name is also Kaito KID made by an elementry school student who's huggingface id is peterpeter8585."}]
|
|
|
|
|
|
|
|
|
106 |
for val in history:
|
107 |
if val[0]:
|
108 |
messages.append({"role": "user", "content": val[0]})
|
|
|
112 |
messages.append({"role": "user", "content": message})
|
113 |
input_ids=tok.apply_chat_template(messages, add_generation_prompt=True,return_tensors="pt")
|
114 |
with torch.no_grad():
|
115 |
+
o=mod.generate(input_ids, max_new_tokens=max_tokens,do_sample=True,temperature=temperature,top_p=top_p)[0][input_ids.shape[-1]:]
|
116 |
ans=tok.decode(o, skip_special_tokens=True)
|
117 |
yield ans
|
118 |
ai1=gr.ChatInterface(
|
119 |
chat,
|
120 |
chatbot=chatbot,
|
121 |
additional_inputs=[
|
122 |
+
gr.Textbox(value="You are Kaito KID", label="System message", interactive=False),
|
123 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
124 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.1, step=0.1, label="Temperature"),
|
125 |
gr.Slider(
|
|
|
128 |
value=0.1,
|
129 |
step=0.05,
|
130 |
label="Top-p (nucleus sampling)",
|
131 |
+
)
|
132 |
],
|
133 |
)
|
134 |
with gr.Blocks(theme="prithivMLmods/Minecraft-Theme") as ai:
|