-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeepdrill.go
More file actions
42 lines (33 loc) · 1.04 KB
/
Copy pathdeepdrill.go
File metadata and controls
42 lines (33 loc) · 1.04 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
package deepdrill
import (
"context"
"fmt"
"github.com/mihonen/deepdrill/internal/engine"
)
// Alias types so the user stays in the 'deepdrill' namespace
type Field = engine.Field
type FieldType = engine.FieldType
type Schema = engine.Schema
type Options = engine.Options
const (
FieldTypeText = engine.FieldTypeText
FieldTypeLink = engine.FieldTypeLink
FieldTypeImage = engine.FieldTypeImage
FieldTypeValue = engine.FieldTypeValue
FieldTypeList = engine.FieldTypeList
FieldTypeCustom = engine.FieldTypeCustom
)
var defaultEngine *engine.Engine
func Init(provider string, model string, apiKey string) {
defaultEngine = engine.New(engine.Config{
Provider: provider,
APIKey: apiKey,
Model: model,
})
}
func Fill(ctx context.Context, schema Schema, opts Options) ([]map[string]any, error) {
if defaultEngine == nil {
return nil, fmt.Errorf("deepdrill not initialized: call Init() first")
}
return defaultEngine.Execute(ctx, schema, opts)
}