eikarna commited on
Commit ·
6563cfd
1
Parent(s): a2aeda2
Feat: debug toggle
Browse files52 unmodified lines5354555657585960616240 unmodified lines1031041051061071081094 unmodified lines11411511611711811912024 unmodified lines14514614714814915052 unmodified linesdef format_deepseek_prompt(system_message: str, user_input: str) -> str:"""Format the prompt according to DeepSeek's required structure"""return f"""<|beginofutterance|>System: {system_message}<|endofutterance|><|beginofutterance|>User: {user_input}<|endofutterance|><|beginofutterance|>Assistant:"""def query_hf_api(payload: Dict[str, Any], api_url: str) -> Optional[Dict[str, Any]]:"""Handle API requests with improved error handling"""40 unmodified lines"temperature": settings["temperature"],"top_p": settings["top_p"],"return_full_text": settings["debug_chat"],"stop_sequences": ["<|endofutterance|>", "<|beginofutterance|>"] # Add stop sequences}}4 unmodified linesif 'generated_text' in output[0]:response_text = output[0]['generated_text'].strip()# Remove any remaining special tokensresponse_text = response_text.replace("<|endofutterance|>", "").strip()# Display and store responsewith st.chat_message("assistant"):24 unmodified linessettings = configure_sidebar()st.title("🤖 DeepSeek Chatbot")st.caption("Powered by Hugging Face Inference API - Configure in sidebar")display_chat_history()52 unmodified lines535455565758596040 unmodified lines1011021031041051064 unmodified lines11111211311411511611724 unmodified lines14214314414514614714852 unmodified linesdef format_deepseek_prompt(system_message: str, user_input: str) -> str:"""Format the prompt according to DeepSeek's required structure"""return f"""System: {system_message}<|User|>{user_input}<|Assistant|>"""def query_hf_api(payload: Dict[str, Any], api_url: str) -> Optional[Dict[str, Any]]:"""Handle API requests with improved error handling"""40 unmodified lines"temperature": settings["temperature"],"top_p": settings["top_p"],"return_full_text": settings["debug_chat"],}}4 unmodified linesif 'generated_text' in output[0]:response_text = output[0]['generated_text'].strip()# Remove any remaining special tokensresponse_text = response_text.split("\n</think>\n")[0].strip()# Display and store responsewith st.chat_message("assistant"):24 unmodified linessettings = configure_sidebar()st.title("🤖 DeepSeek Chatbot")st.caption(f"Current Model: {settings['model']}")st.caption("Powered by Hugging Face Inference API - Configure in sidebar")display_chat_history()
app.py+4-6