Skip to content

Commit 5809ea2

Browse files
committed
Add token options
1 parent fe4d081 commit 5809ea2

File tree

2 files changed

+47
-9
lines changed

2 files changed

+47
-9
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export ANTHROPIC_API_KEY=your_api_key_here
2727
- 🧪 Powerful file filtering to focus the AI's attention on specific scrolls of code
2828
- 📚 Handles file output with proper directory creation spells
2929
- 📥 Supports reading enchantments from stdin
30+
- 🖼️ Includes image attachment capabilities for visual context
3031

3132
## 🧙 Installation
3233

@@ -85,9 +86,18 @@ Include specific scrolls:
8586
wiz prompt -f main.py -f utils.py "How can I make these files more efficient?"
8687
```
8788

89+
Add images for visual context:
90+
91+
```bash
92+
wiz prompt -i screenshot.png "What UI improvements would you suggest based on this screenshot?"
93+
```
94+
8895
Options:
8996
- `-f, --file`: Specify files to include (can be used multiple times)
97+
- `-i, --image`: Include image files as context (can be used multiple times)
9098
- `-o, --output`: Location to write response (default: `.response.md`)
99+
- `-m, --max-tokens`: Maximum tokens for the response (default: 60000)
100+
- `-t, --thinking-tokens`: Maximum tokens for Claude's thinking process (default: 16000)
91101

92102
The wizard's response will be saved to `.response.md` by default, and a copy of the full messages including system prompt will be saved to `.messages.md`.
93103

@@ -132,6 +142,18 @@ Conjure a new feature:
132142
wiz prompt "Add a progress bar to the file processing function"
133143
```
134144

145+
Get feedback on UI design with an image:
146+
147+
```bash
148+
wiz prompt -i design.png -f styles.css "How can I improve this layout?"
149+
```
150+
151+
Adjust token limits for complex analysis:
152+
153+
```bash
154+
wiz prompt -m 80000 -t 20000 "Perform a comprehensive security audit of this codebase"
155+
```
156+
135157
Then cast the spell to apply the changes:
136158

137159
```bash

wiz.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ def parse_attachment(attachment):
118118
},
119119
}
120120

121-
def reply(question, files=None, attachments=None):
121+
def reply(question, files=None, attachments=None, max_tokens=60000, thinking_tokens=16000):
122+
attachments = attachments or [] # Ensure attachments is a list
122123

123124
if files:
124125
console.print(f"Using specified files: {', '.join(files)}")
@@ -131,6 +132,7 @@ def reply(question, files=None, attachments=None):
131132
table.add_column("File", style="cyan")
132133
table.add_column("Size", justify="right", style="green")
133134
table.add_column("Status", style="yellow")
135+
table.add_column("Type", style="magenta") # Add type column to differentiate files and attachments
134136

135137
body = [f"Help me with following files: {', '.join(file_list)}"]
136138

@@ -154,12 +156,25 @@ def reply(question, files=None, attachments=None):
154156

155157
# Add to table
156158
size_str = f"{file_size / 1024:.1f} KB" if file_size > 1024 else f"{file_size} bytes"
157-
table.add_row(file, size_str, "✓ Read")
159+
table.add_row(file, size_str, "✓ Read", "Text File")
158160
except Exception as e:
159-
table.add_row(file, "N/A", str(e))
161+
table.add_row(file, "N/A", str(e), "Error")
160162

161163
progress.update(task, advance=1)
162164

165+
# Add attachments to the table
166+
for attachment in attachments:
167+
try:
168+
if attachment.startswith("http"):
169+
table.add_row(attachment, "URL", "✓ Included", "Remote Image")
170+
else:
171+
file_size = os.path.getsize(attachment)
172+
size_str = f"{file_size / 1024:.1f} KB" if file_size > 1024 else f"{file_size} bytes"
173+
ext = os.path.splitext(attachment)[1][1:].upper() or "Unknown"
174+
table.add_row(attachment, size_str, "✓ Included", f"Image ({ext})")
175+
except Exception as e:
176+
table.add_row(attachment, "N/A", f"Error: {str(e)}", "Image Error")
177+
163178
# Show summary table
164179
console.print(table)
165180

@@ -169,7 +184,6 @@ def reply(question, files=None, attachments=None):
169184
**Reminder**
170185
- wrap resulting code between `[{TAG}]` and `[/{TAG}]` tags!!!
171186
"""
172-
attachments = attachments or []
173187
images = [
174188
parse_attachment(att)
175189
for att in attachments
@@ -185,7 +199,7 @@ def reply(question, files=None, attachments=None):
185199
]
186200
}
187201
]
188-
open('.messages.md', 'w').write(system + "\n---\n" + body)
202+
open('.messages.md', 'w').write(system + "\n---\\n" + body)
189203

190204
console.print("[bold yellow]Question:[/bold yellow]")
191205
console.print(question)
@@ -200,13 +214,13 @@ def reply(question, files=None, attachments=None):
200214
# Stream response through a Live display
201215
with client.messages.stream(
202216
model="claude-3-7-sonnet-20250219",
203-
max_tokens=60000,
217+
max_tokens=max_tokens,
204218
temperature=1,
205219
system=system,
206220
messages=messages, # type: ignore
207221
thinking={
208222
"type": "enabled",
209-
"budget_tokens": 16000
223+
"budget_tokens": thinking_tokens,
210224
}
211225
) as stream:
212226
for event in stream:
@@ -291,12 +305,14 @@ def cli():
291305
@click.option('--file', '-f', help='Files to include in the question', multiple=True)
292306
@click.option('--image', '-i', help='Image to include in the question', multiple=True)
293307
@click.option('--output', '-o', help='location write response without thoughts', default='.response.md')
294-
def prompt(question_text, file, output, image):
308+
@click.option('--max-tokens', '-m', help='Max tokens for the response', default=60000)
309+
@click.option('--thinking-tokens', '-t', help='Max tokens for the thinking', default=16000)
310+
def prompt(question_text, file, output, image, max_tokens, thinking_tokens):
295311
question = ' '.join(question_text)
296312

297313
if question:
298314
try:
299-
response = reply(question, files=file, attachments=image)
315+
response = reply(question, files=file, attachments=image, max_tokens=max_tokens)
300316
with open(output, 'w') as f:
301317
f.write(response)
302318
console.print(f"[bold green]Output written to {escape(output)}[/bold green]")

0 commit comments

Comments
 (0)