Update app.py
Browse files
app.py
CHANGED
|
@@ -13,29 +13,9 @@ LOCAL_FLAGS = "flags.json" # You must save locally before push to hf
|
|
| 13 |
|
| 14 |
print("Loading model...")
|
| 15 |
|
| 16 |
-
llm = Llama.from_pretrained(
|
| 17 |
-
repo_id=MODEL_REPO,
|
| 18 |
-
filename=MODEL_FILE,
|
| 19 |
-
n_threads=2,
|
| 20 |
-
n_batch=128,
|
| 21 |
-
n_ctx=2048,
|
| 22 |
-
temperature=0.7
|
| 23 |
-
)
|
| 24 |
-
|
| 25 |
### The Chat Model
|
| 26 |
def chat_model(message, history):
|
| 27 |
-
|
| 28 |
-
# Retrieve the context
|
| 29 |
-
prompt = ""
|
| 30 |
-
for item in history:
|
| 31 |
-
role = item["role"]
|
| 32 |
-
text = item["content"][0]["text"]
|
| 33 |
-
prompt += f"<|{role}|>{text}\n"
|
| 34 |
-
prompt += f"<|user|>{message}\n<|assistant|>"
|
| 35 |
-
|
| 36 |
-
# Invoke the model
|
| 37 |
-
output = llm(prompt, max_tokens=350)
|
| 38 |
-
return output["choices"][0]["text"].strip()
|
| 39 |
|
| 40 |
|
| 41 |
|
|
|
|
| 13 |
|
| 14 |
print("Loading model...")
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
### The Chat Model
|
| 17 |
def chat_model(message, history):
|
| 18 |
+
return message[::-1] # dummy: reverse text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
|