Skip to main content

CLOVA Studio model provider for Strands Agents SDK

Project description

strands-clova

PyPI version Python Support Tests 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)

ClovaModelError

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 - Complete
  • Korean and English language support - Complete
  • System prompts - Complete
  • Configuration management - Complete
  • Structured output support - In Progress
  • Tool/Function calling - In Progress

Made 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.2.tar.gz (12.4 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.2-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: strands_clova-0.1.2.tar.gz
  • Upload date:
  • Size: 12.4 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.2.tar.gz
Algorithm Hash digest
SHA256 0a1f5c9fc1051888793de162b8c258e3e2a67939422e3fcacc4627587072fb19
MD5 ebd8daceaa88f476cb16764dd555dd7f
BLAKE2b-256 fa374b4463f529963d6204272b5247f302f4b9a851d67e713ccd3622fedc9c69

See more details on using hashes here.

File details

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

File metadata

  • Download URL: strands_clova-0.1.2-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

Hashes for strands_clova-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7e934b84340d701b5beec499752605b6fb86e62e125f6afe21e99f20c6d08b0b
MD5 ef29f7d611250b52d7ee0957349eb690
BLAKE2b-256 92ae80bf7683103bfd1136ffe23afc864f404cbc676b5ceeadcacfb05b5cdcca

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