parishad 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- parishad/__init__.py +70 -0
- parishad/__main__.py +10 -0
- parishad/checker/__init__.py +25 -0
- parishad/checker/deterministic.py +644 -0
- parishad/checker/ensemble.py +496 -0
- parishad/checker/retrieval.py +546 -0
- parishad/cli/__init__.py +6 -0
- parishad/cli/code.py +3254 -0
- parishad/cli/main.py +1158 -0
- parishad/cli/prarambh.py +99 -0
- parishad/cli/sthapana.py +368 -0
- parishad/config/modes.py +139 -0
- parishad/config/pipeline.core.yaml +128 -0
- parishad/config/pipeline.extended.yaml +172 -0
- parishad/config/pipeline.fast.yaml +89 -0
- parishad/config/user_config.py +115 -0
- parishad/data/catalog.py +118 -0
- parishad/data/models.json +108 -0
- parishad/memory/__init__.py +79 -0
- parishad/models/__init__.py +181 -0
- parishad/models/backends/__init__.py +247 -0
- parishad/models/backends/base.py +211 -0
- parishad/models/backends/huggingface.py +318 -0
- parishad/models/backends/llama_cpp.py +239 -0
- parishad/models/backends/mlx_lm.py +141 -0
- parishad/models/backends/ollama.py +253 -0
- parishad/models/backends/openai_api.py +193 -0
- parishad/models/backends/transformers_hf.py +198 -0
- parishad/models/costs.py +385 -0
- parishad/models/downloader.py +1557 -0
- parishad/models/optimizations.py +871 -0
- parishad/models/profiles.py +610 -0
- parishad/models/reliability.py +876 -0
- parishad/models/runner.py +651 -0
- parishad/models/tokenization.py +287 -0
- parishad/orchestrator/__init__.py +24 -0
- parishad/orchestrator/config_loader.py +210 -0
- parishad/orchestrator/engine.py +1113 -0
- parishad/orchestrator/exceptions.py +14 -0
- parishad/roles/__init__.py +71 -0
- parishad/roles/base.py +712 -0
- parishad/roles/dandadhyaksha.py +163 -0
- parishad/roles/darbari.py +246 -0
- parishad/roles/majumdar.py +274 -0
- parishad/roles/pantapradhan.py +150 -0
- parishad/roles/prerak.py +357 -0
- parishad/roles/raja.py +345 -0
- parishad/roles/sacheev.py +203 -0
- parishad/roles/sainik.py +427 -0
- parishad/roles/sar_senapati.py +164 -0
- parishad/roles/vidushak.py +69 -0
- parishad/tools/__init__.py +7 -0
- parishad/tools/base.py +57 -0
- parishad/tools/fs.py +110 -0
- parishad/tools/perception.py +96 -0
- parishad/tools/retrieval.py +74 -0
- parishad/tools/shell.py +103 -0
- parishad/utils/__init__.py +7 -0
- parishad/utils/hardware.py +122 -0
- parishad/utils/logging.py +79 -0
- parishad/utils/scanner.py +164 -0
- parishad/utils/text.py +61 -0
- parishad/utils/tracing.py +133 -0
- parishad-0.1.0.dist-info/METADATA +256 -0
- parishad-0.1.0.dist-info/RECORD +68 -0
- parishad-0.1.0.dist-info/WHEEL +4 -0
- parishad-0.1.0.dist-info/entry_points.txt +2 -0
- parishad-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Parishad-Core Pipeline Configuration
|
|
2
|
+
# 8 roles: Madhya Sabha (Balanced Council)
|
|
3
|
+
# Uses 2 model slots: mid + big
|
|
4
|
+
|
|
5
|
+
name: "parishad-core"
|
|
6
|
+
version: "0.1.0"
|
|
7
|
+
description: "Balanced 8-role pipeline: Madhya Sabha with extended council"
|
|
8
|
+
|
|
9
|
+
# Role definitions
|
|
10
|
+
roles:
|
|
11
|
+
darbari:
|
|
12
|
+
name: "darbari"
|
|
13
|
+
class: "Darbari"
|
|
14
|
+
description: "Analyzer: Deeply analyzes query"
|
|
15
|
+
slot: "mid"
|
|
16
|
+
max_tokens: 1000
|
|
17
|
+
temperature: 0.3
|
|
18
|
+
output_schema: "task_spec"
|
|
19
|
+
|
|
20
|
+
majumdar:
|
|
21
|
+
name: "majumdar"
|
|
22
|
+
class: "Majumdar"
|
|
23
|
+
description: "Planner: Creates detailed plan"
|
|
24
|
+
slot: "mid"
|
|
25
|
+
max_tokens: 1200
|
|
26
|
+
temperature: 0.5
|
|
27
|
+
output_schema: "plan"
|
|
28
|
+
|
|
29
|
+
sar_senapati:
|
|
30
|
+
name: "sar_senapati"
|
|
31
|
+
class: "SarSenapati"
|
|
32
|
+
description: "Coordinator: Orchestrates execution strategy"
|
|
33
|
+
slot: "mid"
|
|
34
|
+
max_tokens: 1000
|
|
35
|
+
temperature: 0.4
|
|
36
|
+
output_schema: "execution_strategy"
|
|
37
|
+
|
|
38
|
+
sainik:
|
|
39
|
+
name: "sainik"
|
|
40
|
+
class: "Sainik"
|
|
41
|
+
description: "Implementor: Executes plan"
|
|
42
|
+
slot: "big"
|
|
43
|
+
max_tokens: 2500
|
|
44
|
+
temperature: 0.6
|
|
45
|
+
output_schema: "candidate"
|
|
46
|
+
|
|
47
|
+
prerak:
|
|
48
|
+
name: "prerak"
|
|
49
|
+
class: "Prerak"
|
|
50
|
+
description: "Checker: Validates correctness"
|
|
51
|
+
slot: "mid"
|
|
52
|
+
max_tokens: 1200
|
|
53
|
+
temperature: 0.3
|
|
54
|
+
output_schema: "verdict"
|
|
55
|
+
|
|
56
|
+
sacheev:
|
|
57
|
+
name: "sacheev"
|
|
58
|
+
class: "Sacheev"
|
|
59
|
+
description: "Secretary: Documents and summarizes"
|
|
60
|
+
slot: "mid"
|
|
61
|
+
max_tokens: 800
|
|
62
|
+
temperature: 0.3
|
|
63
|
+
output_schema: "summary"
|
|
64
|
+
|
|
65
|
+
dandadhyaksha:
|
|
66
|
+
name: "dandadhyaksha"
|
|
67
|
+
class: "Dandadhyaksha"
|
|
68
|
+
description: "Magistrate: Enforces quality standards"
|
|
69
|
+
slot: "mid"
|
|
70
|
+
max_tokens: 1000
|
|
71
|
+
temperature: 0.3
|
|
72
|
+
output_schema: "enforcement"
|
|
73
|
+
|
|
74
|
+
raja:
|
|
75
|
+
name: "raja"
|
|
76
|
+
class: "Raja"
|
|
77
|
+
description: "Judge: Final answer & formatting"
|
|
78
|
+
slot: "big"
|
|
79
|
+
max_tokens: 1500
|
|
80
|
+
temperature: 0.3
|
|
81
|
+
output_schema: "final_answer"
|
|
82
|
+
|
|
83
|
+
# Pipeline execution order (8 roles)
|
|
84
|
+
pipeline:
|
|
85
|
+
- darbari
|
|
86
|
+
- majumdar
|
|
87
|
+
- sar_senapati
|
|
88
|
+
- sainik
|
|
89
|
+
- prerak
|
|
90
|
+
- sacheev
|
|
91
|
+
- dandadhyaksha
|
|
92
|
+
- raja
|
|
93
|
+
|
|
94
|
+
# Data flow between roles
|
|
95
|
+
data_flow:
|
|
96
|
+
darbari:
|
|
97
|
+
inputs: ["user_query"]
|
|
98
|
+
outputs: ["task_spec"]
|
|
99
|
+
majumdar:
|
|
100
|
+
inputs: ["user_query", "task_spec"]
|
|
101
|
+
outputs: ["plan"]
|
|
102
|
+
sar_senapati:
|
|
103
|
+
inputs: ["user_query", "task_spec", "plan"]
|
|
104
|
+
outputs: ["execution_strategy"]
|
|
105
|
+
sainik:
|
|
106
|
+
inputs: ["user_query", "task_spec", "plan", "execution_strategy"]
|
|
107
|
+
outputs: ["candidate"]
|
|
108
|
+
prerak:
|
|
109
|
+
inputs: ["user_query", "candidate", "plan"]
|
|
110
|
+
outputs: ["verdict"]
|
|
111
|
+
sacheev:
|
|
112
|
+
inputs: ["user_query", "candidate", "verdict"]
|
|
113
|
+
outputs: ["summary"]
|
|
114
|
+
dandadhyaksha:
|
|
115
|
+
inputs: ["user_query", "candidate", "verdict", "summary"]
|
|
116
|
+
outputs: ["enforcement"]
|
|
117
|
+
raja:
|
|
118
|
+
inputs: ["user_query", "candidate", "verdict", "summary", "enforcement"]
|
|
119
|
+
outputs: ["final_answer"]
|
|
120
|
+
|
|
121
|
+
# Pipeline-specific settings
|
|
122
|
+
settings:
|
|
123
|
+
allow_retry: true
|
|
124
|
+
strict_validation: true
|
|
125
|
+
enable_checker: true
|
|
126
|
+
enable_planner: true
|
|
127
|
+
truncation_policy: "moderate"
|
|
128
|
+
max_total_tokens: 10000
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Parishad-Extended Pipeline Configuration
|
|
2
|
+
# 10 roles: Maha Sabha (Full 10-Unique-Role Council)
|
|
3
|
+
# Uses 3 model slots: small + mid + big
|
|
4
|
+
|
|
5
|
+
name: "parishad-extended"
|
|
6
|
+
version: "0.1.0"
|
|
7
|
+
description: "Maha Sabha: Full 10-role council including Lateral Thinker (Vidushak)"
|
|
8
|
+
|
|
9
|
+
# Role definitions
|
|
10
|
+
roles:
|
|
11
|
+
pantapradhan:
|
|
12
|
+
name: "pantapradhan"
|
|
13
|
+
class: "Pantapradhan"
|
|
14
|
+
description: "Prime Minister: Meta-planning and strategic oversight"
|
|
15
|
+
slot: "big"
|
|
16
|
+
max_tokens: 1500
|
|
17
|
+
temperature: 0.4
|
|
18
|
+
output_schema: "meta_plan"
|
|
19
|
+
|
|
20
|
+
darbari:
|
|
21
|
+
name: "darbari"
|
|
22
|
+
class: "Darbari"
|
|
23
|
+
description: "Analyzer: Deep analysis of query"
|
|
24
|
+
slot: "mid"
|
|
25
|
+
max_tokens: 1200
|
|
26
|
+
temperature: 0.3
|
|
27
|
+
output_schema: "task_spec"
|
|
28
|
+
|
|
29
|
+
majumdar:
|
|
30
|
+
name: "majumdar"
|
|
31
|
+
class: "Majumdar"
|
|
32
|
+
description: "Planner: Creates detailed execution plan"
|
|
33
|
+
slot: "mid"
|
|
34
|
+
max_tokens: 1400
|
|
35
|
+
temperature: 0.5
|
|
36
|
+
output_schema: "plan"
|
|
37
|
+
|
|
38
|
+
sar_senapati:
|
|
39
|
+
name: "sar_senapati"
|
|
40
|
+
class: "SarSenapati"
|
|
41
|
+
description: "Coordinator: Execution strategy"
|
|
42
|
+
slot: "mid"
|
|
43
|
+
max_tokens: 1000
|
|
44
|
+
temperature: 0.4
|
|
45
|
+
output_schema: "execution_strategy"
|
|
46
|
+
|
|
47
|
+
vidushak:
|
|
48
|
+
name: "vidushak"
|
|
49
|
+
class: "Vidushak"
|
|
50
|
+
description: "Lateral Thinker: Challenges plan with creative alternatives"
|
|
51
|
+
slot: "mid"
|
|
52
|
+
max_tokens: 1000
|
|
53
|
+
temperature: 0.8
|
|
54
|
+
output_schema: "creative_challenge"
|
|
55
|
+
|
|
56
|
+
sainik:
|
|
57
|
+
name: "sainik"
|
|
58
|
+
class: "Sainik"
|
|
59
|
+
description: "Implementor: Executes optimized plan"
|
|
60
|
+
slot: "big"
|
|
61
|
+
max_tokens: 2500
|
|
62
|
+
temperature: 0.6
|
|
63
|
+
output_schema: "candidate"
|
|
64
|
+
|
|
65
|
+
prerak:
|
|
66
|
+
name: "prerak"
|
|
67
|
+
class: "Prerak"
|
|
68
|
+
description: "Checker: Detailed validation"
|
|
69
|
+
slot: "mid"
|
|
70
|
+
max_tokens: 1200
|
|
71
|
+
temperature: 0.3
|
|
72
|
+
output_schema: "verdict"
|
|
73
|
+
|
|
74
|
+
sacheev:
|
|
75
|
+
name: "sacheev"
|
|
76
|
+
class: "Sacheev"
|
|
77
|
+
description: "Secretary: Documents and summarizes"
|
|
78
|
+
slot: "small"
|
|
79
|
+
max_tokens: 800
|
|
80
|
+
temperature: 0.3
|
|
81
|
+
output_schema: "summary"
|
|
82
|
+
|
|
83
|
+
dandadhyaksha:
|
|
84
|
+
name: "dandadhyaksha"
|
|
85
|
+
class: "Dandadhyaksha"
|
|
86
|
+
description: "Magistrate: Enforces quality"
|
|
87
|
+
slot: "mid"
|
|
88
|
+
max_tokens: 1000
|
|
89
|
+
temperature: 0.3
|
|
90
|
+
output_schema: "enforcement"
|
|
91
|
+
|
|
92
|
+
raja:
|
|
93
|
+
name: "raja"
|
|
94
|
+
class: "Raja"
|
|
95
|
+
description: "Judge: Final answer & formatting"
|
|
96
|
+
slot: "big"
|
|
97
|
+
max_tokens: 1800
|
|
98
|
+
temperature: 0.3
|
|
99
|
+
output_schema: "final_answer"
|
|
100
|
+
|
|
101
|
+
# Pipeline execution order (10 UNIQUE roles)
|
|
102
|
+
pipeline:
|
|
103
|
+
- pantapradhan
|
|
104
|
+
- darbari
|
|
105
|
+
- majumdar
|
|
106
|
+
- sar_senapati
|
|
107
|
+
- vidushak
|
|
108
|
+
- sainik
|
|
109
|
+
- prerak
|
|
110
|
+
- sacheev
|
|
111
|
+
- dandadhyaksha
|
|
112
|
+
- raja
|
|
113
|
+
|
|
114
|
+
# Data flow between roles
|
|
115
|
+
data_flow:
|
|
116
|
+
pantapradhan:
|
|
117
|
+
inputs: ["user_query"]
|
|
118
|
+
outputs: ["meta_plan"]
|
|
119
|
+
darbari:
|
|
120
|
+
inputs: ["user_query", "meta_plan"]
|
|
121
|
+
outputs: ["task_spec"]
|
|
122
|
+
majumdar:
|
|
123
|
+
inputs: ["user_query", "meta_plan", "task_spec"]
|
|
124
|
+
outputs: ["plan"]
|
|
125
|
+
sar_senapati:
|
|
126
|
+
inputs: ["user_query", "task_spec", "plan"]
|
|
127
|
+
outputs: ["execution_strategy"]
|
|
128
|
+
vidushak:
|
|
129
|
+
inputs: ["user_query", "plan"]
|
|
130
|
+
outputs: ["creative_challenge"]
|
|
131
|
+
sainik:
|
|
132
|
+
inputs: ["user_query", "task_spec", "plan", "execution_strategy", "creative_challenge"]
|
|
133
|
+
outputs: ["candidate"]
|
|
134
|
+
prerak:
|
|
135
|
+
inputs: ["user_query", "candidate", "plan"]
|
|
136
|
+
outputs: ["verdict"]
|
|
137
|
+
sacheev:
|
|
138
|
+
inputs: ["user_query", "candidate", "verdict"]
|
|
139
|
+
outputs: ["summary"]
|
|
140
|
+
dandadhyaksha:
|
|
141
|
+
inputs: ["user_query", "candidate", "verdict", "summary"]
|
|
142
|
+
outputs: ["enforcement"]
|
|
143
|
+
raja:
|
|
144
|
+
inputs: ["user_query", "candidate", "verdict", "summary", "enforcement"]
|
|
145
|
+
outputs: ["final_answer"]
|
|
146
|
+
|
|
147
|
+
# Pipeline-specific settings
|
|
148
|
+
settings:
|
|
149
|
+
allow_retry: true
|
|
150
|
+
strict_validation: true
|
|
151
|
+
enable_checker: true
|
|
152
|
+
enable_planner: true
|
|
153
|
+
truncation_policy: "conservative"
|
|
154
|
+
max_total_tokens: 15000
|
|
155
|
+
|
|
156
|
+
# Budget policies
|
|
157
|
+
budget:
|
|
158
|
+
max_tokens_per_query: 15000
|
|
159
|
+
|
|
160
|
+
# Per-role token allocations
|
|
161
|
+
role_budgets:
|
|
162
|
+
pantapradhan: 1500
|
|
163
|
+
darbari: 1200
|
|
164
|
+
majumdar: 1400
|
|
165
|
+
sar_senapati: 1000
|
|
166
|
+
vidushak: 1000
|
|
167
|
+
sainik: 2500
|
|
168
|
+
prerak: 1200
|
|
169
|
+
sacheev: 800
|
|
170
|
+
dandadhyaksha: 1000
|
|
171
|
+
raja: 1800
|
|
172
|
+
reserve: 100
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Parishad-Fast Pipeline Configuration
|
|
2
|
+
# 5 roles: Full Council (Small/Faster Models)
|
|
3
|
+
# Laghu Sabha matches standard structure but uses smaller/faster models
|
|
4
|
+
|
|
5
|
+
name: "parishad-fast"
|
|
6
|
+
version: "0.1.0"
|
|
7
|
+
description: "Fast 5-role pipeline: Analyze -> Plan -> Execute -> Check -> Judge"
|
|
8
|
+
|
|
9
|
+
# Role definitions
|
|
10
|
+
roles:
|
|
11
|
+
darbari:
|
|
12
|
+
name: "darbari"
|
|
13
|
+
class: "Darbari"
|
|
14
|
+
description: "Analyzer: Identifies requirements"
|
|
15
|
+
slot: "small"
|
|
16
|
+
max_tokens: 800
|
|
17
|
+
temperature: 0.3
|
|
18
|
+
output_schema: "task_spec"
|
|
19
|
+
|
|
20
|
+
majumdar:
|
|
21
|
+
name: "majumdar"
|
|
22
|
+
class: "Majumdar"
|
|
23
|
+
description: "Planner: Creates simple plan"
|
|
24
|
+
slot: "mid"
|
|
25
|
+
max_tokens: 1000
|
|
26
|
+
temperature: 0.5
|
|
27
|
+
output_schema: "plan"
|
|
28
|
+
|
|
29
|
+
sainik:
|
|
30
|
+
name: "sainik"
|
|
31
|
+
class: "Sainik"
|
|
32
|
+
description: "Implementor: Executes plan"
|
|
33
|
+
slot: "mid"
|
|
34
|
+
max_tokens: 1500
|
|
35
|
+
temperature: 0.6
|
|
36
|
+
output_schema: "candidate"
|
|
37
|
+
|
|
38
|
+
prerak:
|
|
39
|
+
name: "prerak"
|
|
40
|
+
class: "Prerak"
|
|
41
|
+
description: "Checker: Validates output"
|
|
42
|
+
slot: "small"
|
|
43
|
+
max_tokens: 800
|
|
44
|
+
temperature: 0.3
|
|
45
|
+
output_schema: "verdict"
|
|
46
|
+
|
|
47
|
+
raja:
|
|
48
|
+
name: "raja"
|
|
49
|
+
class: "Raja"
|
|
50
|
+
description: "Judge: Formats final answer"
|
|
51
|
+
slot: "small"
|
|
52
|
+
max_tokens: 1000
|
|
53
|
+
temperature: 0.3
|
|
54
|
+
output_schema: "final_answer"
|
|
55
|
+
|
|
56
|
+
# Execution order
|
|
57
|
+
pipeline:
|
|
58
|
+
- darbari
|
|
59
|
+
- majumdar
|
|
60
|
+
- sainik
|
|
61
|
+
- prerak
|
|
62
|
+
- raja
|
|
63
|
+
|
|
64
|
+
# Data flow between roles
|
|
65
|
+
data_flow:
|
|
66
|
+
darbari:
|
|
67
|
+
inputs: ["user_query"]
|
|
68
|
+
outputs: ["task_spec"]
|
|
69
|
+
majumdar:
|
|
70
|
+
inputs: ["user_query", "task_spec"]
|
|
71
|
+
outputs: ["plan"]
|
|
72
|
+
sainik:
|
|
73
|
+
inputs: ["user_query", "task_spec", "plan"]
|
|
74
|
+
outputs: ["candidate"]
|
|
75
|
+
prerak:
|
|
76
|
+
inputs: ["user_query", "candidate", "plan"]
|
|
77
|
+
outputs: ["verdict"]
|
|
78
|
+
raja:
|
|
79
|
+
inputs: ["user_query", "candidate", "verdict", "plan"]
|
|
80
|
+
outputs: ["final_answer"]
|
|
81
|
+
|
|
82
|
+
# Pipeline-specific settings
|
|
83
|
+
settings:
|
|
84
|
+
allow_retry: true
|
|
85
|
+
strict_validation: false
|
|
86
|
+
enable_checker: true
|
|
87
|
+
enable_planner: true
|
|
88
|
+
truncation_policy: "aggressive"
|
|
89
|
+
max_total_tokens: 4000
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""
|
|
2
|
+
User-level configuration management for Parishad.
|
|
3
|
+
|
|
4
|
+
Handles user preferences stored in ~/.parishad/config.yaml:
|
|
5
|
+
- default_profile: Which model profile to use by default
|
|
6
|
+
- default_mode: Which execution mode to use by default
|
|
7
|
+
- model_dir: Where models are stored
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import logging
|
|
13
|
+
from dataclasses import dataclass
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
from typing import Optional
|
|
16
|
+
|
|
17
|
+
import yaml
|
|
18
|
+
|
|
19
|
+
logger = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class UserConfig:
|
|
24
|
+
"""User configuration settings."""
|
|
25
|
+
default_profile: str
|
|
26
|
+
default_mode: str
|
|
27
|
+
model_dir: str
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def get_user_config_dir() -> Path:
|
|
31
|
+
"""
|
|
32
|
+
Return ~/.parishad directory (cross-platform via Path.home()).
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
Path to user config directory
|
|
36
|
+
"""
|
|
37
|
+
return Path.home() / ".parishad"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def get_user_config_path() -> Path:
|
|
41
|
+
"""
|
|
42
|
+
Return path to ~/.parishad/config.yaml.
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
Path to user config file
|
|
46
|
+
"""
|
|
47
|
+
return get_user_config_dir() / "config.yaml"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def load_user_config() -> UserConfig:
|
|
51
|
+
"""
|
|
52
|
+
Load user config if present, else return sensible defaults.
|
|
53
|
+
|
|
54
|
+
Defaults:
|
|
55
|
+
default_profile: "local_gpu"
|
|
56
|
+
default_mode: "balanced"
|
|
57
|
+
model_dir: "~/.parishad/models"
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
UserConfig with settings
|
|
61
|
+
"""
|
|
62
|
+
path = get_user_config_path()
|
|
63
|
+
|
|
64
|
+
if not path.exists():
|
|
65
|
+
# Return default config
|
|
66
|
+
logger.debug("No user config found, using defaults")
|
|
67
|
+
return UserConfig(
|
|
68
|
+
default_profile="local_gpu",
|
|
69
|
+
default_mode="balanced",
|
|
70
|
+
model_dir=str(get_user_config_dir() / "models"),
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
try:
|
|
74
|
+
data = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
|
|
75
|
+
|
|
76
|
+
config = UserConfig(
|
|
77
|
+
default_profile=data.get("default_profile", "local_gpu"),
|
|
78
|
+
default_mode=data.get("default_mode", "balanced"),
|
|
79
|
+
model_dir=data.get("model_dir", str(get_user_config_dir() / "models")),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
logger.debug(f"Loaded user config: profile={config.default_profile}, mode={config.default_mode}")
|
|
83
|
+
return config
|
|
84
|
+
|
|
85
|
+
except Exception as e:
|
|
86
|
+
logger.warning(f"Failed to load user config: {e}, using defaults")
|
|
87
|
+
return UserConfig(
|
|
88
|
+
default_profile="local_gpu",
|
|
89
|
+
default_mode="balanced",
|
|
90
|
+
model_dir=str(get_user_config_dir() / "models"),
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def save_user_config(cfg: UserConfig) -> None:
|
|
95
|
+
"""
|
|
96
|
+
Save user config to ~/.parishad/config.yaml (create dir if needed).
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
cfg: UserConfig to save
|
|
100
|
+
"""
|
|
101
|
+
cfg_dir = get_user_config_dir()
|
|
102
|
+
cfg_dir.mkdir(parents=True, exist_ok=True)
|
|
103
|
+
|
|
104
|
+
data = {
|
|
105
|
+
"default_profile": cfg.default_profile,
|
|
106
|
+
"default_mode": cfg.default_mode,
|
|
107
|
+
"model_dir": cfg.model_dir,
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
get_user_config_path().write_text(
|
|
111
|
+
yaml.safe_dump(data, sort_keys=False),
|
|
112
|
+
encoding="utf-8"
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
logger.info(f"Saved user config: profile={cfg.default_profile}, mode={cfg.default_mode}")
|
parishad/data/catalog.py
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Model Catalog for Parishad Marketplace.
|
|
3
|
+
Defines recommended models and sabha configurations.
|
|
4
|
+
"""
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
from typing import Literal, List, Dict
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class ModelEntry:
|
|
10
|
+
"""A recommended model."""
|
|
11
|
+
name: str # Display name
|
|
12
|
+
backend: Literal["llama_cpp", "ollama", "lm_studio"] # Defaulting to GGUF-compatible backends
|
|
13
|
+
model_id: str # The ID used by the backend or the lookup key
|
|
14
|
+
min_ram_gb: int
|
|
15
|
+
description: str
|
|
16
|
+
hw_tags: List[str] = field(default_factory=list) # e.g. ["cpu", "cuda", "mlx", "metal"]
|
|
17
|
+
download_info: Dict[str, str] = field(default_factory=dict) # Hints for downloader: repo_id, filename
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class SabhaConfig:
|
|
21
|
+
"""Configuration for a Sabha tier."""
|
|
22
|
+
name: str
|
|
23
|
+
roles: List[str]
|
|
24
|
+
description: str
|
|
25
|
+
min_tokens_req: int
|
|
26
|
+
|
|
27
|
+
# --- SABHA DEFINITIONS ---
|
|
28
|
+
SABHAS = {
|
|
29
|
+
"laghu": SabhaConfig(
|
|
30
|
+
name="Laghu Sabha",
|
|
31
|
+
description="A concise council of 5 core roles. Fast and efficient.",
|
|
32
|
+
roles=["raja", "dandadhyaksha", "sacheev", "prerak", "sainik"],
|
|
33
|
+
min_tokens_req=4096
|
|
34
|
+
),
|
|
35
|
+
"mantri": SabhaConfig(
|
|
36
|
+
name="Mantri Parishad",
|
|
37
|
+
description="Expanded council with 8 roles for better planning.",
|
|
38
|
+
roles=[
|
|
39
|
+
"raja", "dandadhyaksha", "sacheev", "prerak", "majumdar",
|
|
40
|
+
"pantapradhan", "darbari", "sainik"
|
|
41
|
+
],
|
|
42
|
+
min_tokens_req=8192
|
|
43
|
+
),
|
|
44
|
+
"maha": SabhaConfig(
|
|
45
|
+
name="Maha Sabha",
|
|
46
|
+
description="The full royal court of 10 roles for maximum capability.",
|
|
47
|
+
roles=[
|
|
48
|
+
"raja", "dandadhyaksha", "sacheev", "prerak", "majumdar",
|
|
49
|
+
"pantapradhan", "darbari", "sar_senapati", "guptachar", "sainik"
|
|
50
|
+
],
|
|
51
|
+
min_tokens_req=16384
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
# --- MODEL RECOMMENDATIONS ---
|
|
56
|
+
|
|
57
|
+
# Note: We prioritize GGUF (llama_cpp) for local ease (no gated repos, lower VRAM reqs).
|
|
58
|
+
# 'model_id' here acts as the 'spec' for ModelManager.download()
|
|
59
|
+
|
|
60
|
+
MODELS = {
|
|
61
|
+
"entry": [
|
|
62
|
+
ModelEntry(
|
|
63
|
+
name="Qwen 2.5 (0.5B)", backend="llama_cpp", model_id="qwen2.5:0.5b",
|
|
64
|
+
min_ram_gb=2, description="Ultra-lightweight. Good for basic testing.",
|
|
65
|
+
hw_tags=["cpu", "cuda", "mlx"]
|
|
66
|
+
),
|
|
67
|
+
ModelEntry(
|
|
68
|
+
name="Llama 3.2 (1B)", backend="llama_cpp", model_id="llama3.2:1b",
|
|
69
|
+
min_ram_gb=4, description="Meta's smallest instruction model.",
|
|
70
|
+
hw_tags=["cpu", "cuda", "mlx"]
|
|
71
|
+
),
|
|
72
|
+
ModelEntry(
|
|
73
|
+
name="Phi-3.5 Mini (3.8B)", backend="llama_cpp", model_id="phi3:mini", # Using phi3:mini as close approx or update downloader
|
|
74
|
+
min_ram_gb=8, description="High capability for size. Strong reasoning.",
|
|
75
|
+
hw_tags=["cpu", "cuda", "mlx"],
|
|
76
|
+
download_info={"repo": "microsoft/Phi-3-mini-4k-instruct-gguf", "file": "Phi-3-mini-4k-instruct-q4.gguf"}
|
|
77
|
+
),
|
|
78
|
+
ModelEntry(
|
|
79
|
+
name="Gemma 2 (2B)", backend="llama_cpp", model_id="gemma2:2b",
|
|
80
|
+
min_ram_gb=6, description="Google's lightweight efficient model.",
|
|
81
|
+
hw_tags=["cpu", "cuda", "mlx"]
|
|
82
|
+
),
|
|
83
|
+
ModelEntry(
|
|
84
|
+
name="Qwen 2.5 (1.5B)", backend="llama_cpp", model_id="qwen2.5:1.5b",
|
|
85
|
+
min_ram_gb=4, description="Balanced small model.",
|
|
86
|
+
hw_tags=["cpu", "cuda", "mlx"]
|
|
87
|
+
),
|
|
88
|
+
],
|
|
89
|
+
"mid": [
|
|
90
|
+
ModelEntry(
|
|
91
|
+
name="Qwen 2.5 (7B)", backend="llama_cpp", model_id="qwen2.5:7b",
|
|
92
|
+
min_ram_gb=16, description="Excellent all-rounder. Best in class 7B.",
|
|
93
|
+
hw_tags=["cuda", "mlx"]
|
|
94
|
+
),
|
|
95
|
+
ModelEntry(
|
|
96
|
+
name="Llama 3.1 (8B)", backend="llama_cpp", model_id="llama3.1:8b",
|
|
97
|
+
min_ram_gb=16, description="Meta's state-of-the-art 8B model.",
|
|
98
|
+
hw_tags=["cuda", "metal"]
|
|
99
|
+
),
|
|
100
|
+
ModelEntry(
|
|
101
|
+
name="Mistral 7B (v0.3)", backend="llama_cpp", model_id="mistral:7b",
|
|
102
|
+
min_ram_gb=16, description="Reliable workhorse from Mistral AI.",
|
|
103
|
+
hw_tags=["cuda", "mlx"]
|
|
104
|
+
),
|
|
105
|
+
],
|
|
106
|
+
"high": [
|
|
107
|
+
ModelEntry(
|
|
108
|
+
name="Qwen 2.5 (14B)", backend="llama_cpp", model_id="Qwen/Qwen2.5-14B-Instruct-GGUF/qwen2.5-14b-instruct-q4_k_m.gguf",
|
|
109
|
+
min_ram_gb=28, description="Heavyweight reasoning. Great for coding.",
|
|
110
|
+
hw_tags=["cuda", "mlx"]
|
|
111
|
+
),
|
|
112
|
+
ModelEntry(
|
|
113
|
+
name="Mixtral 8x7B", backend="llama_cpp", model_id="TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF/mixtral-8x7b-instruct-v0.1.Q4_K_M.gguf",
|
|
114
|
+
min_ram_gb=26, description="Top-tier sparse MoE. Very fast.",
|
|
115
|
+
hw_tags=["cuda", "metal"]
|
|
116
|
+
),
|
|
117
|
+
]
|
|
118
|
+
}
|