Skip to content

Commit f99fb6a

Browse files
committed
fix: linting and README
1 parent a12b956 commit f99fb6a

9 files changed

Lines changed: 92 additions & 152 deletions

File tree

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Python
1717
uses: actions/setup-python@v5
1818
with:
19-
python-version: "3.14"
19+
python-version: "3.13"
2020
- name: Install pypa/build
2121
run: >-
2222
python3 -m

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
14+
python-version: ["3.10", "3.11", "3.12", "3.13"]
1515

1616
steps:
1717
- uses: actions/checkout@v3

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![PyPI version](https://badge.fury.io/py/strands-nova.svg)](https://badge.fury.io/py/strands-nova)
44
[![Python Support](https://img.shields.io/pypi/pyversions/strands-nova.svg)](https://pypi.org/project/strands-nova/)
5-
[![Tests](https://github.com/aidendef/strands-nova/actions/workflows/test.yml/badge.svg)](https://github.com/aidendef/strands-nova/actions/workflows/test.yml)
5+
[![Tests](https://github.com/RyanDsilva/strands-nova/actions/workflows/test.yml/badge.svg)](https://github.com/RyanDsilva/strands-nova/actions/workflows/test.yml)
66
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
77

88
Amazon Nova API model provider for [Strands Agents SDK](https://github.com/strands-agents/sdk-python)

examples/basic_usage.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,48 @@
33

44
import asyncio
55
import os
6+
67
from dotenv import load_dotenv
8+
from strands import Agent
79

810
from strands_nova import NovaModel
9-
from strands import Agent
1011

1112

1213
async def main():
1314
"""Run basic example."""
1415
# Load environment variables
1516
load_dotenv()
16-
17+
1718
# Check for API key
1819
if not os.getenv("NOVA_API_KEY"):
1920
print("Error: NOVA_API_KEY not found in environment variables.")
2021
print("Please set: export NOVA_API_KEY='your-api-key'")
2122
print("Get your API key from: https://nova.amazon.com/apis")
2223
return
23-
24+
2425
print("=== Basic Nova API Example ===\n")
25-
26+
2627
# Initialize model
27-
model = NovaModel(
28-
model="nova-premier-v1",
29-
temperature=0.7,
30-
max_tokens=1024
31-
)
32-
28+
model = NovaModel(model="nova-premier-v1", temperature=0.7, max_tokens=1024)
29+
3330
# Create agent
3431
agent = Agent(model=model)
35-
32+
3633
# Simple conversation
3734
print("Question: What are the key benefits of Amazon's Nova models?")
3835
response = await agent.invoke_async("What are the key benefits of Amazon's Nova models?")
3936
print(f"Response: {response.message}\n")
40-
37+
4138
# Technical question
4239
print("Question: Explain how transformer architecture works in simple terms.")
4340
response = await agent.invoke_async("Explain how transformer architecture works in simple terms.")
4441
print(f"Response: {response.message}\n")
45-
42+
4643
# Example with Nova Pro model
4744
print("\n=== Using Nova Pro v3 ===\n")
48-
model_pro = NovaModel(
49-
model="Nova Pro v3 (6.x)",
50-
temperature=0.5,
51-
max_tokens=512
52-
)
45+
model_pro = NovaModel(model="Nova Pro v3 (6.x)", temperature=0.5, max_tokens=512)
5346
agent_pro = Agent(model=model_pro)
54-
47+
5548
print("Question: Write a Python function to calculate fibonacci numbers.")
5649
response = await agent_pro.invoke_async("Write a Python function to calculate fibonacci numbers.")
5750
print(f"Response: {response.message}\n")

examples/streaming_example.py

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import asyncio
55
import os
6+
67
from dotenv import load_dotenv
78

89
from strands_nova import NovaModel
@@ -11,48 +12,38 @@
1112
async def basic_streaming():
1213
"""Demonstrate basic streaming."""
1314
print("=== Basic Streaming Example ===\n")
14-
15-
model = NovaModel(
16-
model="nova-premier-v1",
17-
temperature=0.7,
18-
max_tokens=500
19-
)
20-
15+
16+
model = NovaModel(model="nova-premier-v1", temperature=0.7, max_tokens=500)
17+
2118
print("Question: Write a short story about a robot learning to paint.\n")
2219
print("Response: ", end="", flush=True)
23-
20+
2421
async for event in model.stream("Write a short story about a robot learning to paint."):
2522
if "contentBlockDelta" in event:
2623
delta = event["contentBlockDelta"]["delta"]
2724
if "text" in delta:
2825
print(delta["text"], end="", flush=True)
29-
26+
3027
print("\n")
3128

3229

3330
async def streaming_with_system_prompt():
3431
"""Demonstrate streaming with system prompt."""
3532
print("\n=== Streaming with System Prompt ===\n")
36-
37-
model = NovaModel(
38-
model="nova-premier-v1",
39-
temperature=0.3
40-
)
41-
33+
34+
model = NovaModel(model="nova-premier-v1", temperature=0.3)
35+
4236
system_prompt = "You are a helpful coding assistant. Provide concise, well-commented code examples."
43-
37+
4438
print("Question: Write a Python function to merge two sorted lists.\n")
4539
print("Response: ", end="", flush=True)
46-
47-
async for event in model.stream(
48-
"Write a Python function to merge two sorted lists.",
49-
system_prompt=system_prompt
50-
):
40+
41+
async for event in model.stream("Write a Python function to merge two sorted lists.", system_prompt=system_prompt):
5142
if "contentBlockDelta" in event:
5243
delta = event["contentBlockDelta"]["delta"]
5344
if "text" in delta:
5445
print(delta["text"], end="", flush=True)
55-
46+
5647
print("\n")
5748

5849

@@ -70,15 +61,13 @@ async def reasoning_model_example():
7061
model = NovaModel(
7162
model="nova-premier-v1", # Placeholder until reasoning model is available
7263
# reasoning_effort="medium", # Currently not supported, will raise error
73-
temperature=0.5
64+
temperature=0.5,
7465
)
7566

7667
print("Question: What is the sum of all prime numbers between 1 and 100?\n")
7768
print("Response: ", end="", flush=True)
7869

79-
async for event in model.stream(
80-
"What is the sum of all prime numbers between 1 and 100?"
81-
):
70+
async for event in model.stream("What is the sum of all prime numbers between 1 and 100?"):
8271
if "contentBlockDelta" in event:
8372
delta = event["contentBlockDelta"]["delta"]
8473
if "text" in delta:
@@ -90,50 +79,46 @@ async def reasoning_model_example():
9079
async def web_search_example():
9180
"""Demonstrate web search capabilities."""
9281
print("\n=== Web Search Example ===\n")
93-
94-
model = NovaModel(
95-
model="nova-premier-v1",
96-
web_search_options={"search_context_size": "low"}
97-
)
98-
82+
83+
model = NovaModel(model="nova-premier-v1", web_search_options={"search_context_size": "low"})
84+
9985
print("Question: What is the current Amazon stock price?\n")
10086
print("Response: ", end="", flush=True)
101-
87+
10288
async for event in model.stream(
103-
"What is the current Amazon stock price?",
104-
system_prompt="You are a helpful financial assistant."
89+
"What is the current Amazon stock price?", system_prompt="You are a helpful financial assistant."
10590
):
10691
if "contentBlockDelta" in event:
10792
delta = event["contentBlockDelta"]["delta"]
10893
if "text" in delta:
10994
print(delta["text"], end="", flush=True)
110-
95+
11196
print("\n")
11297

11398

11499
async def main():
115100
"""Run all streaming examples."""
116101
# Load environment variables
117102
load_dotenv()
118-
103+
119104
# Check for API key
120105
if not os.getenv("NOVA_API_KEY"):
121106
print("Error: NOVA_API_KEY not found in environment variables.")
122107
print("Please set: export NOVA_API_KEY='your-api-key'")
123108
print("Get your API key from: https://nova.amazon.com/apis")
124109
return
125-
110+
126111
# Run examples
127112
await basic_streaming()
128113
await streaming_with_system_prompt()
129-
114+
130115
# Optional: Run reasoning and web search examples
131116
# Note: These require specific model access
132117
try:
133118
await reasoning_model_example()
134119
except Exception as e:
135120
print(f"\nReasoning model example skipped: {e}\n")
136-
121+
137122
try:
138123
await web_search_example()
139124
except Exception as e:

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ classifiers = [
2222
"Programming Language :: Python :: 3.11",
2323
"Programming Language :: Python :: 3.12",
2424
"Programming Language :: Python :: 3.13",
25-
"Programming Language :: Python :: 3.14",
2625
"Topic :: Software Development :: Libraries :: Python Modules",
2726
"Topic :: Scientific/Engineering :: Artificial Intelligence",
2827
]
@@ -62,7 +61,7 @@ asyncio_default_fixture_loop_scope = "function"
6261

6362
[tool.black]
6463
line-length = 120
65-
target-version = ["py310", "py311", "py312", "py314"]
64+
target-version = ["py310", "py311", "py312", "py313"]
6665

6766
[tool.ruff]
6867
line-length = 120
@@ -72,7 +71,7 @@ select = ["E", "F", "I", "N", "W"]
7271
ignore = ["E501"]
7372

7473
[tool.mypy]
75-
python_version = "3.14"
74+
python_version = "3.13"
7675
warn_return_any = true
7776
warn_unused_configs = true
7877
ignore_missing_imports = true

0 commit comments

Comments
 (0)