Update app.py
Browse files12345678910111213141539 unmodified lines55565758596023 unmodified lines84858687888990917 unmodified lines99100101102import streamlit as stimport requests# Hugging Face API URL (default model)API_URL = "https://api-inference.huggingface.co/models/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B"# Function to query the Hugging Face APIdef query(payload, api_url):headers = {"Authorization": f"Bearer {st.secrets['HF_TOKEN']}"}response = requests.post(api_url, headers=headers, json=payload)return response.json()# Page configurationst.set_page_config(page_title="DeepSeek Chatbot - ruslanmv.com",39 unmodified lines0.1, 1.0, 0.9)# Chat interfacest.title("🤖 DeepSeek Chatbot")st.caption("Powered by Hugging Face Inference API - Configure in sidebar")23 unmodified lines}}# Query the Hugging Face API using the selected modeloutput = query(payload, f"https://api-inference.huggingface.co/models/{selected_model}")# Handle API responseif isinstance(output, list) and len(output) > 0 and 'generated_text' in output[0]:7 unmodified linesst.error("Error: Unable to generate a response. Please try again.")except Exception as e:st.error(f"Application Error: {str(e)}")12345639 unmodified lines46474849505152535455565723 unmodified lines81828384858687888990917 unmodified lines99100101102import streamlit as stimport requests# Page configurationst.set_page_config(page_title="DeepSeek Chatbot - ruslanmv.com",39 unmodified lines0.1, 1.0, 0.9)# Function to query the Hugging Face APIdef query(payload, api_url):headers = {"Authorization": f"Bearer {st.secrets['HF_TOKEN']}"}response = requests.post(api_url, headers=headers, json=payload)return response.json()# Chat interfacest.title("🤖 DeepSeek Chatbot")st.caption("Powered by Hugging Face Inference API - Configure in sidebar")23 unmodified lines}}# Dynamically construct the API URL based on the selected modelapi_url = f"https://api-inference.huggingface.co/models/{selected_model}"# Query the Hugging Face API using the selected modeloutput = query(payload, api_url)# Handle API responseif isinstance(output, list) and len(output) > 0 and 'generated_text' in output[0]:7 unmodified linesst.error("Error: Unable to generate a response. Please try again.")except Exception as e:st.error(f"Application Error: {str(e)}")
app.py+11-11