-
Smart Agent List
+ Smart Assistant Dashboard
-
-
-
-
-
-
-
- |
- Name
- |
-
- Status
- |
-
- Talk
- |
-
- Delete
- |
-
-
-
-
- {{ range .Agents }}
-
- | {{.}} |
- Online |
-
- Talk
- |
-
- Delete
- |
-
- {{ end }}
-
-
-
-
-
-
-
-
diff --git a/example/webui/main.go b/example/webui/main.go
index edad841..800812e 100644
--- a/example/webui/main.go
+++ b/example/webui/main.go
@@ -106,6 +106,12 @@ func main() {
})
})
+ webapp.Get("/agents", func(c *fiber.Ctx) error {
+ return c.Render("agents.html", fiber.Map{
+ "Agents": pool.List(),
+ })
+ })
+
webapp.Get("/create", func(c *fiber.Ctx) error {
return c.Render("create.html", fiber.Map{
"Title": "Hello, World!",
@@ -152,8 +158,8 @@ func main() {
func (a *App) KnowledgeBase(db *InMemoryDatabase) func(c *fiber.Ctx) error {
return func(c *fiber.Ctx) error {
payload := struct {
- URL string `json:"url"`
- ChunkSize int `json:"chunk_size"`
+ URL string `form:"url"`
+ ChunkSize int `form:"chunk_size"`
}{}
if err := c.BodyParser(&payload); err != nil {
@@ -169,28 +175,7 @@ func (a *App) KnowledgeBase(db *InMemoryDatabase) func(c *fiber.Ctx) error {
chunkSize = payload.ChunkSize
}
- go func() {
- content, err := Sitemap(website)
- if err != nil {
- fmt.Println("Error walking sitemap for website", err)
- }
- fmt.Println("Found pages: ", len(content))
- fmt.Println("ChunkSize: ", chunkSize)
-
- for _, c := range content {
- chunks := splitParagraphIntoChunks(c, chunkSize)
- fmt.Println("chunks: ", len(chunks))
- for _, chunk := range chunks {
- db.AddEntry(chunk)
- }
-
- db.SaveDB()
- }
-
- if err := db.SaveToStore(); err != nil {
- fmt.Println("Error storing in the KB", err)
- }
- }()
+ go WebsiteToKB(website, chunkSize, db)
return c.Redirect("/knowledgebase")
}
@@ -199,7 +184,7 @@ func (a *App) KnowledgeBase(db *InMemoryDatabase) func(c *fiber.Ctx) error {
func (a *App) Notify(pool *AgentPool) func(c *fiber.Ctx) error {
return func(c *fiber.Ctx) error {
payload := struct {
- Message string `json:"message"`
+ Message string `form:"message"`
}{}
if err := c.BodyParser(&payload); err != nil {
diff --git a/example/webui/rag.go b/example/webui/rag.go
index 375a92a..d048a9f 100644
--- a/example/webui/rag.go
+++ b/example/webui/rag.go
@@ -119,6 +119,30 @@ func Sitemap(url string) (res []string, err error) {
return
}
+func WebsiteToKB(website string, chunkSize int, db *InMemoryDatabase) {
+ content, err := Sitemap(website)
+ if err != nil {
+ fmt.Println("Error walking sitemap for website", err)
+ }
+ fmt.Println("Found pages: ", len(content))
+ fmt.Println("ChunkSize: ", chunkSize)
+
+ for _, c := range content {
+ chunks := splitParagraphIntoChunks(c, chunkSize)
+ fmt.Println("chunks: ", len(chunks))
+ for _, chunk := range chunks {
+ fmt.Println("Chunk size: ", len(chunk))
+ db.AddEntry(chunk)
+ }
+
+ db.SaveDB()
+ }
+
+ if err := db.SaveToStore(); err != nil {
+ fmt.Println("Error storing in the KB", err)
+ }
+}
+
// splitParagraphIntoChunks takes a paragraph and a maxChunkSize as input,
// and returns a slice of strings where each string is a chunk of the paragraph
// that is at most maxChunkSize long, ensuring that words are not split.
diff --git a/llm/rag/rag_chromem.go b/llm/rag/chromem.go
similarity index 96%
rename from llm/rag/rag_chromem.go
rename to llm/rag/chromem.go
index a14486e..5f33d2d 100644
--- a/llm/rag/rag_chromem.go
+++ b/llm/rag/chromem.go
@@ -24,7 +24,6 @@ func NewChromemDB(collection, path string, openaiClient *openai.Client) (*Chrome
embeddingFunc := chromem.EmbeddingFunc(
func(ctx context.Context, text string) ([]float32, error) {
- fmt.Println("Creating embeddings")
resp, err := openaiClient.CreateEmbeddings(ctx,
openai.EmbeddingRequestStrings{
Input: []string{text},
@@ -64,7 +63,6 @@ func (c *ChromemDB) Store(s string) error {
if s == "" {
return fmt.Errorf("empty string")
}
- fmt.Println("Trying to store", s)
return c.collection.AddDocuments(context.Background(), []chromem.Document{
{
Content: s,
diff --git a/llm/rag/rag_localai.go b/llm/rag/localai.go
similarity index 100%
rename from llm/rag/rag_localai.go
rename to llm/rag/localai.go