Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -33,7 +33,7 @@ def run_model(input_ids, model, max_new_tokens, top_p, top_k, temperature, repet
|
|
33 |
def generate_text(mode: str, message: str, chat_history: List[Tuple[str, str]], max_new_tokens: int = DEFAULT_MAX_NEW_TOKENS,
|
34 |
temperature: float = 0.6, top_p: float = 0.7, top_k: int = 20, repetition_penalty: float = 1.0) -> Iterator[str]:
|
35 |
conversation = [{"role": "user", "content": user} for user, _ in chat_history]
|
36 |
-
conversation.
|
37 |
conversation.append({"role": "user", "content": message})
|
38 |
|
39 |
context = "\n".join(f"{entry['role']}: {entry['content']}" for entry in conversation)
|
@@ -62,7 +62,7 @@ with gr.Blocks() as demo:
|
|
62 |
mode_selector = gr.Radio(["generate", "edit"], label="Mode", value="generate")
|
63 |
input_text = gr.Textbox(label="Input Text")
|
64 |
output_text = gr.Textbox(label="Output")
|
65 |
-
chat_history = gr.State(default=[])
|
66 |
|
67 |
generate_button = gr.Button("Generate/Edit")
|
68 |
generate_button.click(switch_mode, inputs=[mode_selector, input_text, chat_history], outputs=output_text)
|
|
|
33 |
def generate_text(mode: str, message: str, chat_history: List[Tuple[str, str]], max_new_tokens: int = DEFAULT_MAX_NEW_TOKENS,
|
34 |
temperature: float = 0.6, top_p: float = 0.7, top_k: int = 20, repetition_penalty: float = 1.0) -> Iterator[str]:
|
35 |
conversation = [{"role": "user", "content": user} for user, _ in chat_history]
|
36 |
+
conversation.extend([{"role": "assistant", "content": assistant} for _, assistant in chat_history])
|
37 |
conversation.append({"role": "user", "content": message})
|
38 |
|
39 |
context = "\n".join(f"{entry['role']}: {entry['content']}" for entry in conversation)
|
|
|
62 |
mode_selector = gr.Radio(["generate", "edit"], label="Mode", value="generate")
|
63 |
input_text = gr.Textbox(label="Input Text")
|
64 |
output_text = gr.Textbox(label="Output")
|
65 |
+
chat_history = gr.State(default=[]) # Corrected 'default' keyword
|
66 |
|
67 |
generate_button = gr.Button("Generate/Edit")
|
68 |
generate_button.click(switch_mode, inputs=[mode_selector, input_text, chat_history], outputs=output_text)
|