Using SkillAgent (Recommended)
```python
import asyncio
from openskills import create_agent
async def main():
# Create agent with infographic-skills
agent = await create_agent(
skill_paths=["./infographic-skills"],
api_key="your-api-key",
model="gpt-4",
)
# Chat with automatic skill invocation
response = await agent.chat("ๅธฎๆๆป็ปไผ่ฎฎ")
print(response.content)
print(f"Used skill: {response.skill_used}")
asyncio.run(main())
```
Using Sandbox Mode (Recommended for Script Execution)
```python
import asyncio
from openskills import create_agent
async def main():
# Create agent with sandbox enabled
agent = await create_agent(
skill_paths=["./skills"],
api_key="your-api-key",
model="gpt-4",
use_sandbox=True, # Enable sandbox execution
sandbox_base_url="http://localhost:8080",
auto_execute_scripts=True,
)
# Local file paths are automatically uploaded to sandbox
response = await agent.chat("่ฏทๅค็่ฟไธชๆไปถ: /path/to/file.pdf")
print(response.content)
# Output files are automatically downloaded to skill_dir/output/
asyncio.run(main())
```
Using SkillManager (Low-level API)
```python
from pathlib import Path
from openskills import SkillManager
manager = SkillManager([Path("./infographic-skills")])
# Discover infographic-skills (Layer 1 - Metadata)
await manager.discover()
# Match user query
skills = manager.match("summarize meeting")
# Load instruction (Layer 2)
if skills:
instruction = await manager.load_instruction(skills[0].name)
print(instruction.content)
```