Spaces:
Configuration error
Configuration error
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,12 +41,12 @@ def generate(
|
|
| 41 |
top_k: int = 50,
|
| 42 |
repetition_penalty: float = 1.2,
|
| 43 |
) -> Iterator[str]:
|
| 44 |
-
conversation =
|
| 45 |
if system_prompt:
|
| 46 |
-
conversation
|
| 47 |
for user, assistant in chat_history:
|
| 48 |
-
conversation
|
| 49 |
-
conversation
|
| 50 |
|
| 51 |
input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt", add_generation_prompt=True)
|
| 52 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|
|
@@ -130,4 +130,4 @@ with gr.Blocks(css="style.css") as demo:
|
|
| 130 |
chat_interface.render()
|
| 131 |
|
| 132 |
if __name__ == "__main__":
|
| 133 |
-
demo.queue(max_size=20).launch()
|
|
|
|
| 41 |
top_k: int = 50,
|
| 42 |
repetition_penalty: float = 1.2,
|
| 43 |
) -> Iterator[str]:
|
| 44 |
+
conversation = ""
|
| 45 |
if system_prompt:
|
| 46 |
+
conversation += f"system: You are an AI assistant.\n"
|
| 47 |
for user, assistant in chat_history:
|
| 48 |
+
conversation += f"user: {user}\nassistant: {assistant}\n"
|
| 49 |
+
conversation += f"user: {message}\n"
|
| 50 |
|
| 51 |
input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt", add_generation_prompt=True)
|
| 52 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|
|
|
|
| 130 |
chat_interface.render()
|
| 131 |
|
| 132 |
if __name__ == "__main__":
|
| 133 |
+
demo.queue(max_size=20).launch()
|