Skip to content

Commit

Permalink
Fix in go package
Browse files Browse the repository at this point in the history
  • Loading branch information
synw committed Jan 16, 2025
1 parent d05add0 commit 05d6a88
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion codegen/golang/gen.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package golang

func Gen(content string) string {
codeStart := `package templates
codeStart := `// Autogenerated code: do not edit
package templates
var templates = `
return codeStart + "`" + content + "`"
Expand Down
4 changes: 3 additions & 1 deletion codegen/ts/gen.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package ts

func Gen(content string) string {
codeStart := `import { LmTemplate } from "./interfaces.js";
codeStart := `// Autogenerated code: do not edit
import { LmTemplate } from "./interfaces.js";
const templates: Record<string, LmTemplate> = `
codeEnd := `;
Expand Down
12 changes: 5 additions & 7 deletions go/templates/lmtemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,15 @@ func (tpl *PromptTemplate) _buildUserBlock(msg *string) string {
func (tpl *PromptTemplate) _buildAssistantBlock(msg *string, isShot bool) string {
var buf []string
assistantBlock := tpl.Assistant
if (tpl._extraAssistant != "") && !isShot {
assistantBlock += tpl._extraAssistant
buf = append(buf, assistantBlock)
if tpl.Linebreaks != nil && tpl.Linebreaks.Assistant != nil {
buf = append(buf, strings.Repeat("\n", *tpl.Linebreaks.Assistant))
}
if msg != nil {
buf = append(buf, assistantBlock)
buf = append(buf, *msg)
} else {
buf = append(buf, assistantBlock)
}
if tpl.Linebreaks != nil && tpl.Linebreaks.Assistant != nil {
buf = append(buf, strings.Repeat("\n", *tpl.Linebreaks.Assistant))
if (tpl._extraAssistant != "") && !isShot {
buf = append(buf, tpl._extraAssistant)
}
return strings.Join(buf, "")
}
Expand Down

0 comments on commit 05d6a88

Please sign in to comment.