Vera-ZWY commited on
Commit
375dd21
1 Parent(s): 4f6e76c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -6,6 +6,8 @@ import os
6
  import pandas as pd
7
  from io import StringIO, BytesIO
8
  import base64
 
 
9
  # from linePlot import plot_stacked_time_series, plot_emotion_topic_grid
10
 
11
  # Define your Hugging Face token (make sure to set it as an environment variable)
@@ -37,14 +39,12 @@ def stream_chat_with_rag(
37
  print("top works from API:")
38
  print(fig)
39
 
40
- plot_bytes = base64.b64decode(fig['plot'].split(',')[1])
41
- img = plt.imread(BytesIO(fig), format='PNG')
42
- plt.figure(dpi = 150)
43
- plt.imshow(img)
44
- plt.axis('off')
45
- plt.show()
46
- # return answer, fig
47
- return answe, plt.gcf()
48
 
49
 
50
 
 
6
  import pandas as pd
7
  from io import StringIO, BytesIO
8
  import base64
9
+ import json
10
+ import plotly.io as pio
11
  # from linePlot import plot_stacked_time_series, plot_emotion_topic_grid
12
 
13
  # Define your Hugging Face token (make sure to set it as an environment variable)
 
39
  print("top works from API:")
40
  print(fig)
41
 
42
+ fig_dict = json.loads(plotly_data['plot'])
43
+
44
+ # Render the figure
45
+ fig = pio.from_json(json.dumps(fig_dict))
46
+ fig.show()
47
+ return answe, fig
 
 
48
 
49
 
50