Spaces:
Sleeping
Sleeping
Trae Agent
commited on
Commit
·
3500a4b
1
Parent(s):
a77cb59
优化
Browse files- Dockerfile +5 -0
- api/services/__pycache__/chat_service.cpython-314.pyc +0 -0
- api/services/chat_service.py +7 -0
- index.html +1 -1
- src/main.ts +15 -0
- src/views/Dashboard.vue +4 -0
Dockerfile
CHANGED
|
@@ -27,6 +27,11 @@ COPY --from=frontend-build /app/dist /app/dist
|
|
| 27 |
|
| 28 |
# Create a non-root user for security (good practice for HF Spaces)
|
| 29 |
RUN useradd -m -u 1000 user
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
USER user
|
| 31 |
ENV HOME=/home/user \
|
| 32 |
PATH=/home/user/.local/bin:$PATH
|
|
|
|
| 27 |
|
| 28 |
# Create a non-root user for security (good practice for HF Spaces)
|
| 29 |
RUN useradd -m -u 1000 user
|
| 30 |
+
|
| 31 |
+
# Set ownership of the application directory to the non-root user
|
| 32 |
+
# This is crucial for SQLite database creation in the instance folder
|
| 33 |
+
RUN chown -R user:user /app
|
| 34 |
+
|
| 35 |
USER user
|
| 36 |
ENV HOME=/home/user \
|
| 37 |
PATH=/home/user/.local/bin:$PATH
|
api/services/__pycache__/chat_service.cpython-314.pyc
CHANGED
|
Binary files a/api/services/__pycache__/chat_service.cpython-314.pyc and b/api/services/__pycache__/chat_service.cpython-314.pyc differ
|
|
|
api/services/chat_service.py
CHANGED
|
@@ -16,12 +16,19 @@ class ChatService:
|
|
| 16 |
# Try OPENAI_API_KEY as fallback or generic
|
| 17 |
api_key = os.getenv("OPENAI_API_KEY")
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
response_text = ""
|
| 20 |
advice_type = "general_chat"
|
| 21 |
is_mock = False
|
| 22 |
|
| 23 |
if api_key and OpenAI:
|
| 24 |
try:
|
|
|
|
| 25 |
client = OpenAI(
|
| 26 |
api_key=api_key,
|
| 27 |
base_url="https://api.siliconflow.cn/v1"
|
|
|
|
| 16 |
# Try OPENAI_API_KEY as fallback or generic
|
| 17 |
api_key = os.getenv("OPENAI_API_KEY")
|
| 18 |
|
| 19 |
+
# Debug Log
|
| 20 |
+
print(f"DEBUG: Processing message for user {user_id}, risk {risk_level}")
|
| 21 |
+
print(f"DEBUG: API Key present: {bool(api_key)}")
|
| 22 |
+
if api_key:
|
| 23 |
+
print(f"DEBUG: API Key prefix: {api_key[:8]}...")
|
| 24 |
+
|
| 25 |
response_text = ""
|
| 26 |
advice_type = "general_chat"
|
| 27 |
is_mock = False
|
| 28 |
|
| 29 |
if api_key and OpenAI:
|
| 30 |
try:
|
| 31 |
+
print("DEBUG: Initializing OpenAI client for SiliconFlow")
|
| 32 |
client = OpenAI(
|
| 33 |
api_key=api_key,
|
| 34 |
base_url="https://api.siliconflow.cn/v1"
|
index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
-
<title
|
| 8 |
<script type="module">
|
| 9 |
if (import.meta.hot?.on) {
|
| 10 |
import.meta.hot.on('vite:error', (error) => {
|
|
|
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
+
<title>金融分析顾问</title>
|
| 8 |
<script type="module">
|
| 9 |
if (import.meta.hot?.on) {
|
| 10 |
import.meta.hot.on('vite:error', (error) => {
|
src/main.ts
CHANGED
|
@@ -6,6 +6,21 @@ import { createPinia } from 'pinia'
|
|
| 6 |
import ElementPlus from 'element-plus'
|
| 7 |
import 'element-plus/dist/index.css'
|
| 8 |
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
const app = createApp(App)
|
| 11 |
const pinia = createPinia()
|
|
|
|
| 6 |
import ElementPlus from 'element-plus'
|
| 7 |
import 'element-plus/dist/index.css'
|
| 8 |
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
| 9 |
+
import axios from 'axios'
|
| 10 |
+
|
| 11 |
+
// Axios Interceptor for 401 Unauthorized
|
| 12 |
+
axios.interceptors.response.use(
|
| 13 |
+
response => response,
|
| 14 |
+
error => {
|
| 15 |
+
if (error.response && error.response.status === 401) {
|
| 16 |
+
// Clear token and redirect to login
|
| 17 |
+
localStorage.removeItem('token')
|
| 18 |
+
localStorage.removeItem('user')
|
| 19 |
+
window.location.href = '/login'
|
| 20 |
+
}
|
| 21 |
+
return Promise.reject(error)
|
| 22 |
+
}
|
| 23 |
+
)
|
| 24 |
|
| 25 |
const app = createApp(App)
|
| 26 |
const pinia = createPinia()
|
src/views/Dashboard.vue
CHANGED
|
@@ -118,6 +118,10 @@ onMounted(() => {
|
|
| 118 |
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-900"></div>
|
| 119 |
</div>
|
| 120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
<div v-else-if="portfolio" class="grid grid-cols-1 gap-6 lg:grid-cols-2">
|
| 122 |
<!-- Chart Card -->
|
| 123 |
<div class="bg-white overflow-hidden shadow rounded-lg">
|
|
|
|
| 118 |
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-900"></div>
|
| 119 |
</div>
|
| 120 |
|
| 121 |
+
<div v-else-if="!portfolio" class="flex justify-center py-12">
|
| 122 |
+
<div class="text-gray-500">暂无数据</div>
|
| 123 |
+
</div>
|
| 124 |
+
|
| 125 |
<div v-else-if="portfolio" class="grid grid-cols-1 gap-6 lg:grid-cols-2">
|
| 126 |
<!-- Chart Card -->
|
| 127 |
<div class="bg-white overflow-hidden shadow rounded-lg">
|