Spaces:
Running
Running
Commit
·
21f3db9
1
Parent(s):
9a0427b
update data
Browse files
app.py
CHANGED
@@ -12,10 +12,30 @@ client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
|
12 |
script_dir = os.path.dirname(os.path.abspath(__file__))
|
13 |
|
14 |
printer_1 = """
|
15 |
-
|
16 |
Product: Business Cards
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
25,2.0
|
20 |
50,1.6
|
21 |
100,1.0
|
@@ -29,10 +49,30 @@ Quantity,Price per Unit ($)
|
|
29 |
"""
|
30 |
|
31 |
printer_2 = """
|
32 |
-
BannerLord
|
33 |
Product: Business Cards
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
25,2.4
|
37 |
50,1.8
|
38 |
100,1.2
|
@@ -46,14 +86,34 @@ Quantity,Price per Unit ($)
|
|
46 |
"""
|
47 |
|
48 |
printer_3 = """
|
49 |
-
PrintMaster
|
50 |
Product: Business Cards
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
50,1.4
|
54 |
75,1.2
|
55 |
100,1.05
|
56 |
-
150,1
|
57 |
200,0.875
|
58 |
250,0.72
|
59 |
500,0.4
|
@@ -67,21 +127,29 @@ Quantity,Price per Unit ($)
|
|
67 |
def find_best_price(request):
|
68 |
chat_prompt = (
|
69 |
"You are a customer assistant and you have to find the best price for the customer. "
|
70 |
-
"Here are the prices from the printers:\n"
|
71 |
-
f"Printer 1
|
72 |
-
f"Printer 2
|
73 |
-
f"Printer 3
|
74 |
-
"
|
75 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
"Example:\n"
|
77 |
-
"User: I want to print 600
|
78 |
"Answer:\n"
|
79 |
-
"
|
80 |
-
"
|
81 |
-
"
|
82 |
-
"
|
83 |
-
"
|
84 |
-
"The '###' symbol
|
|
|
85 |
)
|
86 |
|
87 |
chat_response = client.chat.completions.create(
|
|
|
12 |
script_dir = os.path.dirname(os.path.abspath(__file__))
|
13 |
|
14 |
printer_1 = """
|
15 |
+
# PrinterOne
|
16 |
Product: Business Cards
|
17 |
+
Surface Options:
|
18 |
+
plastic:
|
19 |
+
multiplier: 1.0
|
20 |
+
cardboard:
|
21 |
+
multiplier: 0.9
|
22 |
+
wood:
|
23 |
+
multiplier: 1.3
|
24 |
+
|
25 |
+
Sizes:
|
26 |
+
3x3 cm: multiplier 1.0
|
27 |
+
6x6 cm: multiplier 1.8
|
28 |
+
|
29 |
+
Finishing:
|
30 |
+
gloss: multiplier 1.1
|
31 |
+
matt: multiplier 1.0
|
32 |
+
|
33 |
+
Label Types:
|
34 |
+
permanent: multiplier 1.0
|
35 |
+
repositionable: multiplier 1.15
|
36 |
+
removable: multiplier 1.2
|
37 |
+
|
38 |
+
Base Prices (Quantity,Price per Unit $):
|
39 |
25,2.0
|
40 |
50,1.6
|
41 |
100,1.0
|
|
|
49 |
"""
|
50 |
|
51 |
printer_2 = """
|
52 |
+
# BannerLord
|
53 |
Product: Business Cards
|
54 |
+
Surface Options:
|
55 |
+
plastic:
|
56 |
+
multiplier: 1.0
|
57 |
+
cardboard:
|
58 |
+
multiplier: 0.85
|
59 |
+
wood:
|
60 |
+
multiplier: 1.4
|
61 |
+
|
62 |
+
Sizes:
|
63 |
+
3x3 cm: multiplier 1.0
|
64 |
+
6x6 cm: multiplier 1.9
|
65 |
+
|
66 |
+
Finishing:
|
67 |
+
gloss: multiplier 1.15
|
68 |
+
matt: multiplier 1.0
|
69 |
+
|
70 |
+
Label Types:
|
71 |
+
permanent: multiplier 1.0
|
72 |
+
repositionable: multiplier 1.2
|
73 |
+
removable: multiplier 1.25
|
74 |
+
|
75 |
+
Base Prices (Quantity,Price per Unit $):
|
76 |
25,2.4
|
77 |
50,1.8
|
78 |
100,1.2
|
|
|
86 |
"""
|
87 |
|
88 |
printer_3 = """
|
89 |
+
# PrintMaster
|
90 |
Product: Business Cards
|
91 |
+
Surface Options:
|
92 |
+
plastic:
|
93 |
+
multiplier: 1.0
|
94 |
+
cardboard:
|
95 |
+
multiplier: 1.1
|
96 |
+
wood:
|
97 |
+
multiplier: 1.25
|
98 |
+
|
99 |
+
Sizes:
|
100 |
+
3x3 cm: multiplier 1.0
|
101 |
+
6x6 cm: multiplier 1.85
|
102 |
+
|
103 |
+
Finishing:
|
104 |
+
gloss: multiplier 1.12
|
105 |
+
matt: multiplier 1.0
|
106 |
+
|
107 |
+
Label Types:
|
108 |
+
permanent: multiplier 1.0
|
109 |
+
repositionable: multiplier 1.18
|
110 |
+
removable: multiplier 1.22
|
111 |
+
|
112 |
+
Base Prices (Quantity,Price per Unit $):
|
113 |
50,1.4
|
114 |
75,1.2
|
115 |
100,1.05
|
116 |
+
150,1.0
|
117 |
200,0.875
|
118 |
250,0.72
|
119 |
500,0.4
|
|
|
127 |
def find_best_price(request):
|
128 |
chat_prompt = (
|
129 |
"You are a customer assistant and you have to find the best price for the customer. "
|
130 |
+
"Here are the prices and options from the printers:\n"
|
131 |
+
f"Printer 1: {printer_1}\n"
|
132 |
+
f"Printer 2: {printer_2}\n"
|
133 |
+
f"Printer 3: {printer_3}\n"
|
134 |
+
"For each request, you should:\n"
|
135 |
+
"1. Check if the requested size (3x3 or 6x6 cm) is available. If not, suggest the nearest available size.\n"
|
136 |
+
"2. Calculate the final price by:\n"
|
137 |
+
" - Finding the nearest lower quantity in the base price list\n"
|
138 |
+
" - Multiplying by the surface option multiplier\n"
|
139 |
+
" - Multiplying by the size multiplier\n"
|
140 |
+
" - Multiplying by the finishing multiplier\n"
|
141 |
+
" - Multiplying by the label type multiplier\n"
|
142 |
+
"3. Do not use linear interpolation for quantities - use the nearest lower quantity pricing.\n\n"
|
143 |
"Example:\n"
|
144 |
+
"User: I want to print 600 business cards, 6x6 cm size, premium white surface, gloss finish, permanent labels\n"
|
145 |
"Answer:\n"
|
146 |
+
"PrinterOne: 500 cards at base price $0.36. With multipliers (surface: 1.0, size: 1.8, finish: 1.1, label: 1.0) = $0.713 per unit. Total for 600: $427.80\n"
|
147 |
+
"###\n"
|
148 |
+
"BannerLord: 500 cards at base price $0.4. With multipliers (surface: 1.0, size: 1.9, finish: 1.15, label: 1.0) = $0.874 per unit. Total for 600: $524.40\n"
|
149 |
+
"###\n"
|
150 |
+
"PrintMaster: 500 cards at base price $0.4. With multipliers (surface: 1.0, size: 1.85, finish: 1.12, label: 1.0) = $0.829 per unit. Total for 600: $497.40\n\n"
|
151 |
+
"The '###' symbol must separate each printer's price calculation. Show all calculations clearly as in the example above.\n"
|
152 |
+
"For each printer, first state the base quantity and price, then show all applicable multipliers, the final per-unit price, and the total cost."
|
153 |
)
|
154 |
|
155 |
chat_response = client.chat.completions.create(
|