pkg

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Copyright 2023 KubeAGI.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2023 KubeAGI.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	DontKnow = "这个问题我不知道哦😯"
)
View Source
const (
	TitleFlag = "#"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	DB   chroma.Store
	Tree *Tree
	AI   *dashscope.DashScope
}

func NewDashScope

func NewDashScope(apiKey string, chromaURL, namespace string) (*Bot, error)

func (*Bot) Chat

func (d *Bot) Chat(ctx context.Context, prompt string, history []string) (res string, err error)

func (*Bot) EmbeddingFileTitle

func (d *Bot) EmbeddingFileTitle(ctx context.Context, fileName string) (err error)

func (*Bot) Query

func (d *Bot) Query(ctx context.Context, text string, chatHistory []string, lastNode *Node) (res string, foundNode *Node, err error)

type Node

type Node struct {
	RawTitle  string
	FullTitle string
	Text      string
	Level     int
	Question  string
	Children  []*Node
}

func (*Node) IsLeaf

func (n *Node) IsLeaf() bool

func (*Node) PreOrder

func (n *Node) PreOrder(option string) []string

type Tree

type Tree struct {
	Text     string
	Children []*Node
}

func NewTree

func NewTree(title string) *Tree

func (*Tree) AddNode

func (t *Tree) AddNode(n, last *Node)

目前不考虑格式不对的情况,比如 nodeLevel=4, lastLevel=2 这种情况

func (*Tree) FindNodeByFullTitile

func (t *Tree) FindNodeByFullTitile(title string) *Node

func (*Tree) FindNodeParent

func (t *Tree) FindNodeParent(n *Node) *Node

func (*Tree) GetFullTitles

func (t *Tree) GetFullTitles() []string

func (*Tree) ParseFile

func (t *Tree) ParseFile(fileName string) (err error)

func (*Tree) String

func (t *Tree) String() string

Jump to

Keyboard shortcuts

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