update
This commit is contained in:
+2
-2
@@ -13,8 +13,8 @@ module YiemAgent
|
|||||||
include("utils.jl")
|
include("utils.jl")
|
||||||
using .utils
|
using .utils
|
||||||
|
|
||||||
include("llmfunction.jl")
|
# include("llmfunction.jl")
|
||||||
using .llmfunction
|
# using .llmfunction
|
||||||
|
|
||||||
include("agentCore.jl")
|
include("agentCore.jl")
|
||||||
using .agentCore
|
using .agentCore
|
||||||
|
|||||||
+13
-13
@@ -3,7 +3,7 @@ module agentCore
|
|||||||
export _agent_loop, OpenAiToUserMessage
|
export _agent_loop, OpenAiToUserMessage
|
||||||
|
|
||||||
using JSON, DataStructures, Dates, UUIDs, HTTP, Random, PrettyPrinting, Serialization,
|
using JSON, DataStructures, Dates, UUIDs, HTTP, Random, PrettyPrinting, Serialization,
|
||||||
DataFrames, Serde
|
DataFrames, Serde, Base.Threads
|
||||||
using GeneralUtils
|
using GeneralUtils
|
||||||
using ..type, ..utils, ..llmfunction
|
using ..type, ..utils, ..llmfunction
|
||||||
|
|
||||||
@@ -34,41 +34,41 @@ julia> # Called automatically by yiemAgent constructor
|
|||||||
"""
|
"""
|
||||||
function _agent_loop(agent::yiemAgent)
|
function _agent_loop(agent::yiemAgent)
|
||||||
try
|
try
|
||||||
processing_task = nothing
|
processingTask = nothing
|
||||||
|
|
||||||
""" cases:
|
""" cases:
|
||||||
1) agent -> idle, user msg -> nothing
|
1) agent -> idle, user msg -> nothing
|
||||||
typeof(processing_task) == Nothing
|
typeof(processingTask) == Nothing
|
||||||
agent._state.activeRun -> false
|
agent._state.activeRun -> false
|
||||||
agent.inputChannel -> nothing
|
agent.inputChannel -> nothing
|
||||||
agent.followUpChannel -> nothing
|
agent.followUpChannel -> nothing
|
||||||
|
|
||||||
2) agent -> idle, user msg -> new msg
|
2) agent -> idle, user msg -> new msg
|
||||||
typeof(processing_task) == Nothing
|
typeof(processingTask) == Nothing
|
||||||
agent._state.activeRun -> false
|
agent._state.activeRun -> false
|
||||||
agent.inputChannel -> new msg
|
agent.inputChannel -> new msg
|
||||||
agent.followUpChannel -> nothing
|
agent.followUpChannel -> nothing
|
||||||
|
|
||||||
3) agent -> running, user msg -> nothing
|
3) agent -> running, user msg -> nothing
|
||||||
typeof(processing_task) == Task, istaskdone(processing_task) -> false
|
typeof(processingTask) == Task, istaskdone(processingTask) -> false
|
||||||
agent._state.activeRun -> true
|
agent._state.activeRun -> true
|
||||||
agent.inputChannel -> nothing
|
agent.inputChannel -> nothing
|
||||||
agent.followUpChannel -> nothing
|
agent.followUpChannel -> nothing
|
||||||
|
|
||||||
4) agent -> running, user msg -> new msg
|
4) agent -> running, user msg -> new msg
|
||||||
typeof(processing_task) == Task, istaskdone(processing_task) -> false
|
typeof(processingTask) == Task, istaskdone(processingTask) -> false
|
||||||
agent._state.activeRun -> true
|
agent._state.activeRun -> true
|
||||||
agent.inputChannel -> new msg
|
agent.inputChannel -> new msg
|
||||||
agent.followUpChannel -> nothing
|
agent.followUpChannel -> nothing
|
||||||
|
|
||||||
5) agent -> running, user msg -> nothing, user msg follow up -> new msg
|
5) agent -> running, user msg -> nothing, user msg follow up -> new msg
|
||||||
typeof(processing_task) == Task, istaskdone(processing_task) -> false
|
typeof(processingTask) == Task, istaskdone(processingTask) -> false
|
||||||
agent._state.activeRun -> true
|
agent._state.activeRun -> true
|
||||||
agent.inputChannel -> nothing
|
agent.inputChannel -> nothing
|
||||||
agent.followUpChannel -> new msg
|
agent.followUpChannel -> new msg
|
||||||
|
|
||||||
6) agent -> idle, user msg -> nothing
|
6) agent -> idle, user msg -> nothing
|
||||||
typeof(processing_task) == Task, istaskdone(processing_task) -> true
|
typeof(processingTask) == Task, istaskdone(processingTask) -> true
|
||||||
agent._state.activeRun -> false
|
agent._state.activeRun -> false
|
||||||
agent.inputChannel -> nothing
|
agent.inputChannel -> nothing
|
||||||
agent.followUpChannel -> nothing
|
agent.followUpChannel -> nothing
|
||||||
@@ -108,12 +108,12 @@ function _agent_loop(agent::yiemAgent)
|
|||||||
# start _process_message loop
|
# start _process_message loop
|
||||||
if agent._state.activeRun == false
|
if agent._state.activeRun == false
|
||||||
# Dispatch message through the processing pipeline
|
# Dispatch message through the processing pipeline
|
||||||
processing_task = @spawn _process_message(agent)
|
processingTask = Threads.@spawn _process_message(agent)
|
||||||
agent._state.activeRun = true
|
agent._state.activeRun = true
|
||||||
end
|
end
|
||||||
|
|
||||||
# during agent runs, check followUp message after _process_message() is done
|
# during agent runs, check followUp message after _process_message() is done
|
||||||
if typeof(processing_task) == Task && istaskdone(processing_task) == false
|
if typeof(processingTask) == Task && istaskdone(processingTask) == false
|
||||||
# if followUp message available, add them all to agent.inputChannel
|
# if followUp message available, add them all to agent.inputChannel
|
||||||
if isready(agent.followUpChannel)
|
if isready(agent.followUpChannel)
|
||||||
while isready(agent.followUpChannel)
|
while isready(agent.followUpChannel)
|
||||||
@@ -123,7 +123,7 @@ function _agent_loop(agent::yiemAgent)
|
|||||||
end
|
end
|
||||||
continue # continue to process user message in the next loop
|
continue # continue to process user message in the next loop
|
||||||
|
|
||||||
elseif typeof(processing_task) == Task && istaskdone(processing_task) == true
|
elseif typeof(processingTask) == Task && istaskdone(processingTask) == true
|
||||||
# if agent runs is done but followUpChannel has messages, discard all message in it.
|
# if agent runs is done but followUpChannel has messages, discard all message in it.
|
||||||
# when agent work is done it should not accept follow up msg.
|
# when agent work is done it should not accept follow up msg.
|
||||||
# user should put new message in inputChannel instead
|
# user should put new message in inputChannel instead
|
||||||
@@ -132,10 +132,10 @@ function _agent_loop(agent::yiemAgent)
|
|||||||
_ = take!(agent.followUpChannel)
|
_ = take!(agent.followUpChannel)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
result = fetch(processing_task)
|
result = fetch(processingTask)
|
||||||
put!(agent.outputChannel, result)
|
put!(agent.outputChannel, result)
|
||||||
agent._state.activeRun = false # reset
|
agent._state.activeRun = false # reset
|
||||||
processing_task = nothing # reset
|
processingTask = nothing # reset
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
catch e
|
catch e
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ end
|
|||||||
struct llmModel # LLM model configuration
|
struct llmModel # LLM model configuration
|
||||||
id::String # Unique model identifier
|
id::String # Unique model identifier
|
||||||
name::String # Human-readable model name
|
name::String # Human-readable model name
|
||||||
api::Api # API type (parametric type)
|
|
||||||
provider::String # Provider name (e.g., "anthropic", "openai")
|
provider::String # Provider name (e.g., "anthropic", "openai")
|
||||||
baseUrl::String # API endpoint base URL
|
baseUrl::String # API endpoint base URL
|
||||||
reasoning::Bool # Whether the model supports chain-of-thought
|
reasoning::Bool # Whether the model supports chain-of-thought
|
||||||
|
|||||||
Reference in New Issue
Block a user