...
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.clients.qdrant
|
import freeflowuniverse.herolib.clients.qdrant
|
||||||
import freeflowuniverse.herolib.installers.db.qdrant as qdrant_installer
|
import freeflowuniverse.herolib.installers.db.qdrant_installer
|
||||||
import freeflowuniverse.herolib.core.httpconnection
|
import freeflowuniverse.herolib.core.httpconnection
|
||||||
import rand
|
import rand
|
||||||
import os
|
import os
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ heroscript:="
|
|||||||
masterkey: '1234'
|
masterkey: '1234'
|
||||||
port: 7701
|
port: 7701
|
||||||
|
|
||||||
!!meilisearch.start name:'test' reset:1
|
|
||||||
"
|
"
|
||||||
|
|
||||||
meilisearchinstaller.play(heroscript=heroscript)!
|
meilisearchinstaller.play(heroscript=heroscript)!
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
!!hero_code.generate_installer
|
!!hero_code.generate_installer
|
||||||
name:'qdrant'
|
name:'qdrant_installer'
|
||||||
classname:'QDrant'
|
classname:'QDrant'
|
||||||
singleton:0
|
singleton:0
|
||||||
templates:1
|
templates:1
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
module qdrant
|
module qdrant_installer
|
||||||
|
|
||||||
import freeflowuniverse.herolib.osal
|
|
||||||
import freeflowuniverse.herolib.ui.console
|
import freeflowuniverse.herolib.ui.console
|
||||||
import freeflowuniverse.herolib.core
|
|
||||||
import freeflowuniverse.herolib.core.texttools
|
|
||||||
import freeflowuniverse.herolib.osal.zinit
|
import freeflowuniverse.herolib.osal.zinit
|
||||||
import freeflowuniverse.herolib.installers.ulist
|
import freeflowuniverse.herolib.installers.ulist
|
||||||
import os
|
import os
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
module qdrant
|
module qdrant_installer
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.base
|
import freeflowuniverse.herolib.core.base
|
||||||
import freeflowuniverse.herolib.core.playbook
|
import freeflowuniverse.herolib.core.playbook
|
||||||
@@ -8,8 +8,8 @@ import freeflowuniverse.herolib.osal.zinit
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
__global (
|
__global (
|
||||||
qdrant_global map[string]&QDrant
|
qdrant_installer_global map[string]&QDrant
|
||||||
qdrant_default string
|
qdrant_installer_default string
|
||||||
)
|
)
|
||||||
|
|
||||||
/////////FACTORY
|
/////////FACTORY
|
||||||
@@ -32,19 +32,19 @@ pub fn get(args_ ArgsGet) !&QDrant {
|
|||||||
mut context := base.context()!
|
mut context := base.context()!
|
||||||
mut args := args_get(args_)
|
mut args := args_get(args_)
|
||||||
mut obj := QDrant{}
|
mut obj := QDrant{}
|
||||||
if args.name !in qdrant_global {
|
if args.name !in qdrant_installer_global {
|
||||||
if !exists(args)! {
|
if !exists(args)! {
|
||||||
set(obj)!
|
set(obj)!
|
||||||
} else {
|
} else {
|
||||||
heroscript := context.hero_config_get('qdrant', args.name)!
|
heroscript := context.hero_config_get('qdrant_installer', args.name)!
|
||||||
mut obj_ := heroscript_loads(heroscript)!
|
mut obj_ := heroscript_loads(heroscript)!
|
||||||
set_in_mem(obj_)!
|
set_in_mem(obj_)!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return qdrant_global[args.name] or {
|
return qdrant_installer_global[args.name] or {
|
||||||
println(qdrant_global)
|
println(qdrant_installer_global)
|
||||||
// bug if we get here because should be in globals
|
// bug if we get here because should be in globals
|
||||||
panic('could not get config for qdrant with name, is bug:${args.name}')
|
panic('could not get config for qdrant_installer with name, is bug:${args.name}')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,30 +53,30 @@ pub fn set(o QDrant) ! {
|
|||||||
set_in_mem(o)!
|
set_in_mem(o)!
|
||||||
mut context := base.context()!
|
mut context := base.context()!
|
||||||
heroscript := heroscript_dumps(o)!
|
heroscript := heroscript_dumps(o)!
|
||||||
context.hero_config_set('qdrant', o.name, heroscript)!
|
context.hero_config_set('qdrant_installer', o.name, heroscript)!
|
||||||
}
|
}
|
||||||
|
|
||||||
// does the config exists?
|
// does the config exists?
|
||||||
pub fn exists(args_ ArgsGet) !bool {
|
pub fn exists(args_ ArgsGet) !bool {
|
||||||
mut context := base.context()!
|
mut context := base.context()!
|
||||||
mut args := args_get(args_)
|
mut args := args_get(args_)
|
||||||
return context.hero_config_exists('qdrant', args.name)
|
return context.hero_config_exists('qdrant_installer', args.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delete(args_ ArgsGet) ! {
|
pub fn delete(args_ ArgsGet) ! {
|
||||||
mut args := args_get(args_)
|
mut args := args_get(args_)
|
||||||
mut context := base.context()!
|
mut context := base.context()!
|
||||||
context.hero_config_delete('qdrant', args.name)!
|
context.hero_config_delete('qdrant_installer', args.name)!
|
||||||
if args.name in qdrant_global {
|
if args.name in qdrant_installer_global {
|
||||||
// del qdrant_global[args.name]
|
// del qdrant_installer_global[args.name]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// only sets in mem, does not set as config
|
// only sets in mem, does not set as config
|
||||||
fn set_in_mem(o QDrant) ! {
|
fn set_in_mem(o QDrant) ! {
|
||||||
mut o2 := obj_init(o)!
|
mut o2 := obj_init(o)!
|
||||||
qdrant_global[o.name] = &o2
|
qdrant_installer_global[o.name] = &o2
|
||||||
qdrant_default = o.name
|
qdrant_installer_default = o.name
|
||||||
}
|
}
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
@@ -92,7 +92,7 @@ pub fn play(args_ PlayArgs) ! {
|
|||||||
|
|
||||||
mut plbook := args.plbook or { playbook.new(text: args.heroscript)! }
|
mut plbook := args.plbook or { playbook.new(text: args.heroscript)! }
|
||||||
|
|
||||||
mut install_actions := plbook.find(filter: 'qdrant.configure')!
|
mut install_actions := plbook.find(filter: 'qdrant_installer.configure')!
|
||||||
if install_actions.len > 0 {
|
if install_actions.len > 0 {
|
||||||
for install_action in install_actions {
|
for install_action in install_actions {
|
||||||
heroscript := install_action.heroscript()
|
heroscript := install_action.heroscript()
|
||||||
@@ -101,37 +101,37 @@ pub fn play(args_ PlayArgs) ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mut other_actions := plbook.find(filter: 'qdrant.')!
|
mut other_actions := plbook.find(filter: 'qdrant_installer.')!
|
||||||
for other_action in other_actions {
|
for other_action in other_actions {
|
||||||
if other_action.name in ['destroy', 'install', 'build'] {
|
if other_action.name in ['destroy', 'install', 'build'] {
|
||||||
mut p := other_action.params
|
mut p := other_action.params
|
||||||
reset := p.get_default_false('reset')
|
reset := p.get_default_false('reset')
|
||||||
if other_action.name == 'destroy' || reset {
|
if other_action.name == 'destroy' || reset {
|
||||||
console.print_debug('install action qdrant.destroy')
|
console.print_debug('install action qdrant_installer.destroy')
|
||||||
destroy()!
|
destroy()!
|
||||||
}
|
}
|
||||||
if other_action.name == 'install' {
|
if other_action.name == 'install' {
|
||||||
console.print_debug('install action qdrant.install')
|
console.print_debug('install action qdrant_installer.install')
|
||||||
install()!
|
install()!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if other_action.name in ['start', 'stop', 'restart'] {
|
if other_action.name in ['start', 'stop', 'restart'] {
|
||||||
mut p := other_action.params
|
mut p := other_action.params
|
||||||
name := p.get('name')!
|
name := p.get('name')!
|
||||||
mut qdrant_obj := get(name: name)!
|
mut qdrant_installer_obj := get(name: name)!
|
||||||
console.print_debug('action object:\n${qdrant_obj}')
|
console.print_debug('action object:\n${qdrant_installer_obj}')
|
||||||
if other_action.name == 'start' {
|
if other_action.name == 'start' {
|
||||||
console.print_debug('install action qdrant.${other_action.name}')
|
console.print_debug('install action qdrant_installer.${other_action.name}')
|
||||||
qdrant_obj.start()!
|
qdrant_installer_obj.start()!
|
||||||
}
|
}
|
||||||
|
|
||||||
if other_action.name == 'stop' {
|
if other_action.name == 'stop' {
|
||||||
console.print_debug('install action qdrant.${other_action.name}')
|
console.print_debug('install action qdrant_installer.${other_action.name}')
|
||||||
qdrant_obj.stop()!
|
qdrant_installer_obj.stop()!
|
||||||
}
|
}
|
||||||
if other_action.name == 'restart' {
|
if other_action.name == 'restart' {
|
||||||
console.print_debug('install action qdrant.${other_action.name}')
|
console.print_debug('install action qdrant_installer.${other_action.name}')
|
||||||
qdrant_obj.restart()!
|
qdrant_installer_obj.restart()!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ pub fn (mut self QDrant) start() ! {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
console.print_header('qdrant start')
|
console.print_header('qdrant_installer start')
|
||||||
|
|
||||||
if !installed()! {
|
if !installed()! {
|
||||||
install()!
|
install()!
|
||||||
@@ -188,7 +188,7 @@ pub fn (mut self QDrant) start() ! {
|
|||||||
for zprocess in startupcmd()! {
|
for zprocess in startupcmd()! {
|
||||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||||
|
|
||||||
console.print_debug('starting qdrant with ${zprocess.startuptype}...')
|
console.print_debug('starting qdrant_installer with ${zprocess.startuptype}...')
|
||||||
|
|
||||||
sm.new(zprocess)!
|
sm.new(zprocess)!
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ pub fn (mut self QDrant) start() ! {
|
|||||||
}
|
}
|
||||||
time.sleep(100 * time.millisecond)
|
time.sleep(100 * time.millisecond)
|
||||||
}
|
}
|
||||||
return error('qdrant did not install properly.')
|
return error('qdrant_installer did not install properly.')
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut self QDrant) install_start(args InstallArgs) ! {
|
pub fn (mut self QDrant) install_start(args InstallArgs) ! {
|
||||||
@@ -266,9 +266,9 @@ pub fn (mut self QDrant) destroy() ! {
|
|||||||
destroy()!
|
destroy()!
|
||||||
}
|
}
|
||||||
|
|
||||||
// switch instance to be used for qdrant
|
// switch instance to be used for qdrant_installer
|
||||||
pub fn switch(name string) {
|
pub fn switch(name string) {
|
||||||
qdrant_default = name
|
qdrant_installer_default = name
|
||||||
}
|
}
|
||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
module qdrant
|
module qdrant_installer
|
||||||
|
|
||||||
import os
|
|
||||||
import freeflowuniverse.herolib.data.encoderhero
|
import freeflowuniverse.herolib.data.encoderhero
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import freeflowuniverse.herolib.core.pathlib
|
||||||
|
import os
|
||||||
|
|
||||||
pub const version = '1.13.4'
|
pub const version = '1.13.4'
|
||||||
const singleton = false
|
const singleton = false
|
||||||
@@ -35,7 +35,6 @@ fn configure() ! {
|
|||||||
mut mycode := $tmpl('templates/config.yaml')
|
mut mycode := $tmpl('templates/config.yaml')
|
||||||
mut path := pathlib.get_file(path: '${os.home_dir()}/hero/var/qdrant/config.yaml', create: true)!
|
mut path := pathlib.get_file(path: '${os.home_dir()}/hero/var/qdrant/config.yaml', create: true)!
|
||||||
path.write(mycode)!
|
path.write(mycode)!
|
||||||
// console.print_debug(mycode)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////NORMALLY NO NEED TO TOUCH
|
/////////////NORMALLY NO NEED TO TOUCH
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
# qdrant
|
# qdrant
|
||||||
|
|
||||||
|
Is a powerfull db for embedding for AI Agents.
|
||||||
|
|
||||||
To get started
|
To get started
|
||||||
|
|
||||||
```vlang
|
```vlang
|
||||||
|
|
||||||
|
import freeflowuniverse.herolib.installers.db.qdrant_installer
|
||||||
import freeflowuniverse.herolib.installers.something.qdrant as qdrant_installer
|
|
||||||
|
|
||||||
heroscript:="
|
heroscript:="
|
||||||
!!qdrant.configure name:'test'
|
!!qdrant.configure name:'test'
|
||||||
@@ -27,18 +26,3 @@ qdrant_installer.play(heroscript=heroscript)!
|
|||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## example heroscript
|
|
||||||
|
|
||||||
```hero
|
|
||||||
!!qdrant.configure
|
|
||||||
homedir: '/home/user/qdrant'
|
|
||||||
username: 'admin'
|
|
||||||
password: 'secretpassword'
|
|
||||||
title: 'Some Title'
|
|
||||||
host: 'localhost'
|
|
||||||
port: 8888
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user