eikarna
commited on
Commit
·
d850ee8
1
Parent(s):
971fbd1
Major Update
Browse files
app.py
CHANGED
|
@@ -59,9 +59,7 @@ def configure_sidebar() -> Dict[str, Any]:
|
|
| 59 |
|
| 60 |
def format_prompt(system_message: str, user_input: str) -> str:
|
| 61 |
"""Format prompt according to model's required template"""
|
| 62 |
-
return f"""
|
| 63 |
-
User: {user_input}
|
| 64 |
-
Assistant: """
|
| 65 |
|
| 66 |
def generate_response(prompt: str, settings: Dict[str, Any]) -> str:
|
| 67 |
"""Generate response using local model"""
|
|
@@ -77,7 +75,8 @@ def generate_response(prompt: str, settings: Dict[str, Any]) -> str:
|
|
| 77 |
)
|
| 78 |
|
| 79 |
response = st.session_state.tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 80 |
-
|
|
|
|
| 81 |
|
| 82 |
def handle_chat_interaction(settings: Dict[str, Any]):
|
| 83 |
"""Manage chat interactions"""
|
|
@@ -114,7 +113,7 @@ def main():
|
|
| 114 |
load_model() # Load model before anything else
|
| 115 |
settings = configure_sidebar()
|
| 116 |
|
| 117 |
-
st.title("🤖 DeepSeek
|
| 118 |
st.caption(f"Running {MODEL_NAME} directly on {DEVICE.upper()}")
|
| 119 |
|
| 120 |
display_chat_history()
|
|
|
|
| 59 |
|
| 60 |
def format_prompt(system_message: str, user_input: str) -> str:
|
| 61 |
"""Format prompt according to model's required template"""
|
| 62 |
+
return f"""<|begin_of_sentence|>System: {system_message}<|User|>{user_input}<|Assistant|>"""
|
|
|
|
|
|
|
| 63 |
|
| 64 |
def generate_response(prompt: str, settings: Dict[str, Any]) -> str:
|
| 65 |
"""Generate response using local model"""
|
|
|
|
| 75 |
)
|
| 76 |
|
| 77 |
response = st.session_state.tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 78 |
+
response = response.split("\n</think>\n")[0].strip()
|
| 79 |
+
return response.split("<|Assistant|>")[-1].strip()
|
| 80 |
|
| 81 |
def handle_chat_interaction(settings: Dict[str, Any]):
|
| 82 |
"""Manage chat interactions"""
|
|
|
|
| 113 |
load_model() # Load model before anything else
|
| 114 |
settings = configure_sidebar()
|
| 115 |
|
| 116 |
+
st.title("🤖 DeepSeek Chat")
|
| 117 |
st.caption(f"Running {MODEL_NAME} directly on {DEVICE.upper()}")
|
| 118 |
|
| 119 |
display_chat_history()
|