Documentation
¶
Index ¶
- Constants
- Variables
- func CountTokens(text string) int
- func ExtractAgentID(ctx context.Context) (string, bool)
- func ExtractAgentLogKey(ctx context.Context) (string, bool)
- func InjectAgentID(ctx context.Context, id string) context.Context
- func InjectAgentLogKey(ctx context.Context, logKey string) context.Context
- func MustInitLogger()
- func SPrintWithCallStack(title, content string, maxWidth int) string
- func SPrintWithFrameCard(title, content string, maxWidth int, style FrameStyle) string
- func SPrintWithMsgCard(title, content string, maxWidth int) string
- func TakeSentences(lst []string, maxToken int) (paragraph []rune, left []string)
- func Unmarshal2[T any](str string) (ret T, err error)
- type CtxKey
- type EnvKey
- type FrameStyle
Constants ¶
View Source
const ( PrintWidthL1 = 110 PrintWidthL2 = 96 )
Variables ¶
View Source
var ( StyConclusion = CreateStyle("╔", "╗", "╚", "╝", "║", "═", "🎉🎉 ", "", 0) StyTalk = CreateStyle("╔", "╗", "╚", "╝", "║", "═", "🚗 ", "", 0) StyNoFuncResult = CreateStyle("┌", "┐", "└", "┘", "│", "─", "🌲 ", "", 1) StyFunctionStack = CreateStyle("┌", "┐", "└", "┘", "│", "─", "🔍 ", "", 1) StyMsgCard = CreateStyle("┌", "┐", "└", "┘", "│", "─", "✉ ", "", 2) )
预定义的样式
View Source
var LogDir = "./logs"
Functions ¶
func CountTokens ¶
func ExtractAgentID ¶
ExtractAgentID 从 context 中获取 bot 的 id
func ExtractAgentLogKey ¶
ExtractAgentLogKey 从 context 中获取 bot 的 prefabName
func InjectAgentID ¶
InjectAgentID 将 bot 的 prefabName 注入到 context 中
func InjectAgentLogKey ¶
InjectAgentLogKey 将 bot 的 prefabName 注入到 context 中
func MustInitLogger ¶
func MustInitLogger()
func SPrintWithCallStack ¶
SPrintWithCallStack 打印函数调用栈
func SPrintWithFrameCard ¶
func SPrintWithFrameCard(title, content string, maxWidth int, style FrameStyle) string
SPrintWithFrameCard 打印带框架的卡片
func SPrintWithMsgCard ¶
SPrintWithMsgCard 打印 msg 栈中的单个消息
func TakeSentences ¶
TakeSentences 从句子列表中取出一段话,并返回剩余的句子列表 lst 为句子列表, 由原始文本分割得到 (比如根据 \n 分隔) maxToken 为每段话的最大 token 数
func Unmarshal2 ¶
Types ¶
type FrameStyle ¶
type FrameStyle struct { TopLeft string TopRight string BottomLeft string BottomRight string Horizontal string Vertical string TitlePrefix string LinePrefix string LiteLevel uint8 }
FrameStyle 定义框架样式
func CreateStyle ¶
func CreateStyle(lt, rt, lb, rb, v, h, titlePrefix, linePrefix string, level uint8) FrameStyle
Click to show internal directories.
Click to hide internal directories.