update pay function
This commit is contained in:
43
app.py
43
app.py
@@ -5418,31 +5418,26 @@ def get_related_stocks(event_id):
|
||||
|
||||
stocks_data = []
|
||||
for stock in stocks:
|
||||
if stock.retrieved_sources is not None:
|
||||
stocks_data.append({
|
||||
'id': stock.id,
|
||||
'stock_code': stock.stock_code,
|
||||
'stock_name': stock.stock_name,
|
||||
'sector': stock.sector,
|
||||
'relation_desc': {"data":stock.retrieved_sources},
|
||||
'retrieved_sources': stock.retrieved_sources,
|
||||
'correlation': stock.correlation,
|
||||
'momentum': stock.momentum,
|
||||
'created_at': stock.created_at.isoformat() if stock.created_at else None,
|
||||
'updated_at': stock.updated_at.isoformat() if stock.updated_at else None
|
||||
})
|
||||
# 处理 relation_desc:只有当 retrieved_sources 是数组时才使用新格式
|
||||
if stock.retrieved_sources is not None and isinstance(stock.retrieved_sources, list):
|
||||
# retrieved_sources 是有效数组,使用新格式
|
||||
relation_desc_value = {"data": stock.retrieved_sources}
|
||||
else:
|
||||
stocks_data.append({
|
||||
'id': stock.id,
|
||||
'stock_code': stock.stock_code,
|
||||
'stock_name': stock.stock_name,
|
||||
'sector': stock.sector,
|
||||
'relation_desc': stock.relation_desc,
|
||||
'correlation': stock.correlation,
|
||||
'momentum': stock.momentum,
|
||||
'created_at': stock.created_at.isoformat() if stock.created_at else None,
|
||||
'updated_at': stock.updated_at.isoformat() if stock.updated_at else None
|
||||
})
|
||||
# retrieved_sources 不是数组(可能是 {"raw": "..."} 等异常格式),回退到原始文本
|
||||
relation_desc_value = stock.relation_desc
|
||||
|
||||
stocks_data.append({
|
||||
'id': stock.id,
|
||||
'stock_code': stock.stock_code,
|
||||
'stock_name': stock.stock_name,
|
||||
'sector': stock.sector,
|
||||
'relation_desc': relation_desc_value,
|
||||
'retrieved_sources': stock.retrieved_sources,
|
||||
'correlation': stock.correlation,
|
||||
'momentum': stock.momentum,
|
||||
'created_at': stock.created_at.isoformat() if stock.created_at else None,
|
||||
'updated_at': stock.updated_at.isoformat() if stock.updated_at else None
|
||||
})
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
|
||||
@@ -2759,7 +2759,7 @@ async def stream_role_response(
|
||||
tool_choice="auto",
|
||||
stream=False, # 工具调用不使用流式
|
||||
temperature=0.7,
|
||||
max_tokens=1000,
|
||||
max_tokens=8192, # 增大 token 限制以避免输出被截断
|
||||
)
|
||||
|
||||
assistant_message = response.choices[0].message
|
||||
@@ -2819,7 +2819,7 @@ async def stream_role_response(
|
||||
messages=messages,
|
||||
stream=True,
|
||||
temperature=0.7,
|
||||
max_tokens=2000, # 增加 token 限制以避免输出被截断
|
||||
max_tokens=16384, # 大幅增加 token 限制以避免输出被截断
|
||||
)
|
||||
|
||||
full_content = ""
|
||||
|
||||
@@ -85,15 +85,16 @@ const ChatArea = ({
|
||||
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
||||
}, [messages]);
|
||||
return (
|
||||
<Flex flex={1} direction="column">
|
||||
<Flex flex={1} direction="column" h="100%" overflow="hidden" minH={0}>
|
||||
{/* 顶部标题栏 - 深色毛玻璃 */}
|
||||
<Box
|
||||
bg="rgba(17, 24, 39, 0.8)"
|
||||
backdropFilter="blur(20px) saturate(180%)"
|
||||
borderBottom="1px solid"
|
||||
borderColor="rgba(255, 255, 255, 0.1)"
|
||||
px={6}
|
||||
py={4}
|
||||
px={4}
|
||||
py={3}
|
||||
flexShrink={0}
|
||||
boxShadow="0 8px 32px 0 rgba(31, 38, 135, 0.37)"
|
||||
>
|
||||
<Flex align="center" justify="space-between">
|
||||
@@ -216,6 +217,7 @@ const ChatArea = ({
|
||||
{/* 消息列表 / 欢迎界面 */}
|
||||
<Box
|
||||
flex={1}
|
||||
minH={0}
|
||||
bgGradient="linear(to-b, rgba(17, 24, 39, 0.5), rgba(17, 24, 39, 0.3))"
|
||||
overflowY="auto"
|
||||
display="flex"
|
||||
@@ -263,8 +265,9 @@ const ChatArea = ({
|
||||
backdropFilter="blur(20px) saturate(180%)"
|
||||
borderTop="1px solid"
|
||||
borderColor="rgba(255, 255, 255, 0.1)"
|
||||
px={6}
|
||||
py={1}
|
||||
px={4}
|
||||
py={2}
|
||||
flexShrink={0}
|
||||
boxShadow="0 -8px 32px 0 rgba(31, 38, 135, 0.37)"
|
||||
>
|
||||
<Box maxW="896px" mx="auto">
|
||||
|
||||
@@ -81,10 +81,12 @@ const RoleCard = ({ role, isSpeaking }) => {
|
||||
}}
|
||||
>
|
||||
<HStack spacing={3}>
|
||||
{/* 头像 */}
|
||||
{/* 头像 - 使用 PNG 图片 */}
|
||||
<Box position="relative">
|
||||
<Avatar
|
||||
size="sm"
|
||||
src={role.avatar}
|
||||
name={role.name}
|
||||
icon={getRoleIcon(role.roleType)}
|
||||
bg={role.color}
|
||||
boxShadow={isSpeaking ? `0 0 12px ${role.color}` : 'none'}
|
||||
|
||||
@@ -286,7 +286,7 @@ const StockListItem = ({
|
||||
{/* 关联描述 - 升级和降级处理 */}
|
||||
{stock.relation_desc && (
|
||||
<Box flex={1} minW={0} flexBasis={isMobile ? '100%' : ''}>
|
||||
{stock.relation_desc?.data ? (
|
||||
{Array.isArray(stock.relation_desc?.data) ? (
|
||||
// 升级:带引用来源的版本 - 添加折叠功能
|
||||
<Tooltip
|
||||
label={isDescExpanded ? "点击收起" : "点击展开完整描述"}
|
||||
@@ -332,7 +332,7 @@ const StockListItem = ({
|
||||
color={PROFESSIONAL_COLORS.text.primary}
|
||||
lineHeight="1.8"
|
||||
>
|
||||
{stock.relation_desc?.data?.filter(item => item.query_part).map((item, index, arr) => (
|
||||
{Array.isArray(stock.relation_desc?.data) && stock.relation_desc.data.filter(item => item.query_part).map((item, index, arr) => (
|
||||
<React.Fragment key={index}>
|
||||
<Tooltip
|
||||
label={
|
||||
|
||||
Reference in New Issue
Block a user