Fix config override bug by recreating LMs after load_state
This commit is contained in:
16
nanocode.py
16
nanocode.py
@@ -4,6 +4,7 @@ from modaic import PrecompiledProgram, PrecompiledConfig
|
||||
import dspy
|
||||
import re
|
||||
import subprocess
|
||||
from dspy.utils.callback import BaseCallback
|
||||
|
||||
# --- Modaic ---
|
||||
|
||||
@@ -23,6 +24,7 @@ MAGENTA = "\033[35m"
|
||||
|
||||
# --- File operations ---
|
||||
|
||||
|
||||
def read_file(path: str, offset: int = 0, limit: int = None) -> str:
|
||||
"""Read file contents with line numbers.
|
||||
|
||||
@@ -163,8 +165,15 @@ def run_bash(cmd: str) -> str:
|
||||
return "".join(output_lines).strip() or "(empty output)"
|
||||
|
||||
|
||||
class RLMReasoningCallback(BaseCallback):
|
||||
def on_module_end(self, call_id, outputs, exception):
|
||||
if outputs and hasattr(outputs, "reasoning") and hasattr(outputs, "code"):
|
||||
print(f"\n[REASONING STEP] reasoning: {outputs.reasoning}\n")
|
||||
|
||||
|
||||
# -- Program ---
|
||||
|
||||
|
||||
class CodingAssistant(dspy.Signature):
|
||||
"""You are a concise coding assistant with access to sub agents."""
|
||||
|
||||
@@ -286,6 +295,11 @@ class RLMCodingProgram(PrecompiledProgram):
|
||||
# recreate LMs from config (not from saved state)
|
||||
self.reload_lms()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
agent = RLMCodingProgram(RLMCodingConfig())
|
||||
agent.push_to_hub(MODAIC_REPO_PATH, commit_message="Fix config override bug by recreating LMs after load_state", branch="prod")
|
||||
agent.push_to_hub(
|
||||
MODAIC_REPO_PATH,
|
||||
commit_message="Fix config override bug by recreating LMs after load_state",
|
||||
branch="prod"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user