Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: remove categories from config and instead pass them as base64 encoded json param #450

Merged
merged 12 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions docs/example_category.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"engines": {
"google": {
"enabled": true,
"required": false,
"requiredbyorigin": true,
"preferred": false,
"preferredbyorigin": false
},
"bing": {
"enabled": true,
"required": false,
"requiredbyorigin": true,
"preferred": false,
"preferredbyorigin": false
},
"brave": {
"enabled": true,
"required": false,
"requiredbyorigin": false,
"preferred": true,
"preferredbyorigin": false
}
},
"ranking": {
"rankexp": 0.5,
"rankmul": 1,
"rankconst": 0,
"rankscoremul": 1,
"rankscoreadd": 0,
"timesreturnedmul": 1,
"timesreturnedadd": 0,
"timesreturnedscoremul": 1,
"timesreturnedscoreadd": 0,
"engines": {
"google": {
"mul": 1,
"add": 0
},
"bing": {
"mul": 1,
"add": 0
},
"brave": {
"mul": 1,
"add": 0
}
}
},
"timings": {
"preferredtimeout": "500",
"hardtimeout": "1500"
}
}
6 changes: 3 additions & 3 deletions generate/enginer/enginer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ var (
interfacesImport = flag.String("interfacesimport", "github.com/hearchco/agent/src/search/scraper", "source of the interface import, which is prefixed to interfaces; default github.com/hearchco/agent/src/search/scraper")
interfacesPackage = flag.String("interfacespackage", "scraper", "name of the package for the interfaces; default scraper")
interfaceEnginer = flag.String("interfaceenginer", "Enginer", "name of the nginer interface; default scraper.Enginer")
interfaceSearcher = flag.String("interfacesearcher", "Searcher", "name of the searcher interface; default scraper.Searcher")
interfaceImageSearcher = flag.String("interfaceimagesearcher", "ImageSearcher", "name of the searcher interface; default scraper.ImageSearcher")
interfaceWebSearcher = flag.String("interfacewebsearcher", "WebSearcher", "name of the web searcher interface; default scraper.WebSearcher")
interfaceImageSearcher = flag.String("interfaceimagesearcher", "ImageSearcher", "name of the image searcher interface; default scraper.ImageSearcher")
interfaceSuggester = flag.String("interfacesuggester", "Suggester", "name of the suggester interface; default scraper.Suggester")
enginesImport = flag.String("enginesimport", "github.com/hearchco/agent/src/search/engines", "source of the engines import, which is prefixed to imports for engines; default github.com/hearchco/agent/src/search/engines")
)
Expand Down Expand Up @@ -201,7 +201,7 @@ func (g *Generator) generate(typeName string) {

g.printEnginerLen(values)
g.printInterfaces(values, *interfaceEnginer)
g.printInterfaces(values, *interfaceSearcher)
g.printInterfaces(values, *interfaceWebSearcher)
g.printInterfaces(values, *interfaceImageSearcher)
g.printInterfaces(values, *interfaceSuggester)
}
Expand Down
18 changes: 5 additions & 13 deletions hearchco_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@ server:
type: none
imageproxy:
secretkey: changemepls
# categories:
# general:
# engines:
# duckduckgo:
# enabled: false
# ranking:
# engines:
# google:
# mul: 2
# images:
# engines:
# bing:
# enabled: false
# engines:
# google:
# noweb: true # Disables web search for this engine
# noimages: true # Disables image search for this engine
# nosuggestions: true # Disables suggestions for this engine
63 changes: 14 additions & 49 deletions src/config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package config
import (
"time"

"github.com/hearchco/agent/src/search/category"
exchengines "github.com/hearchco/agent/src/exchange/engines"
"github.com/hearchco/agent/src/search/engines"
"github.com/hearchco/agent/src/utils/moretime"
)

Expand Down Expand Up @@ -31,57 +32,21 @@ func New() Config {
Timeout: 3 * time.Second,
},
},
Categories: map[category.Name]Category{
category.SUGGESTIONS: {
Engines: suggestionsEngines,
RequiredEngines: suggestionsRequiredEngines,
RequiredByOriginEngines: suggestionsRequiredByOriginEngines,
PreferredEngines: suggestionsPreferredEngines,
PreferredByOriginEngines: suggestionsPreferredByOriginEngines,
Ranking: suggestionsRanking(),
Timings: suggestionsTimings,
},
category.GENERAL: {
Engines: generalEngines,
RequiredEngines: generalRequiredEngines,
RequiredByOriginEngines: generalRequiredByOriginEngines,
PreferredEngines: generalPreferredEngines,
PreferredByOriginEngines: generalPreferredByOriginEngines,
Ranking: generalRanking(),
Timings: generalTimings,
},
category.IMAGES: {
Engines: imagesEngines,
RequiredEngines: imagesRequiredEngines,
RequiredByOriginEngines: imagesRequiredByOriginEngines,
PreferredEngines: imagesPreferredEngines,
PreferredByOriginEngines: imagesPreferredByOriginEngines,
Ranking: imagesRanking(),
Timings: imagesTimings,
},
category.SCIENCE: {
Engines: scienceEngines,
RequiredEngines: scienceRequiredEngines,
RequiredByOriginEngines: scienceRequiredByOriginEngines,
PreferredEngines: sciencePreferredEngines,
PreferredByOriginEngines: sciencePreferredByOriginEngines,
Ranking: scienceRanking(),
Timings: scienceTimings,
},
category.THOROUGH: {
Engines: thoroughEngines,
RequiredEngines: thoroughRequiredEngines,
RequiredByOriginEngines: thoroughRequiredByOriginEngines,
PreferredEngines: thoroughPreferredEngines,
PreferredByOriginEngines: thoroughPreferredByOriginEngines,
Ranking: thoroughRanking(),
Timings: thoroughTimings,
},
Engines: EngineConfig{
NoWeb: []engines.Name{},
NoImages: []engines.Name{},
NoSuggestions: []engines.Name{},
},
Exchange: Exchange{
BaseCurrency: "EUR",
Engines: exchangeEngines,
Timings: exchangeTimings,
Engines: []exchengines.Name{
exchengines.CURRENCYAPI,
exchengines.EXCHANGERATEAPI,
exchengines.FRANKFURTER,
},
Timings: ExchangeTimings{
HardTimeout: 1 * time.Second,
},
},
}
}
44 changes: 0 additions & 44 deletions src/config/defaults_cat_general.go

This file was deleted.

32 changes: 0 additions & 32 deletions src/config/defaults_cat_images.go

This file was deleted.

30 changes: 0 additions & 30 deletions src/config/defaults_cat_science.go

This file was deleted.

32 changes: 0 additions & 32 deletions src/config/defaults_cat_suggestions.go

This file was deleted.

52 changes: 0 additions & 52 deletions src/config/defaults_cat_thorough.go

This file was deleted.

17 changes: 0 additions & 17 deletions src/config/defaults_exchange.go

This file was deleted.

Loading
Loading