migrate-honcho

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Honcho Python SDK Migration (v1.6.0 → v2.0.0)

Honcho Python SDK 迁移指南(v1.6.0 → v2.0.0)

Overview

概述

This skill migrates code from
honcho
Python SDK v1.6.0 to v2.0.0 (required for Honcho 3.0.0+).
Key breaking changes:
  • AsyncHoncho
    /
    AsyncPeer
    /
    AsyncSession
    removed → use
    .aio
    accessor
  • "Observation" → "Conclusion" terminology
  • Representation
    class removed (returns
    str
    now)
  • get_config
    /
    set_config
    get_configuration
    /
    set_configuration
  • Streaming via
    chat_stream()
    instead of
    chat(stream=True)
  • poll_deriver_status()
    removed
  • .core
    property removed
本技能可将
honcho
Python SDK从v1.6.0版本迁移至v2.0.0版本(Honcho 3.0.0+版本要求使用该SDK版本)。
主要破坏性变更:
  • AsyncHoncho
    /
    AsyncPeer
    /
    AsyncSession
    已移除 → 使用
    .aio
    访问器
  • "Observation" 术语替换为 "Conclusion"
  • Representation
    类已移除(现在返回
    str
    类型)
  • get_config
    /
    set_config
    替换为
    get_configuration
    /
    set_configuration
  • 通过
    chat_stream()
    实现流式传输,替代
    chat(stream=True)
  • poll_deriver_status()
    已移除
  • .core
    属性已移除

Quick Migration

快速迁移步骤

1. Update async architecture

1. 更新异步架构

python
undefined
python
undefined

Before

旧代码

from honcho import AsyncHoncho, AsyncPeer, AsyncSession
async_client = AsyncHoncho() peer = await async_client.peer("user-123") response = await peer.chat("query")
from honcho import AsyncHoncho, AsyncPeer, AsyncSession
async_client = AsyncHoncho() peer = await async_client.peer("user-123") response = await peer.chat("query")

After

新代码

from honcho import Honcho
client = Honcho() peer = await client.aio.peer("user-123") response = await peer.aio.chat("query")
from honcho import Honcho
client = Honcho() peer = await client.aio.peer("user-123") response = await peer.aio.chat("query")

Async iteration

异步迭代

async for p in client.aio.peers(): print(p.id)
undefined
async for p in client.aio.peers(): print(p.id)
undefined

2. Replace observations with conclusions

2. 替换Observations为Conclusions

python
undefined
python
undefined

Before

旧代码

from honcho import Observation, ObservationScope, AsyncObservationScope
scope = peer.observations scope = peer.observations_of("other-peer") rep = scope.get_representation()
from honcho import Observation, ObservationScope, AsyncObservationScope
scope = peer.observations scope = peer.observations_of("other-peer") rep = scope.get_representation()

After

新代码

from honcho import Conclusion, ConclusionScope, ConclusionScopeAio
scope = peer.conclusions scope = peer.conclusions_of("other-peer") rep = scope.representation() # Returns str
undefined
from honcho import Conclusion, ConclusionScope, ConclusionScopeAio
scope = peer.conclusions scope = peer.conclusions_of("other-peer") rep = scope.representation() # 返回str类型
undefined

3. Update representation handling

3. 更新Representation处理逻辑

python
undefined
python
undefined

Before

旧代码

from honcho import Representation, ExplicitObservation, DeductiveObservation
rep: Representation = peer.working_rep() print(rep.explicit) print(rep.deductive) if rep.is_empty(): print("No observations")
from honcho import Representation, ExplicitObservation, DeductiveObservation
rep: Representation = peer.working_rep() print(rep.explicit) print(rep.deductive) if rep.is_empty(): print("无观测数据")

After

新代码

rep: str = peer.representation() print(rep) # Just a string now if not rep: print("No conclusions")
undefined
rep: str = peer.representation() print(rep) # 现在仅返回字符串 if not rep: print("无结论数据")
undefined

4. Rename configuration methods

4. 重命名配置方法

python
undefined
python
undefined

Before

旧代码

config = peer.get_config() peer.set_config({"observe_me": False}) session.get_config() client.get_config()
config = peer.get_config() peer.set_config({"observe_me": False}) session.get_config() client.get_config()

After

新代码

from honcho.api_types import PeerConfig, SessionConfiguration, WorkspaceConfiguration
config = peer.get_configuration() peer.set_configuration(PeerConfig(observe_me=False)) session.get_configuration() client.get_configuration()
undefined
from honcho.api_types import PeerConfig, SessionConfiguration, WorkspaceConfiguration
config = peer.get_configuration() peer.set_configuration(PeerConfig(observe_me=False)) session.get_configuration() client.get_configuration()
undefined

5. Update method names

5. 更新方法名称

python
undefined
python
undefined

Before

旧代码

peer.working_rep() peer.get_context() peer.get_sessions() session.get_context() session.get_summaries() session.get_messages() session.get_peers() session.get_peer_config() client.get_peers() client.get_sessions() client.get_workspaces()
peer.working_rep() peer.get_context() peer.get_sessions() session.get_context() session.get_summaries() session.get_messages() session.get_peers() session.get_peer_config() client.get_peers() client.get_sessions() client.get_workspaces()

After

新代码

peer.representation() peer.context() peer.sessions() session.context() session.summaries() session.messages() session.peers() session.get_peer_configuration() client.peers() client.sessions() client.workspaces()
undefined
peer.representation() peer.context() peer.sessions() session.context() session.summaries() session.messages() session.peers() session.get_peer_configuration() client.peers() client.sessions() client.workspaces()
undefined

6. Update streaming

6. 更新流式传输逻辑

python
undefined
python
undefined

Before

旧代码

response = peer.chat("query", stream=True) for chunk in response: print(chunk, end="")
response = peer.chat("query", stream=True) for chunk in response: print(chunk, end="")

After

新代码

stream = peer.chat_stream("query") for chunk in stream: print(chunk, end="")
undefined
stream = peer.chat_stream("query") for chunk in stream: print(chunk, end="")
undefined

7. Update queue status (formerly deriver)

7. 更新队列状态(原Deriver状态)

python
undefined
python
undefined

Before

旧代码

from honcho_core.types import DeriverStatus
status = client.get_deriver_status() status = client.poll_deriver_status(timeout=300.0) # Removed!
from honcho_core.types import DeriverStatus
status = client.get_deriver_status() status = client.poll_deriver_status(timeout=300.0) # 已移除!

After

新代码

from honcho.api_types import QueueStatusResponse
status = client.queue_status()
from honcho.api_types import QueueStatusResponse
status = client.queue_status()

poll_deriver_status removed - implement polling manually if needed

poll_deriver_status已移除 - 如需轮询请自行实现

undefined
undefined

8. Update representation parameters

8. 更新Representation参数

python
undefined
python
undefined

Before

旧代码

rep = peer.working_rep( include_most_derived=True, max_observations=50 )
rep = peer.working_rep( include_most_derived=True, max_observations=50 )

After

新代码

rep = peer.representation( include_most_frequent=True, max_conclusions=50 )
undefined
rep = peer.representation( include_most_frequent=True, max_conclusions=50 )
undefined

9. Move update_message to session

9. 将update_message方法迁移至Session

python
undefined
python
undefined

Before

旧代码

updated = client.update_message(message=msg, metadata={"key": "value"}, session="sess-id")
updated = client.update_message(message=msg, metadata={"key": "value"}, session="sess-id")

After

新代码

updated = session.update_message(message=msg, metadata={"key": "value"})
undefined
updated = session.update_message(message=msg, metadata={"key": "value"})
undefined

10. Update card() return type

10. 更新card()返回类型

python
undefined
python
undefined

Before

旧代码

card: str = peer.card() # Returns str
card: str = peer.card() # 返回str类型

After

新代码

card: list[str] | None = peer.card() # Returns list[str] | None if card: print("\n".join(card))
undefined
card: list[str] | None = peer.card() # 返回list[str] | None类型 if card: print("\n".join(card))
undefined

Quick Reference Table

快速参考对照表

v1.6.0v2.0.0
AsyncHoncho()
Honcho()
+
.aio
accessor
AsyncPeer
Peer
+
.aio
accessor
AsyncSession
Session
+
.aio
accessor
Observation
Conclusion
ObservationScope
ConclusionScope
AsyncObservationScope
ConclusionScopeAio
Representation
str
.observations
.conclusions
.observations_of()
.conclusions_of()
.get_config()
.get_configuration()
.set_config()
.set_configuration()
.working_rep()
.representation()
.get_context()
.context()
.get_sessions()
.sessions()
.get_peers()
.peers()
.get_messages()
.messages()
.get_summaries()
.summaries()
.get_deriver_status()
.queue_status()
.poll_deriver_status()
(removed)
.get_peer_config()
.get_peer_configuration()
.set_peer_config()
.set_peer_configuration()
client.update_message()
session.update_message()
chat(stream=True)
chat_stream()
include_most_derived=
include_most_frequent=
max_observations=
max_conclusions=
last_user_message=
search_query=
config=
configuration=
PeerContext
PeerContextResponse
DeriverStatus
QueueStatusResponse
client.core
(removed)
v1.6.0v2.0.0
AsyncHoncho()
Honcho()
+
.aio
访问器
AsyncPeer
Peer
+
.aio
访问器
AsyncSession
Session
+
.aio
访问器
Observation
Conclusion
ObservationScope
ConclusionScope
AsyncObservationScope
ConclusionScopeAio
Representation
str
.observations
.conclusions
.observations_of()
.conclusions_of()
.get_config()
.get_configuration()
.set_config()
.set_configuration()
.working_rep()
.representation()
.get_context()
.context()
.get_sessions()
.sessions()
.get_peers()
.peers()
.get_messages()
.messages()
.get_summaries()
.summaries()
.get_deriver_status()
.queue_status()
.poll_deriver_status()
(已移除)
.get_peer_config()
.get_peer_configuration()
.set_peer_config()
.set_peer_configuration()
client.update_message()
session.update_message()
chat(stream=True)
chat_stream()
include_most_derived=
include_most_frequent=
max_observations=
max_conclusions=
last_user_message=
search_query=
config=
configuration=
PeerContext
PeerContextResponse
DeriverStatus
QueueStatusResponse
client.core
(已移除)

Detailed Reference

详细参考

For comprehensive details on each change, see:
  • DETAILED-CHANGES.md - Full API change documentation
  • MIGRATION-CHECKLIST.md - Step-by-step checklist
如需了解每个变更的完整细节,请查看:
  • DETAILED-CHANGES.md - 完整API变更文档
  • MIGRATION-CHECKLIST.md - 分步迁移清单

New Exception Types

新异常类型

python
from honcho import (
    HonchoError,
    APIError,
    BadRequestError,
    AuthenticationError,
    PermissionDeniedError,
    NotFoundError,
    ConflictError,
    UnprocessableEntityError,
    RateLimitError,
    ServerError,
    TimeoutError,
    ConnectionError,
)
python
from honcho import (
    HonchoError,
    APIError,
    BadRequestError,
    AuthenticationError,
    PermissionDeniedError,
    NotFoundError,
    ConflictError,
    UnprocessableEntityError,
    RateLimitError,
    ServerError,
    TimeoutError,
    ConnectionError,
)

New Import Locations

新导入路径

python
undefined
python
undefined

Configuration types

配置类型

from honcho.api_types import ( PeerConfig, SessionConfiguration, WorkspaceConfiguration, SessionPeerConfig, QueueStatusResponse, PeerContextResponse, )
from honcho.api_types import ( PeerConfig, SessionConfiguration, WorkspaceConfiguration, SessionPeerConfig, QueueStatusResponse, PeerContextResponse, )

Async type hints

异步类型提示

from honcho import HonchoAio, PeerAio, SessionAio
from honcho import HonchoAio, PeerAio, SessionAio

Message types (note: Params is plural now)

消息类型(注意:Params现在为复数形式)

from honcho import Message, MessageCreateParams
undefined
from honcho import Message, MessageCreateParams
undefined