Git Product home page Git Product logo

Comments (6)

vasinov avatar vasinov commented on May 20, 2024

@ysammy, this particular activity is going to be re-written from scratch and allow for better customization, once we resolve #33. Right now summarize_text doesn't even use the driver as it depends on LlamaIndex.

Which tool were you trying to use memory summarization with?

from griptape.

ysammy avatar ysammy commented on May 20, 2024

I pasted the example from this section into a notebook. The one difference is setting the prompt driver explicitly with my API key. I went this route because I found that the example wasn't respecting openai.api_key or os.environ["OPENAI_API_KEY"] when run in a notebook.

# Pipelines represent sequences of tasks.
pipeline = Pipeline(
    memory=ConversationMemory(),
    prompt_driver=OpenAiPromptDriver(
        api_key=OPENAI_API_KEY,
    ),
)

The output I get is as follows:

[06/22/23 10:07:20] INFO     Task d5904fcd762b4a9aaa9bbe80df5c20aa                                                 
                             Input: Load https://www.griptape.ai, summarize it, and store it in griptape.txt       
[06/22/23 10:07:22] INFO     Subtask c3e97f0ad62741c8b7c849355c1e6883                                              
                             Thought: I can use the WebScraper tool to load the website, then use the              
                             TextToolMemory to store the content, and finally use the summarize activity to        
                             generate a summary. After that, I can use the FileManager tool to save the summary to 
                             a file on disk.                                                                       
                             Action: {"type": "tool", "name": "WebScraper", "activity": "get_content", "input":    
                             {"values": {"url": "https://www.griptape.ai"}}}                                       
[06/22/23 10:07:23] INFO     Subtask c3e97f0ad62741c8b7c849355c1e6883                                              
                             Observation: Output of "WebScraper.get_content" was stored in memory "TextToolMemory" 
                             with the following artifact namespace: bc69a45812dc46fd8a51f07b29aee96a               
[06/22/23 10:07:24] INFO     Subtask fcb16c0d788c4673bacc14aaf3fa5aaf                                              
                             Action: {"type": "memory", "name": "TextToolMemory", "activity": "summarize", "input":
                             {"values": {"artifact_namespace": "bc69a45812dc46fd8a51f07b29aee96a"}}}               
[06/22/23 10:07:31] INFO     Subtask fcb16c0d788c4673bacc14aaf3fa5aaf                                              
                             Observation: error summarizing text: RetryError[<Future at 0x2b74942d0 state=finished 
                             raised AuthenticationError>]                                                          
ERROR:root:PromptDriver.run attempt 0 failed: No API key provided. You can set your API key in code using 'openai.api_key = <API-KEY>', or you can set the environment variable OPENAI_API_KEY=<API-KEY>). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = <PATH>'. You can generate API keys in the OpenAI web interface. See https://platform.openai.com/account/api-keys for details.
Retrying in 1 seconds

Tracing the code to where error summarizing text is raised in an exception led me to the issue I referenced. I suspect it is because the OpenAiPromptDriver created inline doesn't include my API key.

from griptape.

vasinov avatar vasinov commented on May 20, 2024

I went this route because I found that the example wasn't respecting openai.api_key or os.environ["OPENAI_API_KEY"] when run in a notebook.

Does that mean that you tried setting the OPENAI_API_KEY env var in the notebook before running the code and it didn't work? If so, can you make sure it was set correctly:

os.environ["OPENAI_API_KEY"] = <your key>
assert os.environ["OPENAI_API_KEY"]

If that works but the env var doesn't get picked up by the openai lib then there is something weird going on :)

from griptape.

ysammy avatar ysammy commented on May 20, 2024

Can confirm that the assertion passes and the default OpenAiPromptDriver for the pipeline cannot find the key. I have not yet had a chance to debug why this is the case.

from griptape.

vasinov avatar vasinov commented on May 20, 2024

I figured out what the issue is...

openai.api_key, which defaults to OPENAY_API_KEY, is loaded during the import. Setting OPENAI_API_KEY later doesn't do anything. I pushed a fix for this to main. Let me know if it fixes the issue in your notebook.

from griptape.

ysammy avatar ysammy commented on May 20, 2024

I figured it was something like that. Confirmed this works!

from griptape.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.