This commit is contained in:
2025-11-22 18:32:19 +01:00
parent 3d8effeac7
commit 27d2723023
9 changed files with 153 additions and 4 deletions

0
.zed/debug.json Normal file
View File

View File

@@ -10,8 +10,21 @@ mut cl := client.new()!
// max_completion_tokens: 1024
// )!
response := cl.llms.llm_embed_local.embed(input: [
'The food was delicious and the waiter..',
])!
response := cl.llms.llm_maverick.chat_completion(
message: 'Explain quantum computing in simple terms'
temperature: 0.5
max_completion_tokens: 1024
)!
println(response)
// response := cl.llms.llm_embed_local.embed(input: [
// 'The food was delicious and the waiter..',
// ])!
// response2 := cl.llms.llm_embed.embed(input: [
// 'The food was delicious and the waiter..',
// ])!
println(response2)

View File

@@ -0,0 +1,9 @@
module flow_calendar
import incubaid.herolib.hero.heromodels
import incubaid.herolib.core.flows
pub fn calendar_delete(mut s flows.Step) ! {
// get heromodels
mut m := heromodels.get('coordinator_${s.coordinator.name}')!
}

View File

@@ -0,0 +1,20 @@
module flow_calendar
import incubaid.herolib.hero.heromodels
import incubaid.herolib.core.flows
type CoordinatorProxy = flows.Coordinator
pub fn (mut c CoordinatorProxy) start(prompt string) ! {
// init the heromodels, define well chosen name, needed to call later
mut m := heromodels.new(redis: c.redis, name: 'coordinator_${c.name}')!
mut step_triage := c.step_new(
context: {
'prompt': prompt
}
f: triage
)!
c.run()!
}

View File

@@ -0,0 +1,13 @@
module flow_calendar
import incubaid.herolib.hero.heromodels
import incubaid.herolib.core.flows
pub fn triage(mut s flows.Step) ! {
prompt := s.context['prompt'] or { panic("can't find prompt context in step:\n${s}") }
response := s.coordinator.ai.llms.llm_maverick.chat_completion(
message: 'Explain quantum computing in simple terms'
temperature: 0.5
max_completion_tokens: 1024
)!
}

View File

@@ -0,0 +1,55 @@
module flows
// __global (
// contexts map[u32]&Context
// context_current u32
// )
//
//
import incubaid.herolib.core.logger
import incubaid.herolib.ai.client as aiclient
import incubaid.herolib.core.redisclient
import incubaid.herolib.data.paramsparser
pub struct Coordinator {
pub mut:
name string
steps map[string]Step
logger logger.Logger
ai aiclient.AIClient
redis ?&redisclient.Redis
}
pub fn new() !Coordinator {
return Coordinator{
logger: logger.new(path: '/tmp/flowlogger')!
ai: aiclient.new()!
}
}
@[params]
pub struct StepNewArgs {
pub mut:
name string
description string
f fn (mut s Step) ! @[required]
context map[string]string
error_steps []Step
next_steps []Step
error string
params paramsparser.Params
}
// add step to it
pub fn (mut c Coordinator) step_new(args StepNewArgs) !Step {
return Step{
coordinator: &c
name: args.name
description: args.description
main_step: args.f
error_steps: args.error_steps
next_steps: args.next_steps
error: args.error
params: args.params
}
}

31
lib/core/flows/step.v Normal file
View File

@@ -0,0 +1,31 @@
module flows
import incubaid.herolib.data.paramsparser
import incubaid.herolib.core.logger
pub struct Step {
pub mut:
name string
description string
main_step fn (mut s Step) ! @[required]
context map[string]string
error_steps []Step
next_steps []Step
error string
logs []logger.LogItem
params paramsparser.Params
coordinator &Coordinator
}
pub fn (mut s Step) error_step_add(s2 Step) {
s.error_steps << s2
}
pub fn (mut s Step) next_step_add(s2 Step) {
s.next_steps << s2
}
pub fn (mut s Step) log(l logger.LogItemArgs) ! {
mut l2 := s.coordinator.logger.log(l)!
s.logs << l2
}

View File

@@ -14,7 +14,7 @@ pub mut:
logtype LogType
}
pub fn (mut l Logger) log(args_ LogItemArgs) ! {
pub fn (mut l Logger) log(args_ LogItemArgs) !LogItem {
mut args := args_
t := args.timestamp or {
@@ -67,6 +67,13 @@ pub fn (mut l Logger) log(args_ LogItemArgs) ! {
if l.console_output {
l.write_to_console(args, t)!
}
return LogItem{
timestamp: t
cat: args.cat
log: args.log
logtype: args.logtype
}
}
// Write log message to console with clean formatting

View File

@@ -168,6 +168,7 @@ println(map_representation["key1"]) // Output: value1
Combine two `Params` objects, with values from the merged object overriding existing keys.
```v
mut params1 := paramsparser.new("color:red size:small")!
params2 := paramsparser.new("size:large material:wood")!