Spaces:
Running
Running
artificialguybr
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -39,14 +39,11 @@ def stream_chat(
|
|
39 |
message: str,
|
40 |
history: list,
|
41 |
system_prompt: str,
|
42 |
-
temperature: float = 0.5,
|
43 |
-
max_new_tokens: int = 32768,
|
44 |
-
top_p: float = 1.0,
|
45 |
top_k: int = 50,
|
46 |
):
|
47 |
-
print(f'message: {message}')
|
48 |
-
print(f'history: {history}')
|
49 |
-
|
50 |
full_prompt = f"<<SYS>>\n{system_prompt}\n<</SYS>>\n\n"
|
51 |
for prompt, answer in history:
|
52 |
full_prompt += f"[INST]{prompt}[/INST]{answer}"
|
@@ -69,7 +66,7 @@ def stream_chat(
|
|
69 |
|
70 |
thread = Thread(target=model.generate, kwargs=generate_kwargs)
|
71 |
thread.start()
|
72 |
-
|
73 |
buffer = ""
|
74 |
for new_text in streamer:
|
75 |
buffer += new_text
|
@@ -84,12 +81,10 @@ with gr.Blocks(css=CSS, theme="soft") as demo:
|
|
84 |
fn=stream_chat,
|
85 |
chatbot=chatbot,
|
86 |
fill_height=True,
|
87 |
-
additional_inputs_accordion=gr.Accordion(label="⚙️ Parameters", open=False),
|
88 |
additional_inputs=[
|
89 |
gr.Textbox(
|
90 |
value="You are a helpful assistant capable of generating long-form content.",
|
91 |
label="System Prompt",
|
92 |
-
visible=False,
|
93 |
),
|
94 |
gr.Slider(
|
95 |
minimum=0,
|
|
|
39 |
message: str,
|
40 |
history: list,
|
41 |
system_prompt: str,
|
42 |
+
temperature: float = 0.5,
|
43 |
+
max_new_tokens: int = 32768,
|
44 |
+
top_p: float = 1.0,
|
45 |
top_k: int = 50,
|
46 |
):
|
|
|
|
|
|
|
47 |
full_prompt = f"<<SYS>>\n{system_prompt}\n<</SYS>>\n\n"
|
48 |
for prompt, answer in history:
|
49 |
full_prompt += f"[INST]{prompt}[/INST]{answer}"
|
|
|
66 |
|
67 |
thread = Thread(target=model.generate, kwargs=generate_kwargs)
|
68 |
thread.start()
|
69 |
+
|
70 |
buffer = ""
|
71 |
for new_text in streamer:
|
72 |
buffer += new_text
|
|
|
81 |
fn=stream_chat,
|
82 |
chatbot=chatbot,
|
83 |
fill_height=True,
|
|
|
84 |
additional_inputs=[
|
85 |
gr.Textbox(
|
86 |
value="You are a helpful assistant capable of generating long-form content.",
|
87 |
label="System Prompt",
|
|
|
88 |
),
|
89 |
gr.Slider(
|
90 |
minimum=0,
|