Spaces:
Runtime error
Runtime error
Commit ·
0fbf65b
1
Parent(s): a5fa684
update Evaluate and prompting with schema from user
Browse files- service/evaluator_gemini.go +7 -18
service/evaluator_gemini.go
CHANGED
|
@@ -20,7 +20,7 @@ func NewGeminiEvaluator(cfg *model.ServiceConfig) *GeminiEvaluator {
|
|
| 20 |
return &GeminiEvaluator{config: cfg}
|
| 21 |
}
|
| 22 |
|
| 23 |
-
func (g *GeminiEvaluator) Evaluate(ctx context.Context, transcript string) (*model.CoreOutputFormat, error) {
|
| 24 |
prompt := fmt.Sprintf(`
|
| 25 |
You are a Data Extraction AI.
|
| 26 |
Your task is to extract structured data from the TRANSCRIPT based on the TARGET SCHEMA.
|
|
@@ -31,25 +31,14 @@ func (g *GeminiEvaluator) Evaluate(ctx context.Context, transcript string) (*mod
|
|
| 31 |
|
| 32 |
IMPORTANT: Your output must be a SINGLE JSON object with the EXACT structure below:
|
| 33 |
{
|
| 34 |
-
"parsed": {
|
| 35 |
-
|
| 36 |
-
"nim": "extracted string or null",
|
| 37 |
-
"gpa": number or 0
|
| 38 |
-
},
|
| 39 |
-
"status": {
|
| 40 |
-
"name": "filled" or "missing",
|
| 41 |
-
"nim": "filled" or "missing",
|
| 42 |
-
"gpa": "filled" or "missing"
|
| 43 |
-
},
|
| 44 |
"progress": 0.0 to 1.0,
|
| 45 |
-
"reason": {
|
| 46 |
-
|
| 47 |
-
},
|
| 48 |
-
"raw_transcript": "copy the transcript exactly here"
|
| 49 |
}
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
`, transcript, g.config.Schema)
|
| 53 |
|
| 54 |
req := model.GeminiRequest{
|
| 55 |
Contents: []model.Content{
|
|
|
|
| 20 |
return &GeminiEvaluator{config: cfg}
|
| 21 |
}
|
| 22 |
|
| 23 |
+
func (g *GeminiEvaluator) Evaluate(ctx context.Context, transcript string, schema map[string]interface{}) (*model.CoreOutputFormat, error) {
|
| 24 |
prompt := fmt.Sprintf(`
|
| 25 |
You are a Data Extraction AI.
|
| 26 |
Your task is to extract structured data from the TRANSCRIPT based on the TARGET SCHEMA.
|
|
|
|
| 31 |
|
| 32 |
IMPORTANT: Your output must be a SINGLE JSON object with the EXACT structure below:
|
| 33 |
{
|
| 34 |
+
"parsed": { ...fields matching schema... },
|
| 35 |
+
"status": { ...fields matching schema (filled/missing)... },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
"progress": 0.0 to 1.0,
|
| 37 |
+
"reason": { ...field_name: reason... },
|
| 38 |
+
"raw_transcript": "..."
|
|
|
|
|
|
|
| 39 |
}
|
| 40 |
+
Return ONLY valid JSON.
|
| 41 |
+
`, transcript, schema)
|
|
|
|
| 42 |
|
| 43 |
req := model.GeminiRequest{
|
| 44 |
Contents: []model.Content{
|