ibm-granite-community / granite-snack-cookbook

Granite Snack Cookbook -- easily consumable recipes (python notebooks) that showcase the capabilities of the Granite models
Creative Commons Attribution 4.0 International
72 stars 17 forks source link

fix test failures for Agentic RAG recipe #36

Closed adampingel closed 1 month ago

adampingel commented 1 month ago

FYI @fayvor and @rawkintrevo

fayvor commented 1 month ago

@AnnaGutowska I can probably help with this. Can you tell me which version of Python you are using to get this to run successfully? It fails with Python 3.10.12 and 3.10.15.

AnnaGutowska commented 1 month ago

Hi @fayvor, I am able to run it locally with Python 3.11.9 as well as on Colab without any errors (granted that the user inputs their api key and project id where instructed)

AnnaGutowska commented 1 month ago

@fayvor please note, I will be making a PR for this change:

llm = langchain_ibm.WatsonxLLM(                   **should be just WatsonxLLM**
    model_id="ibm/granite-3-8b-instruct", 
    url=credentials.get("url"),
    apikey=credentials.get("apikey"),
    project_id=credentials.get("project_id"),
    params={
        GenParams.DECODING_METHOD: "greedy",
        GenParams.TEMPERATURE: 0,
        GenParams.MIN_NEW_TOKENS: 5,
        GenParams.MAX_NEW_TOKENS: 250,
        GenParams.STOP_SEQUENCES: ["Human:", "Observation"],
    },
)
fayvor commented 1 month ago

@AnnaGutowska I think it may pass sometimes on Colab if the libraries are installed in a certain order. Once I get it to run, I can specify a version range for the faulty package.

fayvor commented 1 month ago

@AnnaGutowska I was able to get Agentic_RAG to run on Colab (and use the Colab secrets) with these changes: https://github.com/ibm-granite-community/granite-snack-cookbook/pull/45

AnnaGutowska commented 1 month ago

Great, thank you so much! @fayvor I see the tests fail at the authentication step now and not at the package imports anymore.

fayvor commented 1 month ago

No problem! Yes, we'll need to add the WatsonX keys to the Github CI environment.

adampingel commented 1 month ago

Those are already in place

fayvor commented 1 month ago

#45 merged

fayvor commented 1 month ago

Now we're getting this "token_quota_reached" failure in Agentic_RAG:

ApiRequestFailure: Failure during generate. (POST ***ml/v1/text/generation?version=2024-10-14)
Status code: 403, body: {"errors":[{"code":"token_quota_reached","message":"Request of 1 token(s) from quota was rejected","more_info":"https://cloud.ibm.com/apidocs/watsonx-ai"}],"trace":"fd0b0ed54e2cf8b523574b4c3b30a2df","status_code":403}

https://github.com/ibm-granite-community/granite-snack-cookbook/actions/runs/11484241158/job/31961540469?pr=46

AnnaGutowska commented 1 month ago

@fayvor I am receiving the same error in this PR. Is the API key used by the org attached to a free account of watsonx? This is likely the reason for the error.