-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdocument_example_test.go
More file actions
94 lines (83 loc) · 2.55 KB
/
document_example_test.go
File metadata and controls
94 lines (83 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package gemara
import (
"fmt"
"os"
"text/template"
"github.com/gemaraproj/go-gemara/internal/codec"
)
// Adapted from: https://github.com/finos/ai-governance-framework/blob/main/docs/_mitigations/mi-11_human-feedback-loop-for-ai-systems.md
func ExampleGuidanceCatalog() {
tmpl := `# {{ .Title }} ({{ .Metadata.Id }})
---
**Front Matter:** {{ .FrontMatter }}
---
{{- $doc := . }}{{ range .Groups }}
### {{ .Title }} ({{ .Id }})
{{ .Description }}
#### Guidelines:
{{- $familyId := .Id }}{{ range $doc.Guidelines }}{{ if eq .Group $familyId }}
##### {{ .Title }} ({{ .Id }})
**Objective:** {{ .Objective }}
{{- if .SeeAlso }}
**See Also:** {{ range $index, $item := .SeeAlso }}{{ if $index }} {{ end }}{{ $item }}{{ end }}
{{- end }}
{{- end }}{{ end -}}
{{ end }}`
l1Docs, err := goodAIGFExample()
if err != nil {
fmt.Printf("error getting testdata: %v\n", err)
return
}
t, err := template.New("guidance").Parse(tmpl)
if err != nil {
fmt.Printf("error parsing template: %v\n", err)
return
}
err = t.Execute(os.Stdout, l1Docs)
if err != nil {
fmt.Printf("error executing template: %v\n", err)
}
// Output:
//# AI Governance Framework (FINOS-AIR)
//---
//**Front Matter:** The following framework has been developed by FINOS (Fintech Open Source Foundation).
//---
//
//### Detective (DET)
//Detection and Continuous Improvement
//#### Guidelines:
//
//##### Human Feedback Loop for AI Systems (AIR-DET-011)
//**Objective:** A Human Feedback Loop is a critical detective and continuous improvement mechanism that involves systematically collecting, analyzing, and acting upon feedback provided by human users, subject matter experts (SMEs), or reviewers regarding an AI system's performance, outputs, or behavior.
//
//**See Also:** AIR-DET-015 AIR-DET-004 AIR-PREV-005
//
//
//##### Example Detective Control 004 (AIR-DET-004)
//**Objective:** Placeholder control for testing references.
//
//
//##### Example Detective Control 015 (AIR-DET-015)
//**Objective:** Placeholder control for testing references.
//
//
//
//### Preventive (PREV)
//Prevention and Risk Mitigation
//#### Guidelines:
//
//##### Example Preventive Control 005 (AIR-PREV-005)
//**Objective:** Placeholder control for testing references.
}
func goodAIGFExample() (GuidanceCatalog, error) {
testdataPath := "./test-data/good-aigf.yaml"
data, err := os.ReadFile(testdataPath)
if err != nil {
return GuidanceCatalog{}, err
}
var l1Docs GuidanceCatalog
if err := codec.UnmarshalYAML(data, &l1Docs); err != nil {
return GuidanceCatalog{}, err
}
return l1Docs, nil
}