NeonBohdan commited on
Commit
c5b0047
1 Parent(s): 56b174a

Added ModelConfig

Browse files
Files changed (1) hide show
  1. shared.py +33 -0
shared.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import yaml
2
+
3
+ from typing import Dict
4
+ from pydantic import BaseModel, ValidationError
5
+
6
+
7
+
8
+ class PileConfig(BaseModel):
9
+ file2persona: Dict[str, str]
10
+ file2prefix: Dict[str, str]
11
+ persona2system: Dict[str, str]
12
+ prompt: str
13
+
14
+ class InferenceConfig(BaseModel):
15
+ chat_template: str
16
+
17
+ class RepoConfig(BaseModel):
18
+ name: str
19
+ tag: str
20
+
21
+ class ModelConfig(BaseModel):
22
+ pile: PileConfig
23
+ inference: InferenceConfig
24
+ repo: RepoConfig
25
+
26
+ @classmethod
27
+ def from_yaml(cls, yaml_file = "datasets/config.yaml"):
28
+ with open(yaml_file, 'r') as file:
29
+ data = yaml.safe_load(file)
30
+ try:
31
+ return cls(**data)
32
+ except ValidationError as e:
33
+ raise e