File size: 1,315 Bytes
124020a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3

import sys
import inspect

print("=== DSPy Interface Fix Verification ===")
print()

try:
    import dspy_optimizer

    # Check the LocalLM signature
    print("LocalLM.__call__ signature:")
    sig = inspect.signature(dspy_optimizer.LocalLM.__call__)
    print(sig)
    print()

    # Verify the method accepts messages parameter
    lm = dspy_optimizer.LocalLM()
    print("✓ LocalLM created successfully")

    # Check if we can call with messages parameter
    print("Testing interface compatibility...")

    # Test the signature compatibility
    import inspect
    params = sig.parameters

    has_messages = 'messages' in params
    has_prompt = 'prompt' in params

    print(f"✓ Has 'messages' parameter: {has_messages}")
    print(f"✓ Has 'prompt' parameter: {has_prompt}")

    if has_messages:
        messages_param = params['messages']
        print(f"✓ 'messages' parameter: {messages_param}")
        print(f"  - Default: {messages_param.default}")
        print(f"  - Kind: {messages_param.kind}")

    print()
    print("🎉 DSPy interface compatibility fix successful!")
    print("The LocalLM now accepts DSPy's calling pattern: lm(messages=inputs, **kwargs)")

except Exception as e:
    print(f"✗ Error: {e}")
    import traceback
    traceback.print_exc()