47 lines
896 B
Go
47 lines
896 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"strings"
|
|
|
|
"github.com/yuin/goldmark"
|
|
highlighting "github.com/yuin/goldmark-highlighting"
|
|
)
|
|
|
|
func markdownToHTML(markdownText string) string {
|
|
var buf bytes.Buffer
|
|
md := goldmark.New(
|
|
goldmark.WithExtensions(
|
|
highlighting.NewHighlighting(highlighting.WithStyle("monokai")),
|
|
),
|
|
)
|
|
if err := md.Convert([]byte(markdownText), &buf); err != nil {
|
|
panic(err) // Handle the error appropriately
|
|
}
|
|
|
|
return buf.String()
|
|
}
|
|
|
|
func model2Icon(model string) string {
|
|
if model == "gpt-3.5-turbo" {
|
|
return "openai"
|
|
}
|
|
if model == "gpt-4" {
|
|
return "openai"
|
|
}
|
|
// If model name contain claude-3 retrun anthropic
|
|
if strings.Contains(model, "claude-3") {
|
|
return "anthropic"
|
|
}
|
|
return "openai"
|
|
}
|
|
|
|
func model2Name(model string) string {
|
|
for i := range ModelsInfos {
|
|
if ModelsInfos[i].ID == model {
|
|
return ModelsInfos[i].Name
|
|
}
|
|
}
|
|
return "OpenAI"
|
|
}
|