mirror of
https://github.com/mariocandela/beelzebub.git
synced 2025-07-01 18:47:26 -04:00
Feature: add support for llama, refactor yaml service interface (#115)
* refactor and add llama LMM support * update readme * improve code coverage
This commit is contained in:
@ -2,6 +2,7 @@ package parser
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/mariocandela/beelzebub/v3/plugins"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
@ -53,7 +54,12 @@ commands:
|
||||
- regex: "wp-admin"
|
||||
handler: "login"
|
||||
headers:
|
||||
- "Content-Type: text/html"`)
|
||||
- "Content-Type: text/html"
|
||||
plugin:
|
||||
openAISecretKey: "qwerty"
|
||||
llmModel: "llama3"
|
||||
host: "localhost:1563"
|
||||
`)
|
||||
return beelzebubServiceConfiguration, nil
|
||||
}
|
||||
|
||||
@ -112,10 +118,10 @@ func TestReadConfigurationsServicesValid(t *testing.T) {
|
||||
configurationsParser.gelAllFilesNameByDirNameDependency = mockReadDirValid
|
||||
|
||||
beelzebubServicesConfiguration, err := configurationsParser.ReadConfigurationsServices()
|
||||
assert.Nil(t, err)
|
||||
|
||||
firstBeelzebubServiceConfiguration := beelzebubServicesConfiguration[0]
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, firstBeelzebubServiceConfiguration.Protocol, "http")
|
||||
assert.Equal(t, firstBeelzebubServiceConfiguration.ApiVersion, "v1")
|
||||
assert.Equal(t, firstBeelzebubServiceConfiguration.Address, ":8080")
|
||||
@ -125,6 +131,9 @@ func TestReadConfigurationsServicesValid(t *testing.T) {
|
||||
assert.Equal(t, firstBeelzebubServiceConfiguration.Commands[0].Handler, "login")
|
||||
assert.Equal(t, len(firstBeelzebubServiceConfiguration.Commands[0].Headers), 1)
|
||||
assert.Equal(t, firstBeelzebubServiceConfiguration.Commands[0].Headers[0], "Content-Type: text/html")
|
||||
assert.Equal(t, firstBeelzebubServiceConfiguration.Plugin.OpenAISecretKey, "qwerty")
|
||||
assert.Equal(t, firstBeelzebubServiceConfiguration.Plugin.LLMModel, "llama3")
|
||||
assert.Equal(t, firstBeelzebubServiceConfiguration.Plugin.Host, "localhost:1563")
|
||||
}
|
||||
|
||||
func TestGelAllFilesNameByDirName(t *testing.T) {
|
||||
@ -177,3 +186,16 @@ func TestReadFileBytesByFilePath(t *testing.T) {
|
||||
|
||||
assert.Equal(t, "", string(bytes))
|
||||
}
|
||||
|
||||
func TestFromString(t *testing.T) {
|
||||
model, err := FromString("llama3")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, plugins.LLAMA3, model)
|
||||
|
||||
model, err = FromString("gpt4-o")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, plugins.GPT4O, model)
|
||||
|
||||
model, err = FromString("beelzebub-model")
|
||||
assert.Errorf(t, err, "model beelzebub-model not found")
|
||||
}
|
||||
|
Reference in New Issue
Block a user