| import argparse |
| import sys |
| import json |
| from .model_manager import OVModelManager |
|
|
| def main(): |
| parser = argparse.ArgumentParser(description="OpenVinayaka: Hallucination-Free AI Runner") |
| parser.add_argument("command", choices=["run", "serve"], help="Command to execute") |
| parser.add_argument("--model", type=str, default="gpt2", help="HuggingFace model ID (e.g., meta-llama/Llama-2-7b)") |
| parser.add_argument("--memory", type=str, help="Path to JSON memory file (Truth Source)") |
| |
| args = parser.parse_args() |
| |
| if args.command == "run": |
| print(f"π OpenVinayaka CLI v1.0") |
| print(f" Model: {args.model}") |
| |
| |
| manager = OVModelManager(args.model) |
| manager.attach_ov_hooks() |
| |
| |
| memory_data = None |
| if args.memory: |
| try: |
| with open(args.memory, "r") as f: |
| memory_data = json.load(f) |
| print(f"π Memory Loaded: {len(memory_data)} facts.") |
| except Exception as e: |
| print(f"β οΈ Could not load memory: {e}") |
| |
| print("\n㪠Ready! Type your query (or 'exit'):") |
| while True: |
| try: |
| user_input = input("> ") |
| if user_input.lower() in ["exit", "quit"]: |
| break |
| |
| |
| relevant_memory = None |
| if memory_data: |
| |
| |
| relevant_memory = memory_data[0] |
| |
| response = manager.generate(user_input, relevant_memory) |
| print(f"\nπ€ {response}\n") |
| |
| except KeyboardInterrupt: |
| break |
| |
| elif args.command == "serve": |
| print("π API Server starting on port 8000... (Not implemented in demo)") |
|
|
| if __name__ == "__main__": |
| main() |
|
|