Skip to content

Commit f691d93

Browse files
committed
readme-update
1 parent f4ab6ba commit f691d93

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,65 @@ async def generate_poke_desc(text: str) -> Summary:
124124
resp = asyncio.run(generate_poke_desc("pikachu"))
125125
print(resp)
126126
```
127+
128+
### Debug mode
129+
130+
The library also supports debug mode. This is useful if you want to see the prompt that was used or if you want to see the response that was returned.
131+
132+
```python
133+
import asyncio
134+
from smartfunc import async_backend
135+
from pydantic import BaseModel
136+
from dotenv import load_dotenv
137+
138+
load_dotenv(".env")
139+
140+
141+
class Summary(BaseModel):
142+
summary: str
143+
pros: list[str]
144+
cons: list[str]
145+
146+
147+
@async_backend("gpt-4o-mini", debug=True)
148+
async def generate_poke_desc(text: str) -> Summary:
149+
"""Describe the following pokemon: {{ text }}"""
150+
pass
151+
152+
resp = asyncio.run(generate_poke_desc("pikachu"))
153+
print(resp)
154+
```
155+
156+
This will return a dictionary with the debug information.
157+
158+
```python
159+
{
160+
'summary': 'Pikachu is a small, yellow, rodent-like Pokémon known for its electric powers and iconic status as the franchise mascot. It has long ears with black tips, red cheeks that store electricity, and a lightning bolt-shaped tail. Pikachu evolves from Pichu when leveled up with high friendship and can further evolve into Raichu when exposed to a Thunder Stone. Pikachu is often depicted as cheerful, playfully energetic, and is renowned for its ability to generate electricity, which it can unleash in powerful attacks such as Thunderbolt and Volt Tackle.',
161+
'pros': [
162+
'Iconic mascot of the Pokémon franchise', 'Popular among fans of all ages', 'Strong electric-type moves', 'Cute and friendly appearance'
163+
],
164+
'cons': [
165+
'Limited range of evolution (only evolves into Raichu)', 'Commonly found, which may reduce uniqueness', 'Vulnerable to ground-type moves', 'Requires high friendship for evolution to Pichu, which can be a long process'
166+
],
167+
'_debug': {
168+
'template': 'Describe the following pokemon: {{ text }}',
169+
'func_name': 'generate_poke_desc',
170+
'prompt': 'Describe the following pokemon: pikachu',
171+
'system': None,
172+
'template_inputs': {
173+
'text': 'pikachu'
174+
},
175+
'backend_kwargs': {},
176+
'datetime': '2025-03-13T16:05:44.754579',
177+
'return_type': {
178+
'properties': {
179+
'summary': {'title': 'Summary', 'type': 'string'},
180+
'pros': {'items': {'type': 'string'}, 'title': 'Pros', 'type': 'array'},
181+
'cons': {'items': {'type': 'string'}, 'title': 'Cons', 'type': 'array'}},
182+
'required': ['summary', 'pros', 'cons'],
183+
'title': 'Summary',
184+
'type': 'object'
185+
}
186+
}
187+
}
188+
```

0 commit comments

Comments
 (0)