Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -76,15 +76,23 @@ if prompt := st.chat_input("Type your message..."):
|
|
76 |
with st.spinner("Generating response..."):
|
77 |
# Prepare the payload for the API
|
78 |
payload = {
|
79 |
-
"inputs":
|
|
|
|
|
|
|
|
|
80 |
"parameters": {
|
81 |
"max_new_tokens": max_tokens,
|
82 |
"temperature": temperature,
|
83 |
"top_p": top_p,
|
84 |
"return_full_text": False
|
85 |
-
}
|
|
|
86 |
}
|
87 |
|
|
|
|
|
|
|
88 |
# Dynamically construct the API URL based on the selected model
|
89 |
api_url = f"https://api-inference.huggingface.co/models/{selected_model}"
|
90 |
logger.info(f"Selected model: {selected_model}, API URL: {api_url}")
|
@@ -107,4 +115,4 @@ if prompt := st.chat_input("Type your message..."):
|
|
107 |
|
108 |
except Exception as e:
|
109 |
logger.error(f"Application Error: {str(e)}", exc_info=True)
|
110 |
-
st.error(f"Application Error: {str(e)}")
|
|
|
76 |
with st.spinner("Generating response..."):
|
77 |
# Prepare the payload for the API
|
78 |
payload = {
|
79 |
+
"inputs": {
|
80 |
+
"past_user_inputs": [msg["content"] for msg in st.session_state.messages if msg["role"] == "user"],
|
81 |
+
"generated_responses": [msg["content"] for msg in st.session_state.messages if msg["role"] == "assistant"],
|
82 |
+
"text": prompt
|
83 |
+
},
|
84 |
"parameters": {
|
85 |
"max_new_tokens": max_tokens,
|
86 |
"temperature": temperature,
|
87 |
"top_p": top_p,
|
88 |
"return_full_text": False
|
89 |
+
},
|
90 |
+
"system_prompt": system_message
|
91 |
}
|
92 |
|
93 |
+
# Log the full message parsed to the API
|
94 |
+
logger.info(f"Full message sent to API: {payload}")
|
95 |
+
|
96 |
# Dynamically construct the API URL based on the selected model
|
97 |
api_url = f"https://api-inference.huggingface.co/models/{selected_model}"
|
98 |
logger.info(f"Selected model: {selected_model}, API URL: {api_url}")
|
|
|
115 |
|
116 |
except Exception as e:
|
117 |
logger.error(f"Application Error: {str(e)}", exc_info=True)
|
118 |
+
st.error(f"Application Error: {str(e)}")
|