diff --git a/src/YiemAgent.jl b/src/YiemAgent.jl index e021f3c..764574c 100644 --- a/src/YiemAgent.jl +++ b/src/YiemAgent.jl @@ -13,8 +13,8 @@ module YiemAgent include("utils.jl") using .utils - include("llmfunction.jl") - using .llmfunction + # include("llmfunction.jl") + # using .llmfunction include("agentCore.jl") using .agentCore diff --git a/src/agentCore.jl b/src/agentCore.jl index 7031295..6b96c57 100644 --- a/src/agentCore.jl +++ b/src/agentCore.jl @@ -3,7 +3,7 @@ module agentCore export _agent_loop, OpenAiToUserMessage using JSON, DataStructures, Dates, UUIDs, HTTP, Random, PrettyPrinting, Serialization, - DataFrames, Serde + DataFrames, Serde, Base.Threads using GeneralUtils using ..type, ..utils, ..llmfunction @@ -34,41 +34,41 @@ julia> # Called automatically by yiemAgent constructor """ function _agent_loop(agent::yiemAgent) try - processing_task = nothing + processingTask = nothing """ cases: 1) agent -> idle, user msg -> nothing - typeof(processing_task) == Nothing + typeof(processingTask) == Nothing agent._state.activeRun -> false agent.inputChannel -> nothing agent.followUpChannel -> nothing 2) agent -> idle, user msg -> new msg - typeof(processing_task) == Nothing + typeof(processingTask) == Nothing agent._state.activeRun -> false agent.inputChannel -> new msg agent.followUpChannel -> 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.inputChannel -> nothing agent.followUpChannel -> nothing 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.inputChannel -> new msg agent.followUpChannel -> nothing 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.inputChannel -> nothing agent.followUpChannel -> new msg 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.inputChannel -> nothing agent.followUpChannel -> nothing @@ -108,12 +108,12 @@ function _agent_loop(agent::yiemAgent) # start _process_message loop if agent._state.activeRun == false # Dispatch message through the processing pipeline - processing_task = @spawn _process_message(agent) + processingTask = Threads.@spawn _process_message(agent) agent._state.activeRun = true end # 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 isready(agent.followUpChannel) while isready(agent.followUpChannel) @@ -123,7 +123,7 @@ function _agent_loop(agent::yiemAgent) end 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. # when agent work is done it should not accept follow up msg. # user should put new message in inputChannel instead @@ -132,10 +132,10 @@ function _agent_loop(agent::yiemAgent) _ = take!(agent.followUpChannel) end end - result = fetch(processing_task) + result = fetch(processingTask) put!(agent.outputChannel, result) agent._state.activeRun = false # reset - processing_task = nothing # reset + processingTask = nothing # reset end end catch e diff --git a/src/type.jl b/src/type.jl index e659ca1..c803289 100644 --- a/src/type.jl +++ b/src/type.jl @@ -22,7 +22,6 @@ end struct llmModel # LLM model configuration id::String # Unique model identifier name::String # Human-readable model name - api::Api # API type (parametric type) provider::String # Provider name (e.g., "anthropic", "openai") baseUrl::String # API endpoint base URL reasoning::Bool # Whether the model supports chain-of-thought