Skip to content

Commit

Permalink
feat: use combinator
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinZonda committed May 4, 2023
1 parent 83633ff commit 30486a0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
13 changes: 13 additions & 0 deletions prompt/deprecated.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package prompt

// ParseFile @deprecated
// Deprecated: FunctionName is deprecated. Use ParsePromptC instead.
func ParseFile(content string) *PromptC {
return ParsePromptC(content)
}

// ParseUnstructuredFile @deprecated
// Deprecated: FunctionName is deprecated. Use ParseBasicPrompt instead.
func ParseUnstructuredFile(content string) *PromptC {
return ParseBasicPrompt(content)
}
11 changes: 6 additions & 5 deletions prompt/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ func ParseBasicPrompt(content string) *PromptC {
VarConstraint: make(map[string]interfaces.Variable),
Vars: make(map[string]string),
Prompts: []string{content},
Conf: &Conf{
Model: "gpt-3.5-turbo",
Provider: "openai",
SharedInfo: SharedInfo{
Conf: &Conf{
Model: "gpt-3.5-turbo",
Provider: "openai",
},
},
}

Expand Down Expand Up @@ -152,9 +154,8 @@ func (f *PromptC) Compile(vars map[string]string) *CompiledPromptC {
}
compiled:
return &CompiledPromptC{
SharedInfo: f.SharedInfo,
Fatal: fileFatal,
Info: f.FileInfo,
Conf: f.Conf,
Prompts: result,
CompiledVars: compiledVars,
Exceptions: errs,
Expand Down
11 changes: 7 additions & 4 deletions prompt/fileModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ type FileInfo struct {
}

type PromptC struct {
FileInfo
Conf *Conf `json:"conf,omitempty"`
SharedInfo
Vars map[string]string `json:"vars"`
Prompts []string `json:"prompts"`
VarConstraint map[string]interfaces.Variable `json:"-"`
Expand All @@ -45,6 +44,11 @@ func (f *PromptC) GetConf() Conf {
return *f.Conf
}

type SharedInfo struct {
FileInfo
Conf *Conf `json:"conf,omitempty"`
}

var reserved = []string{"conf", "prompts", "vars", "author", "license", "project", "version"}

type CompiledPrompt struct {
Expand All @@ -53,9 +57,8 @@ type CompiledPrompt struct {
}

type CompiledPromptC struct {
SharedInfo
Fatal bool
Info FileInfo
Conf *Conf
Prompts []CompiledPrompt
CompiledVars map[string]string
Exceptions []error
Expand Down

0 comments on commit 30486a0

Please sign in to comment.