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