ada-assistant / src /main.py
syum-af's picture
downgraded to python 3.11
60e356c
Raw
History Blame Contribute Delete
1.78 kB
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()