Skip to content
This repository was archived by the owner on Jul 8, 2026. It is now read-only.

Commit 79994fc

Browse files
committed
work
1 parent 2b31a6d commit 79994fc

2 files changed

Lines changed: 26 additions & 11 deletions

File tree

pydantic/gamble/README.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Gamble - AI Casino Bot
33
description: Interactive roulette and blackjack games powered by AI tool calling with Pydantic AI
44
integrations: ["slack"]
5-
categories: ["AI", "Samples", "Games"]
5+
categories: ["AI", "Samples"]
66
tags:
77
[
88
"slack_bot",
@@ -42,13 +42,15 @@ An AI-powered casino bot for Slack that plays roulette and blackjack with you. T
4242
## How It Works
4343

4444
### Roulette
45+
4546
1. **Start game**: `!gamble I want to play roulette`
4647
2. **AI asks for bet**: "Which number would you like to bet on (1-38)?"
4748
3. **Place bet**: "I bet on 17"
4849
4. **AI spins wheel**: Calls `roulette_wheel()` tool to get result
4950
5. **Win/Lose**: AI announces the result and determines if you won
5051

5152
### Blackjack
53+
5254
1. **Start game**: `!gamble Let's play blackjack`
5355
2. **AI deals cards**: Uses `draw_card()` tool to deal initial hands
5456
3. **AI shows cards**: "You have a 7 and a King. I'm showing a 9. Hit or stand?"
@@ -177,7 +179,7 @@ Update the `MODEL_NAME` variable in `autokitteh.yaml`:
177179
```yaml
178180
vars:
179181
- name: MODEL_NAME
180-
value: "anthropic:claude-sonnet-4-0" # or "openai:gpt-4o", etc.
182+
value: "anthropic:claude-sonnet-4-0" # or "openai:gpt-4o", etc.
181183
```
182184
183185
## Technical Details
@@ -208,6 +210,7 @@ async def draw_card() -> int:
208210
```
209211

210212
The AI agent:
213+
211214
1. Understands tool descriptions and purposes
212215
2. Decides when to call tools based on conversation
213216
3. Uses tool results to formulate responses
@@ -216,6 +219,7 @@ The AI agent:
216219
### Logfire Observability
217220

218221
Logfire integration provides visibility into:
222+
219223
- AI agent decisions and reasoning
220224
- Tool calls with arguments and results
221225
- Message history and conversation flow
@@ -237,10 +241,11 @@ AutoKitteh's durable workflows enable persistent game sessions:
237241
```yaml
238242
triggers:
239243
- name: slack_message
240-
is_durable: true # Game state survives server restarts
244+
is_durable: true # Game state survives server restarts
241245
```
242246

243247
Benefits:
248+
244249
- Game state persists across AutoKitteh restarts
245250
- No database needed for game history
246251
- Automatic state management
@@ -257,13 +262,13 @@ The AI uses its understanding of game rules combined with tool calling to create
257262

258263
## Comparison with Other Samples
259264

260-
| Sample | Conversation History | Tools | Use Case |
261-
|--------|---------------------|-------|----------|
262-
| **ask** | ❌ No | ❌ No | Quick one-off questions |
263-
| **chat** | ✅ Yes | ❌ No | Multi-turn conversations |
264-
| **chat_with_ui** | ✅ Yes | ❌ No | Browser-based chat |
265-
| **gamble** | ✅ Yes | ✅ Yes | Interactive AI games with tools |
266-
| **dnd** | ✅ Yes | ✅ Yes | Complex multiplayer RPG |
265+
| Sample | Conversation History | Tools | Use Case |
266+
| ---------------- | -------------------- | ------ | ------------------------------- |
267+
| **ask** | ❌ No | ❌ No | Quick one-off questions |
268+
| **chat** | ✅ Yes | ❌ No | Multi-turn conversations |
269+
| **chat_with_ui** | ✅ Yes | ❌ No | Browser-based chat |
270+
| **gamble** | ✅ Yes | ✅ Yes | Interactive AI games with tools |
271+
| **dnd** | ✅ Yes | ✅ Yes | Complex multiplayer RPG |
267272

268273
## Development
269274

@@ -284,19 +289,22 @@ Deploy from the command line:
284289
## Customization Ideas
285290

286291
### Additional Games
292+
287293
- **Poker**: Multi-player with betting rounds
288294
- **Dice games**: Craps, Yahtzee
289295
- **Card games**: War, Go Fish
290296
- **Slots**: Virtual slot machine simulation
291297

292298
### Enhanced Features
299+
293300
- **Betting system**: Track virtual currency across games
294301
- **Statistics**: Win/loss records, high scores
295302
- **Multiplayer**: Allow multiple users in same game
296303
- **Game rules**: Configurable house rules and payouts
297304
- **Leaderboards**: Track top players across workspace
298305

299306
### Tool Enhancements
307+
300308
- **Deck management**: Track remaining cards in blackjack
301309
- **Betting validation**: Ensure bets are within limits
302310
- **Game history**: Export game results to spreadsheet
@@ -314,21 +322,25 @@ Deploy from the command line:
314322
## Troubleshooting
315323

316324
**Bot doesn't start game:**
325+
317326
- Ensure message starts with `!gamble`
318327
- Check that bot has permission to read messages in channel
319328
- Verify trigger is deployed and active in AutoKitteh UI
320329

321330
**Tools not being called:**
331+
322332
- Check Logfire logs for tool call attempts
323333
- Verify model supports tool calling (most modern models do)
324334
- Ensure prompts clearly request game actions
325335

326336
**Game state lost:**
337+
327338
- Check that `is_durable: true` is set in trigger configuration
328339
- Verify workflow hasn't timed out
329340
- Look for errors in AutoKitteh logs
330341

331342
**Inconsistent game rules:**
343+
332344
- Different AI models may interpret rules differently
333345
- Consider adding more explicit rule details in system prompt
334346
- Check tool call logs to debug AI reasoning
@@ -338,6 +350,7 @@ Deploy from the command line:
338350
To add a new game:
339351

340352
1. **Define tools** for game mechanics:
353+
341354
```python
342355
@roulette_agent.tool_plain
343356
async def roll_dice(sides: int) -> int:
@@ -346,6 +359,7 @@ To add a new game:
346359
```
347360

348361
2. **Update system prompt** with game rules:
362+
349363
```python
350364
system_prompt=(
351365
"..."

tests/metadata_definitions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@
1818
"googlegemini",
1919
"googlesheets",
2020
"hubspot",
21-
"youtube",
2221
"jira",
2322
"kubernetes",
2423
"linear",
2524
"microsoft_teams",
2625
"notion",
2726
"pipedrive",
27+
"pydanticai",
2828
"reddit",
2929
"salesforce",
3030
"slack",
3131
"telegram",
3232
"twilio",
33+
"youtube",
3334
"zoom",
3435
)
3536

0 commit comments

Comments
 (0)