Skip to main content

CLOVA Studio model provider for Strands Agents SDK

Project description

strands-clova

PyPI version Python Support License: MIT

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

๐Ÿš€ 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 responses
  • get_config() - Get current configuration
  • update_config(**kwargs) - Update configuration
  • structured_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.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strands_clova-0.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strands_clova-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file strands_clova-0.1.0.tar.gz.

File metadata

  • Download URL: strands_clova-0.1.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for strands_clova-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0f9b671835aec5b17c60e1cbc9b798fbd5dfc880ce623e59751a49b09623ab8f
MD5 bc2b248a7d565971e7114304015c5fe6
BLAKE2b-256 5c86eb48f59a064503600951030c50c43a20a98a0f960d3889fbe096712efdb7

See more details on using hashes here.

File details

Details for the file strands_clova-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: strands_clova-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for strands_clova-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8df0a0c6591266fd69f99a2da62eebf9bf04be36484f6e682bcb73bae5d2e92d
MD5 5062e6a98509c054979a798b0d72ce3c
BLAKE2b-256 1cfb5a94257d85160f470e325b166d50ec6bd2ce72330d6faf8b05e64674463c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page