Morph
MorphTools provides advanced code editing capabilities using Morph's Fast Apply API for intelligent code modifications.
Example
The following agent can perform intelligent code editing using Morph:
1from kern.agent import Agent2from kern.tools.models.morph import MorphTools34agent = Agent(5 instructions=[6 "You are a code editing assistant using Morph's advanced AI capabilities",7 "Help users modify, improve, and refactor their code intelligently",8 "Apply code changes efficiently while maintaining code quality",9 "Provide explanations for the modifications made",10 ],11 tools=[MorphTools()],12)1314agent.print_response("Refactor this Python function to be more efficient and add type hints", stream=True)Toolkit Params
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | Optional[str] | None | Morph API key. Uses MORPH_API_KEY if not set. |
base_url | str | "https://api.morphllm.com/v1" | Morph API base URL. |
model | str | "morph-v3-large" | Morph model to use for code editing. |
instructions | Optional[str] | None | Custom instructions for code editing behavior. |
add_instructions | bool | True | Whether to add instructions to the agent. |
Toolkit Functions
| Function | Description |
|---|---|
edit_file | Apply intelligent code modifications using Morph's Fast Apply API. |