@agentscope-ai/chat 1.1.59-beta.1775119922876 → 1.1.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "@agentscope-ai/icons": "^1.0.46",
14
- "@agentscope-ai/chat": "file://Users/ls/GitHub/agentscope-spark-design/packages/spark-chat",
14
+ "@agentscope-ai/chat": "1.1.59-beta.1775119922876",
15
15
  "@agentscope-ai/design": "^1.0.19",
16
16
  "antd": "^5.29.1",
17
17
  "antd-style": "^3.7.1",
@@ -0,0 +1,234 @@
1
+ import { createStyles } from 'antd-style';
2
+
3
+ interface IToolContentItem {
4
+ type: string;
5
+ object?: string;
6
+ status: string;
7
+ delta?: boolean | null;
8
+ msg_id?: string;
9
+ index?: number;
10
+ error?: unknown;
11
+ sequence_number?: number | null;
12
+ data: {
13
+ name: string;
14
+ arguments?: string;
15
+ output?: string;
16
+ };
17
+ }
18
+
19
+ interface IToolMessage {
20
+ id: string;
21
+ object?: string;
22
+ type: string;
23
+ role: string;
24
+ status: string;
25
+ content: IToolContentItem[];
26
+ code?: string | null;
27
+ message?: string | null;
28
+ }
29
+
30
+ export interface IWeatherItem {
31
+ location: string;
32
+ weather: string;
33
+ temperature: number;
34
+ date: string;
35
+ }
36
+
37
+ function parseOutput(data: IToolMessage): IWeatherItem[] {
38
+ const outputContent = data.content[1]?.data;
39
+ try {
40
+ // @ts-ignore
41
+ return JSON.parse(JSON.parse(outputContent.output));
42
+ } catch {
43
+ return [];
44
+ }
45
+ }
46
+
47
+ const weatherIcons: Record<string, string> = {
48
+ sunny: '☀️',
49
+ cloudy: '☁️',
50
+ rainy: '🌧️',
51
+ snowy: '❄️',
52
+ stormy: '⛈️',
53
+ windy: '💨',
54
+ foggy: '🌫️',
55
+ };
56
+
57
+ const weatherLabels: Record<string, string> = {
58
+ sunny: '晴',
59
+ cloudy: '多云',
60
+ rainy: '雨',
61
+ snowy: '雪',
62
+ stormy: '暴风雨',
63
+ windy: '大风',
64
+ foggy: '雾',
65
+ };
66
+
67
+ function formatDate(dateStr: string) {
68
+ const d = new Date(dateStr);
69
+ const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
70
+ const month = d.getMonth() + 1;
71
+ const day = d.getDate();
72
+ const today = new Date();
73
+ const isToday =
74
+ d.getFullYear() === today.getFullYear() &&
75
+ d.getMonth() === today.getMonth() &&
76
+ d.getDate() === today.getDate();
77
+ return {
78
+ weekday: isToday ? '今天' : weekdays[d.getDay()],
79
+ date: `${month}/${day}`,
80
+ };
81
+ }
82
+
83
+ const useStyles = createStyles(({ token, css }) => ({
84
+ wrapper: css`
85
+ border-radius: 12px;
86
+ border: 1px solid ${token.colorBorderSecondary};
87
+ background: ${token.colorBgElevated};
88
+ overflow: hidden;
89
+ `,
90
+ header: css`
91
+ display: flex;
92
+ align-items: center;
93
+ justify-content: space-between;
94
+ padding: 14px 16px;
95
+ border-bottom: 1px solid ${token.colorBorderSecondary};
96
+ `,
97
+ locationRow: css`
98
+ display: flex;
99
+ align-items: center;
100
+ gap: 6px;
101
+ `,
102
+ locationIcon: css`
103
+ font-size: 16px;
104
+ line-height: 1;
105
+ `,
106
+ locationText: css`
107
+ font-size: 14px;
108
+ font-weight: 600;
109
+ color: ${token.colorText};
110
+ `,
111
+ todayTemp: css`
112
+ font-size: 22px;
113
+ font-weight: 700;
114
+ color: ${token.colorText};
115
+ display: flex;
116
+ align-items: center;
117
+ gap: 6px;
118
+ `,
119
+ todayWeather: css`
120
+ font-size: 13px;
121
+ font-weight: 400;
122
+ color: ${token.colorTextSecondary};
123
+ `,
124
+ container: css`
125
+ display: flex;
126
+ overflow-x: auto;
127
+ padding: 14px 12px;
128
+ `,
129
+ card: css`
130
+ flex: 1;
131
+ flex-shrink: 0;
132
+ display: flex;
133
+ flex-direction: column;
134
+ align-items: center;
135
+ gap: 8px;
136
+ padding: 10px 12px;
137
+ border-radius: 10px;
138
+ min-width: 72px;
139
+ transition: background 0.2s;
140
+ cursor: default;
141
+ &:hover {
142
+ background: ${token.colorFillQuaternary};
143
+ }
144
+ `,
145
+ todayCard: css`
146
+ background: ${token.colorPrimaryBg};
147
+ &:hover {
148
+ background: ${token.colorPrimaryBgHover};
149
+ }
150
+ `,
151
+ weekday: css`
152
+ font-size: 12px;
153
+ font-weight: 500;
154
+ color: ${token.colorTextSecondary};
155
+ line-height: 1;
156
+ `,
157
+ todayWeekday: css`
158
+ color: ${token.colorPrimary};
159
+ font-weight: 600;
160
+ `,
161
+ date: css`
162
+ font-size: 11px;
163
+ color: ${token.colorTextQuaternary};
164
+ line-height: 1;
165
+ `,
166
+ icon: css`
167
+ font-size: 26px;
168
+ line-height: 1;
169
+ `,
170
+ temp: css`
171
+ font-size: 15px;
172
+ font-weight: 600;
173
+ color: ${token.colorText};
174
+ line-height: 1;
175
+ `,
176
+ label: css`
177
+ font-size: 11px;
178
+ color: ${token.colorTextTertiary};
179
+ line-height: 1;
180
+ `,
181
+ }));
182
+
183
+ export default function Weather(props: { data: IToolMessage }) {
184
+ const items = parseOutput(props.data);
185
+ const { styles, cx } = useStyles();
186
+
187
+ if (!items.length) return null;
188
+
189
+ const todayItem = items.find((_, i) => {
190
+ const { weekday } = formatDate(items[i].date);
191
+ return weekday === '今天';
192
+ }) || items[0];
193
+
194
+ return (
195
+ <div className={styles.wrapper}>
196
+ <div className={styles.header}>
197
+ <div className={styles.locationRow}>
198
+ <span className={styles.locationIcon}>📍</span>
199
+ <span className={styles.locationText}>{items[0].location}</span>
200
+ </div>
201
+ <div className={styles.todayTemp}>
202
+ {weatherIcons[todayItem.weather] || '🌤️'} {todayItem.temperature}°
203
+ <span className={styles.todayWeather}>
204
+ {weatherLabels[todayItem.weather] || todayItem.weather}
205
+ </span>
206
+ </div>
207
+ </div>
208
+ <div className={styles.container}>
209
+ {items.map((item) => {
210
+ const { weekday, date } = formatDate(item.date);
211
+ const isToday = weekday === '今天';
212
+ return (
213
+ <div
214
+ key={item.date}
215
+ className={cx(styles.card, isToday && styles.todayCard)}
216
+ >
217
+ <span className={cx(styles.weekday, isToday && styles.todayWeekday)}>
218
+ {weekday}
219
+ </span>
220
+ <span className={styles.date}>{date}</span>
221
+ <span className={styles.icon}>
222
+ {weatherIcons[item.weather] || '🌤️'}
223
+ </span>
224
+ <span className={styles.temp}>{item.temperature}°</span>
225
+ <span className={styles.label}>
226
+ {weatherLabels[item.weather] || item.weather}
227
+ </span>
228
+ </div>
229
+ );
230
+ })}
231
+ </div>
232
+ </div>
233
+ );
234
+ }
@@ -1,4 +1,11 @@
1
- export default {
1
+ import { IAgentScopeRuntimeWebUIOptions } from '@agentscope-ai/chat';
2
+ import Weather from '../Cards/Weather';
3
+
4
+
5
+ const config: IAgentScopeRuntimeWebUIOptions = {
6
+ customToolRenderConfig: {
7
+ 'weather search mock': Weather,
8
+ },
2
9
  theme: {
3
10
  colorPrimary: '#615CED',
4
11
  darkMode: true,
@@ -9,7 +16,6 @@ export default {
9
16
  },
10
17
  },
11
18
  sender: {
12
- attachments: false,
13
19
  maxLength: 10000,
14
20
  disclaimer:
15
21
  'AI can also make mistakes, so please check carefully and use it with caution',
@@ -43,3 +49,6 @@ export default {
43
49
  },
44
50
  };
45
51
 
52
+
53
+
54
+ export default config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentscope-ai/chat",
3
- "version": "1.1.59-beta.1775119922876",
3
+ "version": "1.1.60",
4
4
  "description": "a free and open-source chat framework for building excellent LLM-powered chat experiences",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": [