Skip to content

Commit ed2535e

Browse files
authored
Merge branch 'main' into README-changes
2 parents 40caaa5 + ac2a5ec commit ed2535e

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,28 @@ https://github.com/user-attachments/assets/65d0f34e-2bb7-42bf-ab5c-be1cca96a2c6
111111

112112
- **Cost tracking**: Automatically calculates and tracks the cost of each AI model run, providing transparency and helping you manage your AI budget effectively. Learn more about [cost tracking](https://docs.workflowai.com/python-sdk/agent#cost-latency).
113113

114+
```python
115+
class AnswerQuestionInput(BaseModel):
116+
question: str
117+
118+
class AnswerQuestionOutput(BaseModel):
119+
answer: str
120+
121+
@workflowai.agent(id="answer-question")
122+
async def answer_question(input: AnswerQuestionInput) -> AnswerQuestionOutput:
123+
"""
124+
Answer a question.
125+
"""
126+
...
127+
128+
run = await answer_question.run(AnswerQuestionInput(question="What is the history of Paris?"))
129+
print(f"Cost: $ {run.cost_usd:.5f}")
130+
print(f"Latency: {run.duration_seconds:.2f}s")
131+
132+
# Cost: $ 0.00745
133+
# Latency: 8.99s
134+
```
135+
114136
## Get Started
115137

116138
`workflowai` requires Python 3.9 or higher.

0 commit comments

Comments
 (0)