Quick Start
Basic Usage
import asyncio
from knowai_sse import Expander
from knowai_sse.models import PlanetContext
async def main():
expander = Expander(
api_key="your-deepseek-api-key",
base_url="https://api.deepseek.com"
)
context = PlanetContext(
theme="Embodied Intelligence",
values_map={"radical": 0.8, "ethics": 0.2}
)
result = await expander.expand(context)
for instruction in result.instructions:
print(f"[{instruction.channel}] {instruction.query}")
await expander.close()
asyncio.run(main())
Using Different Values
context = PlanetContext(
theme="Machine Learning",
values_map={
"academic": 0.7,
"practical": 0.3
}
)
Processing Results
result = await expander.expand(context)
for instruction in result.instructions:
print(f"Channel: {instruction.channel}")
print(f"Query: {instruction.query}")
print(f"Time Range: {instruction.time_range}")
print("---")
Error Handling
from knowai_sse.exceptions import LLMParseError, LLMTimeoutError
try:
result = await expander.expand(context)
except LLMParseError as e:
print(f"Parse error: {e}")
except LLMTimeoutError as e:
print(f"Request timeout: {e}")