gptscript-ai / py-gptscript

Python module for running GPTScript
Apache License 2.0
10 stars 7 forks source link

Example python code provided for exec(tool) fails with "TypeError: exec() arg 1 must be a string, bytes or code object" #1

Closed sangee2004 closed 6 months ago

sangee2004 commented 6 months ago

Installed using - pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ gptscript==0.1.0rc1

Example python code provided for exec(tool) fails with "TypeError: exec() arg 1 must be a string, bytes or code object"

python test.py
Traceback (most recent call last):
  File "/Users/sangeethahariharan/gptscriprelease/gptscript/examples/test.py", line 27, in <module>
    response = exec(tool)
TypeError: exec() arg 1 must be a string, bytes or code object
sangeethahariharan@Sangeethas-MacBook-Pro examples % python test.py
Traceback (most recent call last):
  File "/Users/sangeethahariharan/gptscriprelease/gptscript/examples/test.py", line 27, in <module>
    response = exec(tool)
TypeError: exec() arg 1 must be a string, bytes or code object
% cat test.py
from gptscript.command import list_models, list_tools
from gptscript.tool import Tool

#models = list_models()
#print(models)
#tools = list_tools()
#print(tools)

tool = Tool(
    json_response=True,
    instructions="""
Create three short graphic artist descriptions and their muses. 
These should be descriptive and explain their point of view.
Also come up with a made up name, they each should be from different
backgrounds and approach art differently.
the response should be in JSON and match the format:
{
   artists: [{
      name: "name"
      description: "description"
   }]
}
""",
    )

response = exec(tool)
print(response)

Also there is a typo in from gptsript.tool import Tool which needs to fixed to from gptscript.tool import Tool

cloudnautique commented 6 months ago

Updated the README on main, should be fixed.

sangee2004 commented 6 months ago

This is fixed now.