CLOVA Studio model provider for Strands Agents SDK
Project description
strands-clova
CLOVA Studio model provider for Strands Agents SDK
๐ Features
- ๐ฐ๐ท Native Korean Language Support - Optimized for Korean context and nuances
- ๐ Bilingual Capabilities - Seamlessly handle both Korean and English
- ๐ Full Streaming Support - Real-time response streaming with SSE
- ๐ Simple Authentication - Just needs CLOVA_API_KEY
- โก Easy Integration - Drop-in replacement for any Strands model provider
- ๐ฆ Type Safe - Full type hints and mypy support
๐ Requirements
- Python 3.10+
- Strands Agents SDK 1.7.0+
- CLOVA Studio API key from Naver Cloud Platform
๐ Installation
pip install strands-agents strands-clova
๐ฏ Quick Start
Basic Usage
from strands_clova import ClovaModel
from strands import Agent
# Initialize CLOVA model
model = ClovaModel(
api_key="your-clova-api-key", # or set CLOVA_API_KEY env var
model="HCX-005",
temperature=0.7,
max_tokens=2048
)
# Create an agent
agent = Agent(model=model)
# Use the agent
response = await agent.invoke_async("์๋
ํ์ธ์! ์ค๋ ๋ ์จ๊ฐ ์ด๋ค๊ฐ์?")
print(response.message)
Streaming Responses
import asyncio
from strands_clova import ClovaModel
async def stream_example():
model = ClovaModel(api_key="your-api-key")
async for event in model.stream("ํ๊ตญ์ ์ ํต ์์ 3๊ฐ์ง๋ฅผ ์๊ฐํด์ฃผ์ธ์"):
if event.get("type") == "text":
print(event["text"], end="", flush=True)
asyncio.run(stream_example())
With System Prompt
model = ClovaModel(api_key="your-api-key")
async for event in model.stream(
"Python ๋ฆฌ์คํธ ์ปดํ๋ฆฌํจ์
์ ์ค๋ช
ํด์ฃผ์ธ์",
system_prompt="You are a helpful coding assistant. Provide concise answers."
):
# Process streaming events
pass
โ๏ธ Configuration
Environment Variables
export CLOVA_API_KEY="your-api-key"
export CLOVA_REQUEST_ID="optional-request-id" # For request tracking
Model Parameters
model = ClovaModel(
model="HCX-005", # Model ID (currently only HCX-005 is supported)
temperature=0.7, # Sampling temperature (0.0-1.0)
max_tokens=4096, # Maximum tokens to generate
top_p=0.8, # Nucleus sampling parameter
top_k=0, # Top-k sampling parameter
repeat_penalty=1.1, # Repetition penalty
stop=["\\n\\n"], # Stop sequences
)
Dynamic Configuration
# Update configuration at runtime
model.update_config(
temperature=0.2,
max_tokens=1024
)
# Get current configuration
config = model.get_config()
print(config)
๐งช Examples
Korean Customer Support Bot
from strands_clova import ClovaModel
from strands import Agent
model = ClovaModel(api_key="your-api-key", temperature=0.3)
agent = Agent(
model=model,
system_prompt="๋น์ ์ ์น์ ํ ๊ณ ๊ฐ ์๋น์ค ์๋ด์์
๋๋ค."
)
response = await agent.invoke_async(
"์ ํ ๋ฐํ ์ ์ฐจ๋ฅผ ์๋ ค์ฃผ์ธ์"
)
Bilingual Document Processing
# Process Korean document and get English summary
response = await agent.invoke_async(
"๋ค์ ํ๊ตญ์ด ๋ฌธ์๋ฅผ ์์ด๋ก ์์ฝํด์ฃผ์ธ์: [๋ฌธ์ ๋ด์ฉ]"
)
Creative Content Generation
model = ClovaModel(temperature=0.9, max_tokens=2048)
agent = Agent(model=model)
response = await agent.invoke_async(
"AI๊ฐ ๊ต์ก์ ๋ฏธ์น๋ ์ํฅ์ ๋ํ ๋ธ๋ก๊ทธ ํฌ์คํธ๋ฅผ ์์ฑํด์ฃผ์ธ์"
)
๐งช Testing
Run Unit Tests
pip install -e ".[dev]"
pytest tests/unit/ -v
Run Integration Tests
Requires CLOVA_API_KEY environment variable:
export CLOVA_API_KEY="your-api-key"
pytest tests/integration/ -v
๐ API Reference
ClovaModel
Main model class that implements the Strands Model abstract base class.
Methods
stream(messages, tool_specs, system_prompt, **kwargs)- Stream responsesget_config()- Get current configurationupdate_config(**kwargs)- Update configurationstructured_output()- Not yet implemented (raises NotImplementedError)
ClovaModelException
Exception raised for CLOVA-specific errors.
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Links
๐ Acknowledgments
- Thanks to the Strands Agents team for creating an excellent SDK
- Thanks to Naver for providing CLOVA Studio API
๐ Status
- โ Basic streaming support
- โ Korean and English language support
- โ System prompts
- โ Configuration management
- โณ Structured output support (coming soon)
- โณ Tool/Function calling (coming soon)
Made with โค๏ธ for the Korean AI community
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file strands_clova-0.1.1.tar.gz.
File metadata
- Download URL: strands_clova-0.1.1.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3a3206d0fe039d7090565f78f289eac82ca08c6dd16a769ab772e6f57ac3f17
|
|
| MD5 |
f52f71d49f02e47e7bc129344ab6e79f
|
|
| BLAKE2b-256 |
6e642238a686f5aa14a9903c5d7db0a961d5cfe0c28106ad71adcd445820f34e
|
File details
Details for the file strands_clova-0.1.1-py3-none-any.whl.
File metadata
- Download URL: strands_clova-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b306c9e1aff43014ffbf6c410fce0a29916a91a906ab6113b07bea44ebab006
|
|
| MD5 |
4e46376b16b1a619eb5d7a815d49a3bb
|
|
| BLAKE2b-256 |
a82e25e239a4304295308ae56128343cc4763b27c373ee4306c896d636306073
|