Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions aisuite/providers/anthropic_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,22 @@ def _get_completion_usage(self, response):

def _get_message(self, response):
"""Get the appropriate message based on response type."""
if response.stop_reason == "tool_use":
# Check if response contains any tool use blocks (regardless of stop_reason)
has_tool_use = any(content.type == "tool_use" for content in response.content)

if has_tool_use:
tool_message = self.convert_response_with_tool_use(response)
if tool_message:
return tool_message

# Safely extract text content from any position in content blocks
text_content = next(
(content.text for content in response.content if content.type == "text"),
"",
)

return Message(
content=response.content[0].text,
content=text_content or None,
role="assistant",
tool_calls=None,
refusal=None,
Expand Down
179 changes: 179 additions & 0 deletions examples/agents/stock_dashboard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Stock Market Movers - November 10, 2025</title>
<style>
:root {
--bg: #0b1020;
--card: #111832;
--text: #e8eefc;
--muted: #9fb2d9;
--accent: #3b82f6;
--positive: #16a34a;
--border: #1f2a4d;
--shadow: 0 10px 30px rgba(0,0,0,0.35);
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
background: linear-gradient(180deg, #0b1020 0%, #0a0f1d 100%);
color: var(--text);
}
.container {
max-width: 1100px;
margin: 48px auto;
padding: 0 20px;
}
header h1 {
margin: 0 0 8px 0;
font-weight: 800;
letter-spacing: 0.2px;
}
header p { margin: 0; color: var(--muted); }

.card {
margin-top: 24px;
background: var(--card);
border: 1px solid var(--border);
border-radius: 14px;
box-shadow: var(--shadow);
overflow: hidden;
}

.table-wrap { width: 100%; overflow-x: auto; }
table {
width: 100%;
border-collapse: collapse;
min-width: 720px;
}
thead th {
text-align: left;
font-size: 12px;
letter-spacing: .05em;
text-transform: uppercase;
color: var(--muted);
padding: 16px 18px;
background: rgba(255,255,255,0.02);
border-bottom: 1px solid var(--border);
}
tbody td {
padding: 16px 18px;
border-bottom: 1px solid var(--border);
}
tbody tr:hover { background: rgba(255,255,255,0.03); }

.ticker {
font-weight: 700;
color: #ffffff;
letter-spacing: .3px;
}
.company { color: var(--muted); }

.chip {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 10px;
border-radius: 999px;
font-weight: 700;
font-variant-numeric: tabular-nums;
font-size: 13px;
background: rgba(22,163,74,.12);
color: var(--positive);
border: 1px solid rgba(22,163,74,.35);
box-shadow: inset 0 0 0 1px rgba(22,163,74,.15);
}
.price { font-variant-numeric: tabular-nums; }

.footer {
display: flex;
gap: 16px;
align-items: center;
flex-wrap: wrap;
padding: 16px 18px;
background: rgba(255,255,255,0.02);
border-top: 1px solid var(--border);
color: var(--muted);
font-size: 14px;
}
.badge {
display: inline-block;
padding: 6px 10px;
background: rgba(59,130,246,.12);
border: 1px solid rgba(59,130,246,.35);
color: #cde1ff;
border-radius: 999px;
font-size: 12px;
letter-spacing: .03em;
text-transform: uppercase;
}
a { color: #93c5fd; text-decoration: none; }
a:hover { text-decoration: underline; }
@media (max-width: 640px){
header h1 { font-size: 22px; }
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>Stock Market Movers - November 10, 2025</h1>
<p>Top gainers snapshot, styled for a professional financial look.</p>
</header>

<section class="card">
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Ticker</th>
<th>Company</th>
<th>Price (USD)</th>
<th>% Change</th>
</tr>
</thead>
<tbody>
<tr>
<td class="ticker">GLTO</td>
<td class="company">Galecto, Inc.</td>
<td class="price">17.25</td>
<td><span class="chip">+248.49%</span></td>
</tr>
<tr>
<td class="ticker">COGT</td>
<td class="company">Cogent Biosciences, Inc.</td>
<td class="price">32.46</td>
<td><span class="chip">+119.03%</span></td>
</tr>
<tr>
<td class="ticker">NVTS</td>
<td class="company">Navitas Semiconductor Corporation</td>
<td class="price">9.60</td>
<td><span class="chip">+22.45%</span></td>
</tr>
<tr>
<td class="ticker">XPEV</td>
<td class="company">XPeng Inc.</td>
<td class="price">26.04</td>
<td><span class="chip">+16.15%</span></td>
</tr>
<tr>
<td class="ticker">SEDG</td>
<td class="company">SolarEdge Technologies, Inc.</td>
<td class="price">45.38</td>
<td><span class="chip">+13.45%</span></td>
</tr>
</tbody>
</table>
</div>
<div class="footer">
<span class="badge">As of Nov 10, 2025</span>
<span>Source: <a href="https://finance.yahoo.com/markets/stocks/gainers/" target="_blank" rel="noopener">Yahoo Finance — Top Gainers</a></span>
</div>
</section>
</div>
</body>
</html>
139 changes: 139 additions & 0 deletions examples/agents/stock_market_dashboard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stock Market Movers - 2025-11-10</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f9;
color: #333;
}
header {
background-color: #333;
color: #fff;
padding: 10px 0;
text-align: center;
}
.container {
width: 90%;
max-width: 1200px;
margin: 20px auto;
}
.gain, .loss {
padding: 10px;
border-radius: 5px;
margin: 10px 0;
}
.gain {
background-color: #d4fdd4;
color: #006400;
border: 1px solid #006400;
}
.loss {
background-color: #ffdede;
color: #b22222;
border: 1px solid #b22222;
}
table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
}
table thead {
background-color: #333;
color: #fff;
}
table th, table td {
padding: 15px;
text-align: left;
border-bottom: 1px solid #ddd;
}
footer {
text-align: center;
padding: 15px 0;
background-color: #333;
color: #fff;
}
@media (max-width: 768px) {
table, thead, tbody, th, td, tr {
display: block;
}
td {
position: relative;
padding-left: 50%;
text-align: left;
}
td:before {
position: absolute;
top: 0;
left: 0;
width: 45%;
padding-right: 10px;
white-space: nowrap;
}
}
</style>
</head>
<body>
<header>
<h1>Stock Market Movers - 2025-11-10</h1>
<p>Market Sentiment: Bullish</p>
</header>
<div class="container">
<section id="top-gainers">
<h2>Top Gainers</h2>
<table>
<thead>
<tr>
<th>Company Name</th>
<th>Ticker</th>
<th>Current Price</th>
<th>% Change</th>
<th>Reason</th>
</tr>
</thead>
<tbody>
<tr class="gain">
<td>Cogent Biosciences, Inc.</td>
<td>COGT</td>
<td>$32.46</td>
<td>+119.03%</td>
<td>Positive clinical trial result</td>
</tr>
<tr class="gain">
<td>Navitas Semiconductor Corporation</td>
<td>NVTS</td>
<td>$9.60</td>
<td>+22.45%</td>
<td>Strong quarterly earnings</td>
</tr>
<tr class="gain">
<td>Opendoor Technologies Inc.</td>
<td>OPEN</td>
<td>$7.99</td>
<td>+21.77%</td>
<td>Acquisition news</td>
</tr>
</tbody>
</table>
</section>
<section id="market-news">
<h2>Market News</h2>
<ul>
<li>Sony raises profit forecast after earnings beat, boosted by Music and Imaging divisions</li>
<li>U.S. markets rally as investors anticipate FOMC meeting outcomes</li>
<li>European markets gain on strong manufacturing data</li>
</ul>
</section>
</div>
<footer>
<p>Sources: Yahoo Finance, CNBC</p>
<p>Timestamp: 2025-11-10</p>
<p>Disclaimer: This is for informational purposes only, not financial advice.</p>
</footer>
</body>
</html>
Loading