AI / Apache Burr Interview questions
What is the difference between application-level and action-level typing in Burr?
Both use Pydantic, but they type different scopes of your app:
| Scope | How it’s set | Benefit |
| Application-level | with_typing(PydanticTypingSystem(MyState)) + with_state(MyState()) | The whole app is typed; app.state.data is a real instance of your model, giving IDE autocompletion end-to-end. |
| Action-level | @action.pydantic(reads=[...], writes=[...]) on an individual function | Type just that action’s slice of state without declaring the entire schema up front; you mutate the model in place. |
@action.pydantic(reads=["prompt", "chat_history"], writes=["response"]) def image_response(state: ApplicationState, model: str = "dall-e-2") -> ApplicationState: result = client.images.generate(model=model, prompt=state.prompt, size="1024x1024", n=1) state.response = {"content": result.data[0].url, "role": "assistant"} return state
Action-level typing subsets state on input and merges it back on output, just like the untyped API does — so referencing a field you didn’t declare in reads/writes is an error, keeping actions modular even when typed.
More Related questions...