1from typing import List
2
3from kern.agent import Agent
4from kern.media import Image
5from kern.models.mistral.mistral import MistralChat
6from pydantic import BaseModel
7
8class GroceryItem(BaseModel):
9 item_name: str
10 price: float
11
12class GroceryListElements(BaseModel):
13 bill_number: str
14 items: List[GroceryItem]
15 total_price: float
16
17agent = Agent(
18 model=MistralChat(id="pixtral-12b-2409"),
19 instructions=[
20 "Extract the text elements described by the user from the picture",
21 ],
22 output_schema=GroceryListElements,
23 markdown=True,
24)
25
26agent.print_response(
27 "From this restaurant bill, extract the bill number, item names and associated prices, and total price and return it as a string in a Json object",
28 images=[Image(url="https://i.imghippo.com/files/kgXi81726851246.jpg")],
29)