Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -56,13 +56,18 @@ def make_prompt(entry):
|
|
56 |
@spaces.GPU
|
57 |
def generate(
|
58 |
message: str,
|
|
|
59 |
max_new_tokens: int = 1024,
|
60 |
# temperature: float = 0.1,
|
61 |
# top_p: float = 0.9,
|
62 |
# top_k: int = 40,
|
63 |
# repetition_penalty: float = 1.0,
|
64 |
-
|
65 |
) -> Iterator[str]:
|
|
|
|
|
|
|
|
|
|
|
66 |
enc = tokenizer(make_prompt(message), return_tensors="pt", padding=True, truncation=True)
|
67 |
|
68 |
|
@@ -115,4 +120,3 @@ with gr.Blocks(css="style.css") as demo:
|
|
115 |
if __name__ == "__main__":
|
116 |
demo.queue(max_size=20)
|
117 |
demo.launch(share=True)
|
118 |
-
|
|
|
56 |
@spaces.GPU
|
57 |
def generate(
|
58 |
message: str,
|
59 |
+
chat_history: list[tuple[str, str]],
|
60 |
max_new_tokens: int = 1024,
|
61 |
# temperature: float = 0.1,
|
62 |
# top_p: float = 0.9,
|
63 |
# top_k: int = 40,
|
64 |
# repetition_penalty: float = 1.0,
|
|
|
65 |
) -> Iterator[str]:
|
66 |
+
conversation = []
|
67 |
+
for user, assistant in chat_history:
|
68 |
+
conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
|
69 |
+
conversation.append({"role": "user", "content": make_prompt(message)})
|
70 |
+
|
71 |
enc = tokenizer(make_prompt(message), return_tensors="pt", padding=True, truncation=True)
|
72 |
|
73 |
|
|
|
120 |
if __name__ == "__main__":
|
121 |
demo.queue(max_size=20)
|
122 |
demo.launch(share=True)
|
|