Skip to content

Commit 4162346

Browse files
committed
feat(py): py menu sample
1 parent d2e55c1 commit 4162346

28 files changed

+660
-1
lines changed

py/plugins/dev-local-vector-store/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ classifiers = [
1717
dependencies = ["genkit-ai", "pytest-mock", "pytest-asyncio"]
1818
description = "Genkit Local Vector Store Plugin"
1919
license = { text = "Apache-2.0" }
20-
name = "genkit-dev-local-vectorstore-plugin"
20+
name = "vectorstore-plugin"
2121
readme = "README.md"
2222
requires-python = ">=3.12"
2323
version = "0.1.0"

py/samples/menu/data/menu.jpeg

482 KB
Loading

py/samples/menu/data/menu.json

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
[
2+
{
3+
"title": "Mozzarella Sticks",
4+
"price": 8,
5+
"description": "Crispy fried mozzarella sticks served with marinara sauce."
6+
},
7+
{
8+
"title": "Chicken Wings",
9+
"price": 10,
10+
"description": "Crispy fried chicken wings tossed in your choice of sauce."
11+
},
12+
{
13+
"title": "Nachos",
14+
"price": 12,
15+
"description": "Crispy tortilla chips topped with melted cheese, chili, sour cream, and salsa."
16+
},
17+
{
18+
"title": "Onion Rings",
19+
"price": 7,
20+
"description": "Crispy fried onion rings served with ranch dressing."
21+
},
22+
{
23+
"title": "French Fries",
24+
"price": 5,
25+
"description": "Crispy fried french fries."
26+
},
27+
{
28+
"title": "Mashed Potatoes",
29+
"price": 6,
30+
"description": "Creamy mashed potatoes."
31+
},
32+
{
33+
"title": "Coleslaw",
34+
"price": 4,
35+
"description": "Homemade coleslaw."
36+
},
37+
{
38+
"title": "Classic Cheeseburger",
39+
"price": 12,
40+
"description": "A juicy beef patty topped with melted American cheese, lettuce, tomato, and onion on a toasted bun."
41+
},
42+
{
43+
"title": "Bacon Cheeseburger",
44+
"price": 14,
45+
"description": "A classic cheeseburger with the addition of crispy bacon."
46+
},
47+
{
48+
"title": "Mushroom Swiss Burger",
49+
"price": 15,
50+
"description": "A beef patty topped with sautéed mushrooms, melted Swiss cheese, and a creamy horseradish sauce."
51+
},
52+
{
53+
"title": "Chicken Sandwich",
54+
"price": 13,
55+
"description": "A crispy chicken breast on a toasted bun with lettuce, tomato, and your choice of sauce."
56+
},
57+
{
58+
"title": "Pulled Pork Sandwich",
59+
"price": 14,
60+
"description": "Slow-cooked pulled pork on a toasted bun with coleslaw and barbecue sauce."
61+
},
62+
{
63+
"title": "Reuben Sandwich",
64+
"price": 15,
65+
"description": "Thinly sliced corned beef, Swiss cheese, sauerkraut, and Thousand Island dressing on rye bread."
66+
},
67+
{
68+
"title": "House Salad",
69+
"price": 8,
70+
"description": "Mixed greens with your choice of dressing."
71+
},
72+
{
73+
"title": "Caesar Salad",
74+
"price": 9,
75+
"description": "Romaine lettuce with croutons, Parmesan cheese, and Caesar dressing."
76+
},
77+
{
78+
"title": "Greek Salad",
79+
"price": 10,
80+
"description": "Mixed greens with feta cheese, olives, tomatoes, cucumbers, and red onions."
81+
},
82+
{
83+
"title": "Chocolate Lava Cake",
84+
"price": 8,
85+
"description": "A warm, gooey chocolate cake with a molten chocolate center."
86+
},
87+
{
88+
"title": "Apple Pie",
89+
"price": 7,
90+
"description": "A classic apple pie with a flaky crust and warm apple filling."
91+
},
92+
{
93+
"title": "Cheesecake",
94+
"price": 8,
95+
"description": "A creamy cheesecake with a graham cracker crust."
96+
}
97+
]

py/samples/menu/src/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2025 Google LLC
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# 01
5+
from case_01.prompts import s01_staticMenuDotPrompt, s01_vanillaPrompt
6+
from case_02.flows import s02_menuQuestionFlow
7+
from case_02.prompts import s02_dataMenuPrompt
8+
9+
# 02
10+
from case_02.tools import menu_tool
11+
12+
# 03
13+
from case_03.flows import s03_multiTurnChatFlow
14+
from case_03.prompts import s03_chatPreamblePrompt
15+
16+
# 04
17+
# TODO: uncomment once implemented
18+
# from case_04.flows import s04_indexMenuItemsFlow, s04_ragMenuQuestionFlow
19+
# from case_04.prompts import s04_ragDataMenuPrompt
20+
# 05
21+
from case_05.flows import (
22+
s05_readMenuFlow,
23+
s05_textMenuQuestionFlow,
24+
s05_visionMenuQuestionFlow,
25+
)
26+
from case_05.prompts import s05_readMenuPrompt, s05_textMenuPrompt
27+
28+
print('All prompts and flows loaded, use the Developer UI to test them out')
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Copyright 2025 Google LLC
2+
# SPDX-License-Identifier: Apache-2.0
3+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"input": {
3+
"question": "Which of your burgers would you recommend for someone like me who loves bacon?"
4+
}
5+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2025 Google LLC
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
from menu_ai import ai
5+
from menu_schemas import MenuQuestionInputSchema
6+
7+
from genkit.plugins.google_genai.models.gemini import gemini15Flash
8+
9+
s01_vanillaPrompt = ai.define_prompt(
10+
variant='s01_vanillaPrompt',
11+
input_schema=MenuQuestionInputSchema,
12+
system="""You are acting as a helpful AI assistant named "Walt" that can answer questions about the food available on the menu at Walt's Burgers.""",
13+
config={'temperature': 0.3},
14+
)
15+
16+
s01_staticMenuDotPrompt = ai.define_prompt(
17+
variant='s01_staticMenuDotPrompt',
18+
model=gemini15Flash.versions[0],
19+
output_format='text',
20+
input_schema=MenuQuestionInputSchema,
21+
system="""
22+
You are acting as a helpful AI assistant named "Walt" that can answer
23+
questions about the food available on the menu at Walt's Burgers.
24+
Here is today's menu:
25+
26+
- The Regular Burger $12
27+
The classic charbroiled to perfection with your choice of cheese
28+
29+
- The Fancy Burger $13
30+
Classic burger topped with bacon & Blue Cheese
31+
32+
- The Bacon Burger $13
33+
Bacon cheeseburger with your choice of cheese.
34+
35+
- Everything Burger $14
36+
Heinz 57 sauce, American cheese, bacon, fried egg & crispy onion bits
37+
38+
- Chicken Breast Sandwich $12
39+
Tender juicy chicken breast on a brioche roll.
40+
Grilled, blackened, or fried
41+
42+
Our fresh 1/2 lb. beef patties are made using choice cut
43+
brisket, short rib & sirloin. Served on a toasted
44+
brioche roll with chips. Served with lettuce, tomato & pickles.
45+
Onions upon request. Substitute veggie patty $2
46+
47+
Answer this customer's question, in a concise and helpful manner,
48+
as long as it is about food.
49+
50+
Question:
51+
{{question}} ?""",
52+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Copyright 2025 Google LLC
2+
# SPDX-License-Identifier: Apache-2.0
3+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"question": "I'd like to try something spicy. What do you recommend?"
3+
}

py/samples/menu/src/case_02/flows.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2025 Google LLC
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
from menu_ai import ai
5+
from menu_schemas import AnswerOutputSchema, MenuQuestionInputSchema
6+
7+
from .prompts import s02_dataMenuPrompt
8+
9+
10+
@ai.flow(name='s02_menuQuestion')
11+
def s02_menuQuestionFlow(
12+
my_input: MenuQuestionInputSchema,
13+
) -> AnswerOutputSchema:
14+
text = s02_dataMenuPrompt({'question': my_input.question})
15+
return AnswerOutputSchema(
16+
answer=text,
17+
)

0 commit comments

Comments
 (0)