gptscript-ai / py-gptscript

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

Corrections need to be done for the example python code in Example Usage section. #3

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

Executing python code from - https://github.com/gptscript-ai/py-gptscript?tab=readme-ov-file#example-usage , results in following errors:

2024/03/06 18:25:32 failed resolving s at : can not load tools path= name=s

18:25:32 started  [main]
18:25:32 sent     [main]
18:25:32 ended    [main]

OUTPUT:

Washington, D.C.

Making few changes in the python code , results in the following expected results:

18:32:48 started  [main]
18:32:48 sent     [main]
         content  [1] content | Waiting for model response...         content  [1] content | {
         content  [1] content |     "artists": [
         content  [1] content |         {
         content  [1] content |             "name": "Elena Vasquez",
         content  [1] content |             "description": "Elena Vasquez, hailing from the vibrant streets of Buenos Aires, Argentina, is a graphic artist whose work is deeply influenced by the rich cultural heritage and bustling urban life of her homeland. Her art is a fusion of traditional South American motifs and contemporary digital techniques, creating a unique visual language that speaks of resilience, diversity, and passion. Elena's muse is the everyday life of her city; from the colorful murals that adorn the walls of La Boca to the intricate tango dances in San Telmo, every aspect of Buenos Aires life finds a way into her dynamic compositions. She believes that art is a dialogue between the creator and the viewer, aiming to evoke emotions and provoke thought through her vivid storytelling."
         content  [1] content |         },
         content  [1] content |         {
         content  [1] content |             "name": "Takumi Nakamura",
         content  [1] content |             "description": "Takumi Nakamura is a Tokyo-based graphic artist whose work is characterized by its minimalist aesthetic and profound simplicity. Drawing inspiration from the ancient Japanese philosophy of 'Wabi-sabi', which finds beauty in imperfection and transience, Takumi's art reflects the quiet, ephemeral nature of life. His muse is the natural world, particularly the serene landscapes of rural Japan. Through his work, Takumi seeks to capture the fleeting moments of beauty that nature offers, using a restrained color palette and clean lines. He believes that true art lies in the ability to convey deep emotions and complex ideas through the simplest of forms, inviting viewers to find peace and solace in his creations."
         content  [1] content |         },
         content  [1] content |         {
         content  [1] content |             "name": "Amina Yusuf",
         content  [1] content |             "description": "Amina Yusuf, from the bustling city of Lagos, Nigeria, is a graphic artist whose work is a vibrant celebration of African heritage and femininity. Her art is a bold mix of traditional African patterns, textures, and symbols with modern digital art techniques, creating pieces that are both visually striking and deeply meaningful. Amina's muse is the African woman; she draws inspiration from the stories, struggles, and triumphs of women across the continent, aiming to highlight their beauty, strength, and resilience. Through her art, Amina seeks to challenge stereotypes and inspire change, believing that art has the power to transform societies and empower individuals."
         content  [1] content |         }
         content  [1] content |     ]
         content  [1] content | }
18:33:46 ended    [main]

OUTPUT:

{
    "artists": [
        {
            "name": "Elena Vasquez",
            "description": "Elena Vasquez, hailing from the vibrant streets of Buenos Aires, Argentina, is a graphic artist whose work is deeply influenced by the rich cultural heritage and bustling urban life of her homeland. Her art is a fusion of traditional South American motifs and contemporary digital techniques, creating a unique visual language that speaks of resilience, diversity, and passion. Elena's muse is the everyday life of her city; from the colorful murals that adorn the walls of La Boca to the intricate tango dances in San Telmo, every aspect of Buenos Aires life finds a way into her dynamic compositions. She believes that art is a dialogue between the creator and the viewer, aiming to evoke emotions and provoke thought through her vivid storytelling."
        },
        {
            "name": "Takumi Nakamura",
            "description": "Takumi Nakamura is a Tokyo-based graphic artist whose work is characterized by its minimalist aesthetic and profound simplicity. Drawing inspiration from the ancient Japanese philosophy of 'Wabi-sabi', which finds beauty in imperfection and transience, Takumi's art reflects the quiet, ephemeral nature of life. His muse is the natural world, particularly the serene landscapes of rural Japan. Through his work, Takumi seeks to capture the fleeting moments of beauty that nature offers, using a restrained color palette and clean lines. He believes that true art lies in the ability to convey deep emotions and complex ideas through the simplest of forms, inviting viewers to find peace and solace in his creations."
        },
        {
            "name": "Amina Yusuf",
            "description": "Amina Yusuf, from the bustling city of Lagos, Nigeria, is a graphic artist whose work is a vibrant celebration of African heritage and femininity. Her art is a bold mix of traditional African patterns, textures, and symbols with modern digital art techniques, creating pieces that are both visually striking and deeply meaningful. Amina's muse is the African woman; she draws inspiration from the stories, struggles, and triumphs of women across the continent, aiming to highlight their beauty, strength, and resilience. Through her art, Amina seeks to challenge stereotypes and inspire change, believing that art has the power to transform societies and empower individuals."
        }
    ]
}

18:33:47 started  [main]
18:33:47 sent     [main]
18:33:47 ended    [main]

OUTPUT:

Washington, D.C.

changes made to the script:

diff exampleusageorig.py exampleusage.py
13,14c13,14
<     tools="sys.write",
<     json_response=True,
---
>     tools=["sys.write"],
> #    json_response=True,
cloudnautique commented 6 months ago

I made a modification to tools to make it an array... so the tools=["sys.write"] should be what fixed it.

cloudnautique commented 6 months ago

addressed in README on main.

sangee2004 commented 6 months ago

Also need to include json in the prompt like this - "the response json format should be" . Without this , script fails to execute with following errors:

         content  [1] content | Waiting for model response...2024/03/07 15:53:18 error, status code: 400, message: 'messages' must contain the word 'json' in some form, to use 'response_format' of type 'json_object'.
cloudnautique commented 6 months ago

Should be addressed.

sangee2004 commented 6 months ago

This issue is addressed now. Able to run the example successfully - https://github.com/gptscript-ai/py-gptscript?tab=readme-ov-file#example-usage .