Update app.py
Browse files
app.py
CHANGED
|
@@ -29,10 +29,13 @@ def chat(user_input, history):
|
|
| 29 |
history = []
|
| 30 |
|
| 31 |
context = format_context(history) + f"You: {user_input}\nπ΄ ππ πππ:"
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
|
| 34 |
outputs = model.generate(
|
| 35 |
inputs,
|
|
|
|
| 36 |
max_new_tokens=50,
|
| 37 |
temperature=0.9,
|
| 38 |
top_k=40,
|
|
@@ -51,4 +54,4 @@ def chat(user_input, history):
|
|
| 51 |
demo = gr.Interface(fn=chat, inputs=["text", "state"], outputs="state")
|
| 52 |
|
| 53 |
# Launch the app
|
| 54 |
-
demo.launch()
|
|
|
|
| 29 |
history = []
|
| 30 |
|
| 31 |
context = format_context(history) + f"You: {user_input}\nπ΄ ππ πππ:"
|
| 32 |
+
encoded = tokenizer(context, return_tensors="pt", truncation=True, max_length=1024)
|
| 33 |
+
inputs = encoded.input_ids
|
| 34 |
+
attention_mask = encoded.attention_mask
|
| 35 |
|
| 36 |
outputs = model.generate(
|
| 37 |
inputs,
|
| 38 |
+
attention_mask=attention_mask,
|
| 39 |
max_new_tokens=50,
|
| 40 |
temperature=0.9,
|
| 41 |
top_k=40,
|
|
|
|
| 54 |
demo = gr.Interface(fn=chat, inputs=["text", "state"], outputs="state")
|
| 55 |
|
| 56 |
# Launch the app
|
| 57 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|