diff --git a/nb/.gitignore b/nb/.gitignore index c1e958b..bdea9b6 100644 --- a/nb/.gitignore +++ b/nb/.gitignore @@ -6,6 +6,9 @@ dist/ wheels/ *.egg-info +# env +.env + # venv .venv diff --git a/nb/README.md b/nb/README.md index 47bad64..39718a3 100644 --- a/nb/README.md +++ b/nb/README.md @@ -1,3 +1,15 @@ # nb Describe your project here. + + +# Setup + +``` +rye sync +``` + +Create a `.env` file in `nb/` next to this README with the following: +``` +ANTHROPIC_API_KEY="YOUR_KEY_HERE" +``` diff --git a/nb/pyproject.toml b/nb/pyproject.toml index ad5739b..734f2dc 100644 --- a/nb/pyproject.toml +++ b/nb/pyproject.toml @@ -8,6 +8,7 @@ authors = [ dependencies = [ "datasets>=2.21.0", "anthropic>=0.34.2", + "python-dotenv>=1.0.1", ] readme = "README.md" requires-python = ">= 3.8" diff --git a/nb/requirements-dev.lock b/nb/requirements-dev.lock index 41c968d..28fbccc 100644 --- a/nb/requirements-dev.lock +++ b/nb/requirements-dev.lock @@ -268,6 +268,8 @@ python-dateutil==2.9.0.post0 # via arrow # via jupyter-client # via pandas +python-dotenv==1.0.1 + # via nb python-json-logger==2.0.7 # via jupyter-events pytz==2024.1 diff --git a/nb/requirements.lock b/nb/requirements.lock index 2ab54cf..a3c87de 100644 --- a/nb/requirements.lock +++ b/nb/requirements.lock @@ -86,6 +86,8 @@ pydantic-core==2.23.3 # via pydantic python-dateutil==2.9.0.post0 # via pandas +python-dotenv==1.0.1 + # via nb pytz==2024.1 # via pandas pyyaml==6.0.2 diff --git a/nb/src/nb/claude_prompting.py b/nb/src/nb/claude_prompting.py new file mode 100644 index 0000000..f30483a --- /dev/null +++ b/nb/src/nb/claude_prompting.py @@ -0,0 +1,21 @@ +from anthropic import Anthropic +from dotenv import load_dotenv +from os import getenv + +load_dotenv() +ANTHROPIC_API_KEY = getenv("ANTHROPIC_API_KEY") + +client = Anthropic(api_key=ANTHROPIC_API_KEY) +MODEL_NAME = "claude-3-opus-20240229" + +message = client.messages.create( + model=MODEL_NAME, + max_tokens=512, + messages=[ + { + "role": "user", + "content": "Give me a JSON dict with names of famous athletes & their sports." + }, + ] +).content[0].text +print(message)