apps

package
v0.0.0-...-04ebf03 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AgentCmd = &cobra.Command{
	Use:   "agent",
	Short: "agent",
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		var agentLog = logger.NewLog("agent")

		loader := config.NewConfigLoader()
		cfg, err := loader.GetConfig()
		if err != nil {
			agentLog.Panicw("load config error", "error", err)
		}

		friday.Fri, err = common.NewFriday(&cfg)
		if err != nil {
			agentLog.Errorf("init friday error: %v", err)
		}
	},
}
View Source
var ChatCmd = &cobra.Command{
	Use:   "chat",
	Short: "chat with llm base on knowledge",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) <= 1 {
			panic("dirId and history is needed.")
		}
		dirIdStr := args[0]
		dirId, err := strconv.Atoi(dirIdStr)
		if err != nil {
			panic(err)
		}

		historyStr := fmt.Sprint(strings.Join(args[1:], " "))

		history := make([]map[string]string, 0)
		err = json.Unmarshal([]byte(historyStr), &history)
		if err != nil {
			panic(err)
		}

		if err := chat(int64(dirId), history); err != nil {
			panic(err)
		}
	},
}
View Source
var IngestCmd = &cobra.Command{
	Use:   "ingest",
	Short: "ingest knowledge",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			panic("ingest path is needed")
		}
		ps := args[0]

		if err := ingest(ps); err != nil {
			panic(err)
		}
	},
}
View Source
var KeywordsCmd = &cobra.Command{
	Use:   "keywords",
	Short: "Extract keywords",
	Run: func(cmd *cobra.Command, args []string) {
		ps := args[0]

		if err := keywords(ps); err != nil {
			panic(err)
		}
	},
}
View Source
var QuestionCmd = &cobra.Command{
	Use:   "question",
	Short: "question base on knowledge",
	Run: func(cmd *cobra.Command, args []string) {
		question := fmt.Sprint(strings.Join(args, " "))

		if err := run(question); err != nil {
			panic(err)
		}
	},
}
View Source
var ServeCmd = &cobra.Command{
	Use:   "serve",
	Short: "serve",
	Run: func(cmd *cobra.Command, args []string) {
		loader := config.NewConfigLoader()
		cfg, err := loader.GetConfig()
		if err != nil {
			panic(err)
		}

		if cfg.Debug {
			logger.SetDebug(true)
		}
		service.ChainPool = dispatch.NewPool(cfg.PoolNum)

		stop := utils.HandleTerminalSignal()
		wg := sync.WaitGroup{}
		s, err := api.NewHttpServer(cfg)
		if err != nil {
			panic(err)
		}
		wg.Add(1)
		go func() {
			defer wg.Done()
			s.Run(stop)
		}()
		wg.Wait()
	},
}
View Source
var SummaryCmd = &cobra.Command{
	Use:   "summary",
	Short: "Summarize an article in short words",
	Run: func(cmd *cobra.Command, args []string) {
		ps := args[0]

		if err := summary(ps); err != nil {
			panic(err)
		}
	},
}
View Source
var WeChatCmd = &cobra.Command{
	Use:   "chat",
	Short: "conclusion base on chat",
	Run: func(cmd *cobra.Command, args []string) {
		ps := fmt.Sprint(strings.Join(args, " "))

		if err := wechat(ps); err != nil {
			panic(err)
		}
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL