Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -173,12 +173,13 @@ def random_response(message):
|
|
| 173 |
# "please give me the most related and useful possible question to get simple but useful insights for {question}."
|
| 174 |
"The data is sales order line is every transaction of the company."
|
| 175 |
"Base on the question:{question}, regenerate the output"
|
| 176 |
-
"Your output will be used to guide the graph generation by python using ploty, so make it simple and easier to process data."
|
| 177 |
"For example: 'Goal(question='What are the sales trends by product category?visualization='bar chart of prod_category against sum(trxn_item_qty) grouped by trxn_date'. and"
|
| 178 |
"'Goal(question='Who are the top customers based on transaction count?', visualization='Bar chart of customer_name vs. count(trxn_id)')"
|
|
|
|
| 179 |
"Usually, when group by age, show all the data."
|
| 180 |
"But for other datas: customer,prouct,sales,qty,etc show top 10."
|
| 181 |
-
"Process the data at last when put in the graph."
|
| 182 |
"When ask customers,customer, it means customer_name."
|
| 183 |
"When ask product, it means prod_name."
|
| 184 |
"When ask category, it means prod_category."
|
|
@@ -187,6 +188,7 @@ def random_response(message):
|
|
| 187 |
"Only output 1 question."
|
| 188 |
"")
|
| 189 |
|
|
|
|
| 190 |
chain = (
|
| 191 |
{"str_summary": RunnablePassthrough(),"question": RunnablePassthrough()}
|
| 192 |
| prompt
|
|
@@ -203,7 +205,7 @@ def random_response(message):
|
|
| 203 |
|
| 204 |
|
| 205 |
try:
|
| 206 |
-
temp_chart = lida.visualize(summary=summary, goal=str(insights)+
|
| 207 |
print(f'*'*50)
|
| 208 |
code = temp_chart[0].code
|
| 209 |
print(f"{code}")
|
|
@@ -222,6 +224,8 @@ def random_response(message):
|
|
| 222 |
# Open the image file
|
| 223 |
# img = Image.open(image_path)
|
| 224 |
img = mpimg.imread('chart_1.png')
|
|
|
|
|
|
|
| 225 |
|
| 226 |
base64_image = encode_image(image_path)
|
| 227 |
|
|
@@ -231,7 +235,7 @@ def random_response(message):
|
|
| 231 |
[
|
| 232 |
HumanMessage(
|
| 233 |
content=[
|
| 234 |
-
{"type": "text", "text": f"Give me some business insights base on the graph
|
| 235 |
{
|
| 236 |
"type": "image_url",
|
| 237 |
"image_url": {
|
|
|
|
| 173 |
# "please give me the most related and useful possible question to get simple but useful insights for {question}."
|
| 174 |
"The data is sales order line is every transaction of the company."
|
| 175 |
"Base on the question:{question}, regenerate the output"
|
| 176 |
+
# "Your output will be used to guide the graph generation by python using ploty, so make it simple and easier to process data."
|
| 177 |
"For example: 'Goal(question='What are the sales trends by product category?visualization='bar chart of prod_category against sum(trxn_item_qty) grouped by trxn_date'. and"
|
| 178 |
"'Goal(question='Who are the top customers based on transaction count?', visualization='Bar chart of customer_name vs. count(trxn_id)')"
|
| 179 |
+
"The visualization should align with the question and the data."
|
| 180 |
"Usually, when group by age, show all the data."
|
| 181 |
"But for other datas: customer,prouct,sales,qty,etc show top 10."
|
| 182 |
+
"Process the top data at last when put in the graph."
|
| 183 |
"When ask customers,customer, it means customer_name."
|
| 184 |
"When ask product, it means prod_name."
|
| 185 |
"When ask category, it means prod_category."
|
|
|
|
| 188 |
"Only output 1 question."
|
| 189 |
"")
|
| 190 |
|
| 191 |
+
|
| 192 |
chain = (
|
| 193 |
{"str_summary": RunnablePassthrough(),"question": RunnablePassthrough()}
|
| 194 |
| prompt
|
|
|
|
| 205 |
|
| 206 |
|
| 207 |
try:
|
| 208 |
+
temp_chart = lida.visualize(summary=summary, goal=str(insights)+"Graph heigh 800,width 1000.Set different colors to different varibles.x label rotate 45 degree,do not use the guide line", textgen_config=text_gen_config,library='matplotlib')
|
| 209 |
print(f'*'*50)
|
| 210 |
code = temp_chart[0].code
|
| 211 |
print(f"{code}")
|
|
|
|
| 224 |
# Open the image file
|
| 225 |
# img = Image.open(image_path)
|
| 226 |
img = mpimg.imread('chart_1.png')
|
| 227 |
+
print(f'*'*50)
|
| 228 |
+
print(f"Image opened")
|
| 229 |
|
| 230 |
base64_image = encode_image(image_path)
|
| 231 |
|
|
|
|
| 235 |
[
|
| 236 |
HumanMessage(
|
| 237 |
content=[
|
| 238 |
+
{"type": "text", "text": f"Give me some business insights base on the graph, contain exact number conclusion."},
|
| 239 |
{
|
| 240 |
"type": "image_url",
|
| 241 |
"image_url": {
|