2.9 KiB
2.9 KiB
Implementation Plan: Zhipu AI (GLM) Provider Integration
Phase 1: Core Client Implementation
- Task: Define Zhipu AI state and initialize client in
src/ai_client.py.- Import
zhipuai(ensure it's added torequirements.txtif missing). - Add
_zhipu_clientand_zhipu_historymodule-level variables. - Implement
_classify_zhipu_error(exc)for structured error mapping.
- Import
- Task: Implement
_send_zhiputool-call loop.- Implement function/tool definition conversion to Zhipu format.
- Implement the core chat completion API call with streaming support.
- Implement tool result packaging and the recursion loop (up to
MAX_TOOL_ROUNDS). - Integrate
_reread_file_itemsfor context refresh after tool rounds.
- Task: Implement Multi-modal (Vision) support.
- Add logic to
_send_zhiputo processscreenshotinputs forglm-4vby encoding them as base64.
- Add logic to
- Task: Implement model discovery.
- Implement
_list_zhipu_models()using the Zhipu AI models list API.
- Implement
- Task: Update
ai_client.pyutility functions.- Update
send()dispatcher to route to_send_zhipu. - Update
reset_session()to clear_zhipu_history.
- Update
- Task: Conductor - User Manual Verification 'Phase 1: Core Client Implementation' (Protocol in workflow.md)
Phase 2: Configuration & Credentials
- Task: Update credential loading in
src/ai_client.py.- Update
_load_credentials()to includez_aiin the error message and loading logic.
- Update
- Task: Add cost tracking for Zhipu models in
src/cost_tracker.py.- Add regex patterns and rates for
glm-4andglm-4-flashtoMODEL_PRICING.
- Add regex patterns and rates for
- Task: Verify that
credentials.tomlworks with the new provider section. - Task: Conductor - User Manual Verification 'Phase 2: Configuration & Credentials' (Protocol in workflow.md)
Phase 3: GUI & Controller Integration
- Task: Register
z_aias a provider.- Add
z_aitoPROVIDERSinsrc/gui_2.py. - Add
z_aitoPROVIDERSinsrc/app_controller.py.
- Add
- Task: Ensure model fetching works in the GUI.
- Verify that clicking "Fetch Models" in the AI Settings panel correctly populates Zhipu models when the provider is selected.
- Task: Conductor - User Manual Verification 'Phase 3: GUI & Controller Integration' (Protocol in workflow.md)
Phase 4: MMA Integration & Final Verification
- Task: Verify MMA compatibility.
- Test a simple multi-agent workflow where a Tier 3 worker is configured to use
glm-4-flash. - Verify that tool calls, history, and context injection work as expected within the tiered architecture.
- Test a simple multi-agent workflow where a Tier 3 worker is configured to use
- Task: Run full regression suite.
- Ensure adding Zhipu hasn't introduced side effects for existing providers.
- Task: Conductor - User Manual Verification 'Phase 4: MMA Integration & Final Verification' (Protocol in workflow.md)