YaTharThShaRma999 commited on
Commit
53cd8f6
1 Parent(s): 12d5b53

Update modules/graph_plotter.py

Browse files
Files changed (1) hide show
  1. modules/graph_plotter.py +5 -5
modules/graph_plotter.py CHANGED
@@ -22,19 +22,19 @@ def plot_equation(equation):
22
  plt.xlim(-5, 5)
23
  plt.ylim(-5, 5)
24
  plt.gca().set_aspect('equal', adjustable='box')
25
- random_num = random.randint(1, 100)
26
- # Save plot to a PIL image
27
  fig = plt.gcf()
28
  fig.canvas.draw()
29
  image = Image.frombytes('RGB', fig.canvas.get_width_height(), fig.canvas.tostring_rgb())
30
 
31
  # Close the plot
32
  plt.close()
33
-
 
34
  # Returning the image
35
  output_dict = {
36
- "llm_output": f"Done. The graph is plotted and displayed. The graph is stored as variable {random_num}",
37
- "real_output": {"display": image, "name": random_num, "metadata": equation},
38
  "type": "image",
39
  }
40
  return output_dict
 
22
  plt.xlim(-5, 5)
23
  plt.ylim(-5, 5)
24
  plt.gca().set_aspect('equal', adjustable='box')
25
+ random_num = random.randint(1, 1000)
 
26
  fig = plt.gcf()
27
  fig.canvas.draw()
28
  image = Image.frombytes('RGB', fig.canvas.get_width_height(), fig.canvas.tostring_rgb())
29
 
30
  # Close the plot
31
  plt.close()
32
+ img_name = f"graph{random_num}.jpg"
33
+ image.save(img_name)
34
  # Returning the image
35
  output_dict = {
36
+ "llm_output": f"Done. The graph is plotted, displayed, and saved. The graph is stored as pil image variable {random_num}. It is also saved as {img_name}",
37
+ "real_output": {"display": image, "name": random_num, "metadata": equation, "file_name": img_name, "saved": True}
38
  "type": "image",
39
  }
40
  return output_dict