File size: 1,778 Bytes
60e356c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
50
51
52
53
54
55
56
57
import os
from pathlib import Path
from dotenv import load_dotenv
from smolagents import LiteLLMModel, OpenAIServerModel
from agents.code_analyzer import CodeAnalyzerAgent
import json

# Load environment variables
load_dotenv()


def main():
    print("Hello from ada-assistant!")
    
    environment = os.getenv("ENVIRONMENT", "development")
    print(f"Running in {environment} mode")
    
    # Get model configuration from environment
    if environment == "production":
        model_id = os.getenv("PRODUCTION_MODEL_ID", "gpt-4o-mini")
        model = OpenAIServerModel(
            model_id=model_id,
            api_key=os.environ["OPENAI_API_KEY"]
        )
    else:
        model_id = os.getenv("DEVELOPMENT_MODEL_ID", "ollama/llama3.2")
        model = LiteLLMModel(model_id=model_id)
    
    print(f"Using model: {model_id}")
    
    # Initialize CodeAnalyzerAgent with model (it will create CodeAgent internally)
    analyzer = CodeAnalyzerAgent(model)
    
    print(f"CodeAnalyzerAgent initialized successfully with {len(analyzer.supported_extensions)} supported file types!")
    
    # Test extract_business_logic with tictactoe.ads file
    print("\n" + "="*50)
    print("Testing extract_business_logic with tictactoe.ads")
    print("="*50)
    
    tictactoe_file = Path(__file__).parent.parent / "tests" / "tictactoe.ads"
    
    if tictactoe_file.exists():
        print(f"Analyzing Ada file: {tictactoe_file}")
        
        print("\nExtracting business logic...")
        result = analyzer.extract_business_logic(tictactoe_file)
        
        print("\nBusiness Logic Analysis:")
        print(json.dumps(result, indent=2, default=str))
    else:
        print(f"Test file not found: {tictactoe_file}")


if __name__ == "__main__":
    main()