Turojin commited on
Commit
79f8a03
·
verified ·
1 Parent(s): 5042164

Upload jarvis/config.py

Browse files
Files changed (1) hide show
  1. jarvis/config.py +101 -0
jarvis/config.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Configuration management for J.A.R.V.I.S."""
2
+ import os
3
+ import json
4
+ import yaml
5
+ from pathlib import Path
6
+ from dataclasses import dataclass, field, asdict
7
+ from typing import Optional, List, Dict, Any
8
+
9
+
10
+ @dataclass
11
+ class LLMConfig:
12
+ provider: str = "ollama" # ollama, openai, anthropic
13
+ model: str = "llama3.1"
14
+ base_url: Optional[str] = "http://localhost:11434/v1"
15
+ api_key: Optional[str] = None
16
+ temperature: float = 0.7
17
+ max_tokens: int = 4096
18
+
19
+
20
+ @dataclass
21
+ class MemoryConfig:
22
+ chroma_path: str = "./data/chroma"
23
+ sqlite_path: str = "./data/jarvis.db"
24
+ embedding_model: str = "all-MiniLM-L6-v2"
25
+ max_context_turns: int = 10
26
+ use_chroma: bool = True
27
+
28
+
29
+ @dataclass
30
+ class PersonaConfig:
31
+ name: str = "J.A.R.V.I.S."
32
+ user_name: str = "Alvin"
33
+ base_persona: str = (
34
+ "You are J.A.R.V.I.S., a personal AI assistant. "
35
+ "You speak with dry wit, understated sarcasm, and absolute loyalty to Alvin. "
36
+ "You never flatter unnecessarily. You occasionally use humor to defuse tension. "
37
+ "You are proactive about open projects but never interrupt during VENTING. "
38
+ "You self-score your responses and will re-run reasoning if quality is low."
39
+ )
40
+ archetypes: Dict[str, str] = field(default_factory=lambda: {
41
+ "Strategist": "Focus on planning, trade-offs, and long-term consequences.",
42
+ "Philosopher": "Focus on meaning, ethics, and first principles.",
43
+ "Companion": "Focus on emotional support, presence, and care.",
44
+ "Engineer": "Focus on systems, implementation details, and pragmatism.",
45
+ "Skeptic": "Focus on challenging assumptions, risks, and edge cases.",
46
+ })
47
+
48
+
49
+ @dataclass
50
+ class PipelineConfig:
51
+ enable_self_scoring: bool = False # MVP: disabled
52
+ enable_mirror_check: bool = False # MVP: disabled
53
+ enable_anchor_gate: bool = False # MVP: disabled
54
+ enable_proactive_loops: bool = False # MVP: disabled
55
+ council_agents: List[str] = field(default_factory=lambda: ["Athena", "Janus", "Anubis"])
56
+ dial_default: int = 5
57
+ mirror_check_interval: int = 5
58
+
59
+
60
+ @dataclass
61
+ class Config:
62
+ llm: LLMConfig = field(default_factory=LLMConfig)
63
+ memory: MemoryConfig = field(default_factory=MemoryConfig)
64
+ persona: PersonaConfig = field(default_factory=PersonaConfig)
65
+ pipeline: PipelineConfig = field(default_factory=PipelineConfig)
66
+ data_dir: str = "./data"
67
+ log_level: str = "INFO"
68
+
69
+ @classmethod
70
+ def from_file(cls, path: str) -> "Config":
71
+ path = Path(path)
72
+ if not path.exists():
73
+ return cls()
74
+ with open(path, "r") as f:
75
+ if path.suffix in (".yaml", ".yml"):
76
+ raw = yaml.safe_load(f)
77
+ else:
78
+ raw = json.load(f)
79
+ return cls(**raw)
80
+
81
+ @classmethod
82
+ def from_env(cls) -> "Config":
83
+ cfg = cls()
84
+ if os.getenv("JARVIS_LLM_PROVIDER"):
85
+ cfg.llm.provider = os.getenv("JARVIS_LLM_PROVIDER")
86
+ if os.getenv("JARVIS_LLM_MODEL"):
87
+ cfg.llm.model = os.getenv("JARVIS_LLM_MODEL")
88
+ if os.getenv("JARVIS_LLM_API_KEY"):
89
+ cfg.llm.api_key = os.getenv("JARVIS_LLM_API_KEY")
90
+ if os.getenv("JARVIS_LLM_BASE_URL"):
91
+ cfg.llm.base_url = os.getenv("JARVIS_LLM_BASE_URL")
92
+ return cfg
93
+
94
+ def to_file(self, path: str):
95
+ path = Path(path)
96
+ path.parent.mkdir(parents=True, exist_ok=True)
97
+ with open(path, "w") as f:
98
+ if path.suffix in (".yaml", ".yml"):
99
+ yaml.dump(asdict(self), f, default_flow_style=False)
100
+ else:
101
+ json.dump(asdict(self), f, indent=2)