aws-samples / amazon-bedrock-workshop

This is a workshop designed for Amazon Bedrock a foundational model service.
https://catalog.us-east-1.prod.workshops.aws/workshops/a4bdb007-5600-4368-81c5-ff5b4154f518/en-US/20-intro
MIT No Attribution
1.34k stars 576 forks source link

Added installation of anthropic since it is used by langchain functio… #173

Closed lukas-wenzel-hh closed 7 months ago

lukas-wenzel-hh commented 7 months ago

…n get_num_tokens() for token counting when using anthropic models with bedrock

Issue #, if available: An issue occurred when executing a cell in 02_contextual_generation.ipynb

The following cell indicated the anthropic library missing. This only happens when a Anthropic model is used with Bedrock. This refers to the anthropic library not being installed on the machine the notebook is used on. The library is used by langchain for token counting.

num_tokens = textgen_llm.get_num_tokens(prompt) print(f”Our prompt has {num_tokens} tokens”)

Error: ModuleNotFoundError Traceback (most recent call last) File /opt/conda/lib/python3.10/site-packages/langchain_community/utilities/anthropic.py:6, in _get_anthropic_client() 5 try: ----> 6 import anthropic 7 except ImportError:

ModuleNotFoundError: No module named 'anthropic'

Description of changes: Added the installation of the anthropic library to the set-up notebook in 00-intro

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.