rairo commited on
Commit
d38bbd7
·
1 Parent(s): eb2e505

Upload folder using huggingface_hub

Browse files
Files changed (8) hide show
  1. .env +2 -0
  2. README.md +3 -9
  3. add_inventory.py +107 -0
  4. add_to_sandbox.py +225 -0
  5. data.csv +23 -0
  6. demo.py +125 -0
  7. requirements.txt +7 -0
  8. tour_op.xlsx +0 -0
.env ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ SQUARE_ACCESS_TOKEN='EAAAEML3fhAnLQWySWj9SFXUyGUny2E_ydlJKBWhWUi8GlOmlLv9EnbNocbigitJ'
2
+ PALM="AIzaSyC0_TYwdyNsDHKHrRdzLlPQJFiq8mOvsPE"
README.md CHANGED
@@ -1,12 +1,6 @@
1
  ---
2
- title: Exponeto
3
- emoji: 🐨
4
- colorFrom: yellow
5
- colorTo: blue
6
  sdk: gradio
7
- sdk_version: 4.0.2
8
- app_file: app.py
9
- pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: exponeto
3
+ app_file: demo.py
 
 
4
  sdk: gradio
5
+ sdk_version: 3.48.0
 
 
6
  ---
 
 
add_inventory.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Import the necessary modules from the squareup library and uuid module
2
+ from square.client import Client
3
+ import os
4
+ from dotenv import load_dotenv
5
+ import uuid
6
+ import datetime
7
+
8
+ load_dotenv()
9
+
10
+
11
+ now = datetime.datetime.utcnow()
12
+ formatted_time = now.isoformat(timespec='microseconds')
13
+ # Create a client object with your sandbox access token and environment
14
+ client = Client(
15
+ access_token=os.environ['SQUARE_ACCESS_TOKEN'],
16
+ environment='sandbox'
17
+ )
18
+
19
+ # Create a dictionary of food items with name and price as keys
20
+ food_items = {
21
+ "pizza": 10.00,
22
+ "burger": 8.00,
23
+ "salad": 6.00,
24
+ "orange juice": 2.00,
25
+ "iced tea": 3.00,
26
+ "Ice coffee": 3.00,
27
+ "Chicken": 5.00,
28
+ "Steak": 10.00,
29
+ "Mashed Potatoes": 4.00,
30
+ "Soup": 2.00,
31
+ "Sandwich": 5.50,
32
+ "Pasta": 3.50,
33
+ "Coffee": 3.00,
34
+ "Cappuccino": 3.00,
35
+ "Latte": 3.00,
36
+ "Americano": 3.00,
37
+ "Hot Chocolate": 3.00,
38
+ "Muffin": 4.00,
39
+ "Cookie": 2.00,
40
+ "Croissant": 3.00,
41
+ "Tea": 2.00,
42
+ "Apple Juice": 2.00
43
+ }
44
+
45
+ # Iterate over the food items dictionary
46
+ for name, price in food_items.items():
47
+ idempotency_key = str(uuid.uuid4())
48
+
49
+ # Create an item variation for the item
50
+ variation = {
51
+ 'type': 'ITEM_VARIATION',
52
+ 'id': f'#{str(uuid.uuid4())}',
53
+ 'item_variation_data': {
54
+ 'item_id': f'#{name}',
55
+ 'pricing_type': 'FIXED_PRICING',
56
+ 'price_money': {
57
+ 'amount': int(price * 100), # Convert price to cents
58
+ 'currency': 'USD'
59
+ }
60
+ }
61
+ }
62
+
63
+ # Create the catalog object and retrieve the catalog object id
64
+ catalog_object = {
65
+ 'idempotency_key': idempotency_key,
66
+ 'object': {
67
+ 'id': f'#{name}',
68
+ 'type': 'ITEM',
69
+ 'item_data': {
70
+ 'name': name,
71
+ 'variations': [variation]
72
+ }
73
+ }
74
+ }
75
+ response = client.catalog.upsert_catalog_object(body=catalog_object)
76
+ print("\nCATALOGUE STATUS:", response.status_code)
77
+ print("\nCATALOGUE RESPONSE:", response.body)
78
+ catalog_object_id = response.body['catalog_object']['item_data']['variations'][0]['id']
79
+ created_at = response.body['catalog_object']['created_at']
80
+ # Create an inventory adjustment for the catalog object
81
+ inventory_adjustment = {
82
+ 'idempotency_key': idempotency_key,
83
+ 'changes': [
84
+ {
85
+ 'type': 'PHYSICAL_COUNT',
86
+ 'physical_count': {
87
+ 'catalog_object_id': catalog_object_id,
88
+ 'state': 'IN_STOCK',
89
+ 'location_id': 'LFA70NPRQAEV1',
90
+ 'quantity': '53',
91
+ 'occurred_at': created_at
92
+ }
93
+ }
94
+ ],
95
+ 'ignore_unchanged_counts': True
96
+ }
97
+
98
+ # Apply the inventory adjustment
99
+ try:
100
+ response = client.inventory.batch_change_inventory(
101
+ inventory_adjustment)
102
+ print("\nINVENTORY STATUS:", response.status_code)
103
+ print("\nINVENTORY RESPONSE", response.body)
104
+ print(f"Added {name} to inventory successfully.")
105
+ except:
106
+ continue
107
+
add_to_sandbox.py ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from square.client import Client, inventory_api
2
+ from dotenv import load_dotenv
3
+ import os
4
+ import square as square
5
+ load_dotenv()
6
+
7
+ client = Client(
8
+ access_token=os.environ['SQUARE_ACCESS_TOKEN'],
9
+ environment='sandbox')
10
+
11
+ inventoryApi = inventory_api.batch_change_inventoryi(client)
12
+
13
+ coffee_shop_items = {
14
+ 'Coffee': {
15
+ 'name': 'Coffee',
16
+ 'description': 'A classic coffee drink.',
17
+ 'quantity': 10,
18
+ 'price': 3.00
19
+ },
20
+ 'Latte': {
21
+ 'name': 'Latte',
22
+ 'description': 'A coffee drink with steamed milk.',
23
+ 'quantity': 10,
24
+ 'price': 4.00
25
+ },
26
+ 'Cappuccino': {
27
+ 'name': 'Cappuccino',
28
+ 'description': 'A coffee drink with steamed milk and foamed milk.',
29
+ 'quantity': 10,
30
+ 'price': 4.50
31
+ },
32
+ 'Americano': {
33
+ 'name': 'Americano',
34
+ 'description': 'A coffee drink with hot water and espresso.',
35
+ 'quantity': 10,
36
+ 'price': 3.50
37
+ },
38
+ 'Mocha': {
39
+ 'name': 'Mocha',
40
+ 'description': 'A coffee drink with chocolate and steamed milk.',
41
+ 'quantity': 10,
42
+ 'price': 4.00
43
+ },
44
+ 'Tea': {
45
+ 'name': 'Tea',
46
+ 'description': 'A hot drink made with tea leaves and water.',
47
+ 'quantity': 10,
48
+ 'price': 2.50
49
+ },
50
+ 'Hot Chocolate': {
51
+ 'name': 'Hot Chocolate',
52
+ 'description': 'A hot drink made with chocolate and milk.',
53
+ 'quantity': 10,
54
+ 'price': 3.00
55
+ },
56
+ 'Croissant': {
57
+ 'name': 'Croissant',
58
+ 'description': 'A flaky pastry.',
59
+ 'quantity': 10,
60
+ 'price': 2.00
61
+ },
62
+ 'Muffin': {
63
+ 'name': 'Muffin',
64
+ 'description': 'A quick bread made with flour, sugar, eggs, and butter.',
65
+ 'quantity': 10,
66
+ 'price': 2.50
67
+ },
68
+ 'Cookie': {
69
+ 'name': 'Cookie',
70
+ 'description': 'A sweet treat made with flour, sugar, eggs, and butter.',
71
+ 'quantity': 10,
72
+ 'price': 1.50
73
+ },
74
+
75
+ "Pizza": {
76
+ 'name': 'Pizza',
77
+ 'description': 'A classic Italian dish made with dough, tomato sauce, and cheese.',
78
+ 'quantity': 10,
79
+ 'price': 15.00
80
+ },
81
+
82
+ "Pasta":
83
+ {
84
+ 'name': 'Pasta',
85
+ 'description': 'A staple of Italian cuisine, pasta is available in a variety of shapes and sizes and can be served with a variety of sauces and toppings.',
86
+ 'quantity': 10,
87
+ 'price': 12.00
88
+ },
89
+ "Burger":
90
+ {
91
+ 'name': 'Burger',
92
+ 'description': 'A ground beef patty served on a bun with lettuce, tomato, and onion.',
93
+ 'quantity': 10,
94
+ 'price': 14.00
95
+ },
96
+ "Sandwich":
97
+ {
98
+ 'name': 'Sandwich',
99
+ 'description': 'A sandwich is a food item consisting of one or more slices of bread with a filling between them. Sandwiches can be filled with a variety of ingredients, such as meat, cheese, vegetables, and condiments.',
100
+ 'quantity': 10,
101
+ 'price': 10.00
102
+ },
103
+ "Salad":
104
+ {
105
+ 'name': 'Salad',
106
+ 'description': 'A salad is a dish of mixed raw vegetables, often with a dressing. Salads can be served as a main course or as a side dish.',
107
+ 'quantity': 10,
108
+ 'price': 12.00
109
+ },
110
+
111
+ "Soup":
112
+ {
113
+ 'name': 'Soup',
114
+ 'description': 'A soup is a liquid food made by combining water or other liquid with solid ingredients such as vegetables, meat, or grains. Soups can be served as a main course or as an appetizer.',
115
+ 'quantity': 10,
116
+ 'price': 8.00
117
+ },
118
+
119
+ "Steak":
120
+ {
121
+ 'name': 'Steak',
122
+ 'description': 'A steak is a cut of meat that is grilled or pan-fried. Steaks are typically made from beef, but they can also be made from other meats, such as pork, lamb, or chicken.',
123
+ 'quantity': 10,
124
+ 'price': 25.00
125
+ },
126
+
127
+ "Seafood":
128
+ {
129
+ 'name': 'Seafood',
130
+ 'description': 'Seafood is a term used to describe any edible creature that lives in the water. Seafood can be cooked in a variety of ways, such as grilled, fried, or baked.',
131
+ 'quantity': 10,
132
+ 'price': 20.00
133
+ },
134
+
135
+ "Chicken":
136
+ {
137
+ 'name': 'Chicken',
138
+ 'description': 'Chicken is a type of poultry that is often raised for meat. Chicken can be cooked in a variety of ways, such as grilled, fried, or baked.',
139
+ 'quantity': 10,
140
+ 'price': 16.00
141
+ },
142
+ "Dessert":
143
+ {
144
+ 'name': 'Dessert',
145
+ 'description': 'Dessert is a sweet dish that is typically eaten at the end of a meal. Desserts can be made from a variety of ingredients, such as cake, ice cream, pie, and pudding.',
146
+ 'quantity': 10,
147
+ 'price': 6.00
148
+ },
149
+ 'Iced Coffee': {
150
+ 'name': 'Iced Coffee',
151
+ 'description': 'A coffee drink that is served cold.',
152
+ 'quantity': 10,
153
+ 'price': 4.00
154
+ },
155
+ 'Iced Tea': {
156
+ 'name': 'Iced Tea',
157
+ 'description': 'A tea drink that is served cold.',
158
+ 'quantity': 10,
159
+ 'price': 3.00
160
+ },
161
+ 'Lemonade': {
162
+ 'name': 'Lemonade',
163
+ 'description': 'A drink made with lemon juice, water, and sugar.',
164
+ 'quantity': 10,
165
+ 'price': 2.50
166
+ },
167
+ 'Iced Soda': {
168
+ 'name': 'Iced Soda',
169
+ 'description': 'A soda drink that is served cold.',
170
+ 'quantity': 10,
171
+ 'price': 2.00
172
+ },
173
+ 'Fruit Juice': {
174
+ 'name': 'Fruit Juice',
175
+ 'description': 'A juice made from fruits.',
176
+ 'quantity': 10,
177
+ 'price': 3.00
178
+ },
179
+ 'Smoothie': {
180
+ 'name': 'Smoothie',
181
+ 'description': 'A drink made from blended fruits, vegetables, and yogurt.',
182
+ 'quantity': 10,
183
+ 'price': 4.50
184
+ },
185
+ 'Milkshake': {
186
+ 'name': 'Milkshake',
187
+ 'description': 'A drink made from blended ice cream, milk, and flavorings.',
188
+ 'quantity': 10,
189
+ 'price': 5.00
190
+ },
191
+ 'Slushy': {
192
+ 'name': 'Slushy',
193
+ 'description': 'A semi-frozen drink made from flavored ice.',
194
+ 'quantity': 10,
195
+ 'price': 3.50
196
+ },
197
+ 'Iced Frappuccino': {
198
+ 'name': 'Iced Frappuccino',
199
+ 'description': 'A coffee-based frozen drink from Starbucks.',
200
+ 'quantity': 10,
201
+ 'price': 5.50
202
+ },
203
+ 'Iced Matcha Latte': {
204
+ 'name': 'Iced Matcha Latte',
205
+ 'description': 'A coffee drink made with matcha powder and steamed milk.',
206
+ 'quantity': 10,
207
+ 'price': 4.00
208
+ }
209
+
210
+
211
+
212
+ }
213
+
214
+
215
+ for item_name in coffee_shop_items:
216
+ item = coffee_shop_items[item_name]
217
+
218
+ inventory_item = inventoryApi.InventoryItem(
219
+ name=item['name'],
220
+ description=item['description'],
221
+ quantity=item['quantity'],
222
+ price=item['price']
223
+ )
224
+
225
+ inventory_api.create_inventory_item(inventory_item)
data.csv ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Item Name,SKU,Quantity,Location ID
2
+ XBCZS7P3ROZU3K3N4WFDEFVG,XBCZS7P3ROZU3K3N4WFDEFVG,53,LFA70NPRQAEV1
3
+ IWEDXCLRHNBSUJS6HPLJTEDD,IWEDXCLRHNBSUJS6HPLJTEDD,53,LFA70NPRQAEV1
4
+ 4FSYGLKEYDVABXFKCO43PZAI,4FSYGLKEYDVABXFKCO43PZAI,53,LFA70NPRQAEV1
5
+ N4DWPFHENM5BMMQRYR5BMNFV,N4DWPFHENM5BMMQRYR5BMNFV,53,LFA70NPRQAEV1
6
+ RXBGD4OCGG6FHAED6TH2XNXW,RXBGD4OCGG6FHAED6TH2XNXW,53,LFA70NPRQAEV1
7
+ UVJIHZ6JKNPEQBEFEVGVG3DM,UVJIHZ6JKNPEQBEFEVGVG3DM,53,LFA70NPRQAEV1
8
+ DZJOLP43VANZSWQWIPLSQXBL,DZJOLP43VANZSWQWIPLSQXBL,53,LFA70NPRQAEV1
9
+ UHDPV6WBVBSPAZESIEKON3FS,UHDPV6WBVBSPAZESIEKON3FS,53,LFA70NPRQAEV1
10
+ WJIPZMFUHQLFS6SGR3CAPBR7,WJIPZMFUHQLFS6SGR3CAPBR7,53,LFA70NPRQAEV1
11
+ XJNGEUEUL4ZJ2NBQTUIWLX4E,XJNGEUEU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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import pprint
3
+ import google.generativeai as palm
4
+ import pandas as pd
5
+
6
+ import os
7
+
8
+ from square.client import Client
9
+ import gradio as gr
10
+ import io
11
+
12
+ from langchain.agents import initialize_agent, AgentType
13
+ from langchain.llms import GooglePalm
14
+ import pandas as pd
15
+ #from yolopandas import pd
16
+ from langchain.chains.question_answering import load_qa_chain
17
+ from langchain import PromptTemplate, LLMChain
18
+ from langchain.agents import create_pandas_dataframe_agent
19
+ from langchain.tools import DuckDuckGoSearchRun
20
+ from pandasai import PandasAI
21
+
22
+
23
+ from dotenv import load_dotenv
24
+
25
+ load_dotenv()
26
+
27
+
28
+ client = Client(
29
+ access_token=os.environ['SQUARE_ACCESS_TOKEN'],
30
+ environment='sandbox')
31
+
32
+ location_id='LFA70NPRQAEV1'
33
+
34
+ palm.configure(api_key=os.environ['PALM'])
35
+
36
+ models = [m for m in palm.list_models(
37
+ ) if 'generateText' in m.supported_generation_methods]
38
+ model = models[0].name
39
+ print(model)
40
+
41
+
42
+ load_dotenv()
43
+
44
+
45
+
46
+ # Define a function to fetch inventory items
47
+
48
+ def fetch_inventory_items():
49
+ response = client.inventory.batch_retrieve_inventory_counts(
50
+ body={
51
+ 'catalog_object_ids': [],
52
+ 'location_ids': []
53
+ }
54
+ )
55
+ print(response.status_code)
56
+ print(response.body)
57
+ inventory_items = response.body['counts']
58
+
59
+ items_data = []
60
+ for item in inventory_items:
61
+ item_data = {
62
+ 'Item Name': item['catalog_object_id'],
63
+ # SKU not available in response, using catalog_object_id as a placeholder
64
+ 'SKU': item['catalog_object_id'],
65
+ 'Quantity': item['quantity'],
66
+ 'Location ID': item['location_id']
67
+ }
68
+ items_data.append(item_data)
69
+
70
+ return items_data
71
+
72
+
73
+ # Fetch inventory items
74
+ inventory_items = fetch_inventory_items()
75
+
76
+ # Convert inventory data to a Pandas dataframe
77
+ df = pd.DataFrame(inventory_items)
78
+
79
+
80
+ # Print the dataframe
81
+ print(df)
82
+ df.to_csv("data.csv", index=False)
83
+ # Retrieve catalog objects
84
+ catalog_objects = client.catalog.batch_retrieve_catalog_objects(
85
+ body={
86
+ 'object_ids': df['Item Name'].tolist(),
87
+ 'include_related_objects': True
88
+ }
89
+ )
90
+ catalog_objects = catalog_objects.body['objects']
91
+
92
+ #print(catalog_objects)
93
+ #llm = GooglePalm(google_api_key=os.environ['PALM'])
94
+ #llm.temperature = 0.1
95
+
96
+ #prompts = ['Explain the difference between effective and affective with examples']
97
+ #llm_result = llm._generate(prompts)
98
+
99
+ #print(llm_result.generations[0][0].text)
100
+
101
+
102
+
103
+
104
+
105
+ def questiondocument(user_question):
106
+ load_dotenv()
107
+ #df = pd.read_csv("data.csv")
108
+ df = pd.read_excel("tour_op.xlsx")
109
+
110
+ agent = create_pandas_dataframe_agent(GooglePalm(temperature=0, google_api_key=os.environ['PALM']), df, agent="structured_chat-zero-shot-react-description", verbose=True)
111
+ response = agent.run(user_question)
112
+ #response = pandas_ai(df, prompt=user_question)
113
+
114
+ return response
115
+
116
+
117
+ demo = gr.Interface(
118
+
119
+ fn=questiondocument,
120
+ inputs=["text"],
121
+ outputs=["text"],
122
+ title="Ask Busy Helper",
123
+ )
124
+ demo.launch(share=True)
125
+
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ squareup
2
+ google-generativeai
3
+ python-dotenv
4
+ pandas
5
+ langchain
6
+ gradio
7
+ openpyxl
tour_op.xlsx ADDED
Binary file (14.5 kB). View file