KB: Specify chunk size
This commit is contained in:
@@ -18,6 +18,10 @@
|
||||
<label for="url" class="block text-lg font-medium text-gray-400">URL</label>
|
||||
<input type="text" name="url" id="url" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md bg-gray-700 text-white" placeholder="Name">
|
||||
</div>
|
||||
<div class="mb-6">
|
||||
<label for="chunk_size" class="block text-lg font-medium text-gray-400">Chunk size</label>
|
||||
<input type="text" name="chunk_size" id="chunk_size" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md bg-gray-700 text-white" placeholder="380">
|
||||
</div>
|
||||
|
||||
|
||||
<div class="flex items-center justify-between">
|
||||
|
||||
@@ -133,6 +133,7 @@ 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"`
|
||||
}{}
|
||||
|
||||
if err := c.BodyParser(&payload); err != nil {
|
||||
@@ -152,7 +153,7 @@ func (a *App) KnowledgeBase(db *InMemoryDatabase) func(c *fiber.Ctx) error {
|
||||
fmt.Println("Found pages: ", len(content))
|
||||
|
||||
for _, c := range content {
|
||||
chunks := splitParagraphIntoChunks(c, 256)
|
||||
chunks := splitParagraphIntoChunks(c, payload.ChunkSize)
|
||||
fmt.Println("chunks: ", len(chunks))
|
||||
for _, chunk := range chunks {
|
||||
db.AddEntry(chunk)
|
||||
|
||||
Reference in New Issue
Block a user