Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mljar/plotai
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.5
Choose a base ref
...
head repository: mljar/plotai
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 7 commits
  • 4 files changed
  • 3 contributors

Commits on Oct 9, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    21dc4d0 View commit details
  2. delete bracket from ifs

    Marchlak committed Oct 9, 2024
    Copy the full SHA
    e000500 View commit details
  3. Merge pull request #12 from Marchlak/main

    add arg verbose (False, True) to constructor to disable logger (response and prompt widgets) (fixed)
    pplonski authored Oct 9, 2024
    Copy the full SHA
    02ec600 View commit details
  4. set version 0.0.6

    pplonski committed Oct 9, 2024
    Copy the full SHA
    7a95b06 View commit details

Commits on Feb 14, 2025

  1. Copy the full SHA
    bdcfb13 View commit details
  2. Copy the full SHA
    1ec190e View commit details

Commits on Feb 17, 2025

  1. Update README.md

    pplonski authored Feb 17, 2025
    Copy the full SHA
    192754b View commit details
Showing with 21 additions and 7 deletions.
  1. +6 −0 README.md
  2. +6 −1 plotai/code/executor.py
  3. +8 −5 plotai/plotai.py
  4. +1 −1 setup.py
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -23,6 +23,12 @@
<a href="https://www.linkedin.com/in/aleksandra-p%C5%82o%C5%84ska-42047432/">👩‍💼 LinkedIn</a>
</p>

## Important securitiy risk

The PlotAI executes code from LLM. It is using `exec()` function for this.

I commented out the `exec()` function in file `plotai/code/executor.py`. If you understand the security risks you need to remove comment to use the package.

# PlotAI 🎨🤖

The easiest way to create plots in Python and Matplotlib. The `plotai` is using LLM to generate code and plots.
7 changes: 6 additions & 1 deletion plotai/code/executor.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,12 @@ def run(self, code, globals_env=None, locals_env=None):
if not line.startswith("```"):
tmp_code += line + "\n"

exec(tmp_code, globals_env, locals_env)
# please be aware of security issue with exec functions
# LLM can execute arbitrary code
# if you are aware of security issues, please uncomment below line

# exec(tmp_code, globals_env, locals_env)

except Exception as e:
return str(e)
return None
13 changes: 8 additions & 5 deletions plotai/plotai.py
Original file line number Diff line number Diff line change
@@ -12,8 +12,9 @@ def __init__(self, *args, **kwargs):
self.model_version = "gpt-3.5-turbo"
# DataFrame to plot
self.df, self.x, self.y, self.z = None, None, None, None
self.verbose = True

for expected_k in ["x", "y", "z", "df", "model_version"]:
for expected_k in ["x", "y", "z", "df", "model_version", "verbose"]:
if expected_k in kwargs:
setattr(self, expected_k, kwargs[expected_k])

@@ -25,12 +26,14 @@ def __init__(self, *args, **kwargs):

def make(self, prompt):
p = Prompt(prompt, self.df, self.x, self.y, self.z)

Logger().log({"title": "Prompt", "details": p.value})

if self.verbose:
Logger().log({"title": "Prompt", "details": p.value})

response = ChatGPT(model=self.model_version).chat(p.value)

Logger().log({"title": "Response", "details": response})

if self.verbose:
Logger().log({"title": "Response", "details": response})

executor = Executor()
error = executor.run(response, globals(), {"df":self.df, "x": self.x, "y": self.y, "z": self.z})
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@

setup(
name="plotai",
version="0.0.5",
version="0.0.7",
description="Create plots in Python with AI",
long_description=long_description,
long_description_content_type="text/markdown",