update
This commit is contained in:
206
src/interface.jl
206
src/interface.jl
@@ -33,6 +33,17 @@ using ..type, ..util, ..llmfunction, ..mcts
|
||||
# ---------------------------------------------- 100 --------------------------------------------- #
|
||||
|
||||
|
||||
macro executeStringFunction(functionStr, args...)
|
||||
# Parse the function string into an expression
|
||||
func_expr = Meta.parse(functionStr)
|
||||
|
||||
# Create a new function with the parsed expression
|
||||
function_to_call = eval(Expr(:function, Expr(:call, func_expr, args...), func_expr.args[2:end]...))
|
||||
|
||||
# Call the newly created function with the provided arguments
|
||||
function_to_call(args...)
|
||||
end
|
||||
|
||||
""" Think and choose action
|
||||
|
||||
# Arguments
|
||||
@@ -97,9 +108,9 @@ function decisionMaker(a::T1, state::T2)::String where {T1<:agent, T2<:AbstractD
|
||||
|
||||
You should only respond with interleaving step-by-step Thought, Action, Observation steps.
|
||||
Thought can reason about the current situation, and Action can be three types:
|
||||
1) Chatbox[text], which you can use to interact with the user.
|
||||
2) Winestock[query], which you can use to find wine in your inventory.
|
||||
3) Finish[answer], which returns your wine reccommendation to the user.
|
||||
1) winestock[query], which you can use to find wine in your inventory.
|
||||
2) chatbox[text], which you can use to interact with the user.
|
||||
3) finish[answer], which returns your wine reccommendation to the user.
|
||||
|
||||
You should only respond in JSON format as describe below:
|
||||
{
|
||||
@@ -115,15 +126,15 @@ function decisionMaker(a::T1, state::T2)::String where {T1<:agent, T2<:AbstractD
|
||||
{
|
||||
"Question": "I would like to buy a sedan.",
|
||||
"Thought_1": "I have many cars in my inventory suitable for several usage scenarios.",
|
||||
"Thought_2": "It would be better if I knew what the user intends to do with his car."1,
|
||||
"Thought_2": "It would be better if I knew what the user intends to do with his car.",
|
||||
"Thought_3": "I will ask the user what is the intended usecase",
|
||||
"Action_1": {"action": "Chatbox", "input": "What will you use it for?"}
|
||||
"Action_1": {"action": "chatbox", "input": "What will you use it for?"}
|
||||
}
|
||||
{
|
||||
"Question": "I'm looking for a sedan.",
|
||||
"Thought_1": "I have many types of sedans in my inventory, each with diverse features.",
|
||||
"Thought_2": "It would be easier to make a recommendation if I knew what feature the user is looking for. I should ask the user.",
|
||||
"Action_1": {"action": "Chatbox", "input": "Do you have any specific feature in mind?"}
|
||||
"Action_1": {"action": "chatbox", "input": "Do you have any specific feature in mind?"}
|
||||
}
|
||||
|
||||
$reflect
|
||||
@@ -157,25 +168,20 @@ end
|
||||
|
||||
"""
|
||||
|
||||
Arguments\n
|
||||
-----
|
||||
|
||||
Return\n
|
||||
-----
|
||||
# Arguments
|
||||
|
||||
# Return
|
||||
|
||||
Example\n
|
||||
-----
|
||||
```jldoctest
|
||||
julia>
|
||||
```
|
||||
# Example
|
||||
```jldoctest
|
||||
julia>
|
||||
```
|
||||
|
||||
TODO\n
|
||||
-----
|
||||
[] update docstring
|
||||
[] implement the function
|
||||
# TODO
|
||||
- [] update docstring
|
||||
- [] implement the function
|
||||
|
||||
Signature\n
|
||||
-----
|
||||
# Signature
|
||||
"""
|
||||
function stateValueEstimator()
|
||||
|
||||
@@ -184,25 +190,20 @@ end
|
||||
|
||||
"""
|
||||
|
||||
Arguments\n
|
||||
-----
|
||||
|
||||
Return\n
|
||||
-----
|
||||
# Arguments
|
||||
|
||||
# Return
|
||||
|
||||
Example\n
|
||||
-----
|
||||
```jldoctest
|
||||
julia>
|
||||
```
|
||||
# Example
|
||||
```jldoctest
|
||||
julia>
|
||||
```
|
||||
|
||||
TODO\n
|
||||
-----
|
||||
[] update docstring
|
||||
[] implement the function
|
||||
# TODO
|
||||
- [] update docstring
|
||||
- [] implement the function
|
||||
|
||||
Signature\n
|
||||
-----
|
||||
# Signature
|
||||
"""
|
||||
function reflector()
|
||||
|
||||
@@ -211,91 +212,80 @@ end
|
||||
|
||||
"""
|
||||
|
||||
Arguments\n
|
||||
-----
|
||||
|
||||
Return\n
|
||||
-----
|
||||
# Arguments
|
||||
|
||||
# Return
|
||||
|
||||
Example\n
|
||||
-----
|
||||
```jldoctest
|
||||
julia>
|
||||
```
|
||||
# Example
|
||||
```jldoctest
|
||||
julia>
|
||||
```
|
||||
|
||||
TODO\n
|
||||
-----
|
||||
[] update docstring
|
||||
[] implement the function
|
||||
[] implement RAG to pull similar experience
|
||||
# TODO
|
||||
- [] update docstring
|
||||
- [] implement the function
|
||||
|
||||
Signature\n
|
||||
-----
|
||||
# Signature
|
||||
"""
|
||||
function isterminal()
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
""" Chat with llm.
|
||||
|
||||
Arguments\n
|
||||
-----
|
||||
a::agent
|
||||
an agent
|
||||
|
||||
Return\n
|
||||
-----
|
||||
None
|
||||
# Arguments
|
||||
`a::agent`
|
||||
an agent
|
||||
|
||||
# Return
|
||||
None
|
||||
|
||||
Example\n
|
||||
-----
|
||||
```jldoctest
|
||||
julia> using JSON3, UUIDs, Dates, FileIO, MQTTClient, ChatAgent
|
||||
julia> const mqttBroker = "mqtt.yiem.cc"
|
||||
julia> mqttclient, connection = MakeConnection(mqttBroker, 1883)
|
||||
julia> tools=Dict( # update input format
|
||||
"askbox"=>Dict(
|
||||
:description => "<askbox tool description>Useful for when you need to ask the user for more context. Do not ask the user their own question.</askbox tool description>",
|
||||
:input => "<input>Input is a text in JSON format.</input><input example>{\"Q1\": \"How are you doing?\", \"Q2\": \"How may I help you?\"}</input example>",
|
||||
:output => "" ,
|
||||
:func => nothing,
|
||||
),
|
||||
)
|
||||
julia> msgMeta = Dict(
|
||||
:msgPurpose=> "updateStatus",
|
||||
:from=> "agent",
|
||||
:to=> "llmAI",
|
||||
:requestresponse=> "request",
|
||||
:sendto=> "", # destination topic
|
||||
:replyTo=> "agent/api/v0.1.0/txt/response", # requester ask responseer to send reply to this topic
|
||||
:repondToMsgId=> "", # responseer is responseing to this msg id
|
||||
:taskstatus=> "", # "complete", "fail", "waiting" or other status
|
||||
:timestamp=> Dates.now(),
|
||||
:msgId=> "$(uuid4())",
|
||||
)
|
||||
julia> a = ChatAgent.agentReflex(
|
||||
"Jene",
|
||||
mqttclient,
|
||||
msgMeta,
|
||||
agentConfigTopic, # I need a function to send msg to config topic to get load balancer
|
||||
role=:sommelier,
|
||||
tools=tools
|
||||
)
|
||||
julia> newAgent = ChatAgent.agentReact(agent)
|
||||
julia> response = ChatAgent.conversation(newAgent, "Hi! how are you?")
|
||||
```
|
||||
# Example
|
||||
```jldoctest
|
||||
julia> using JSON3, UUIDs, Dates, FileIO, MQTTClient, ChatAgent
|
||||
julia> const mqttBroker = "mqtt.yiem.cc"
|
||||
julia> mqttclient, connection = MakeConnection(mqttBroker, 1883)
|
||||
julia> tools=Dict( # update input format
|
||||
"askbox"=>Dict(
|
||||
:description => "<askbox tool description>Useful for when you need to ask the user for more context. Do not ask the user their own question.</askbox tool description>",
|
||||
:input => "<input>Input is a text in JSON format.</input><input example>{\"Q1\": \"How are you doing?\", \"Q2\": \"How may I help you?\"}</input example>",
|
||||
:output => "" ,
|
||||
:func => nothing,
|
||||
),
|
||||
)
|
||||
julia> msgMeta = Dict(
|
||||
:msgPurpose=> "updateStatus",
|
||||
:from=> "agent",
|
||||
:to=> "llmAI",
|
||||
:requestresponse=> "request",
|
||||
:sendto=> "", # destination topic
|
||||
:replyTo=> "agent/api/v0.1.0/txt/response", # requester ask responseer to send reply to this topic
|
||||
:repondToMsgId=> "", # responseer is responseing to this msg id
|
||||
:taskstatus=> "", # "complete", "fail", "waiting" or other status
|
||||
:timestamp=> Dates.now(),
|
||||
:msgId=> "$(uuid4())",
|
||||
)
|
||||
julia> a = ChatAgent.agentReflex(
|
||||
"Jene",
|
||||
mqttclient,
|
||||
msgMeta,
|
||||
agentConfigTopic, # I need a function to send msg to config topic to get load balancer
|
||||
role=:sommelier,
|
||||
tools=tools
|
||||
)
|
||||
julia> newAgent = ChatAgent.agentReact(agent)
|
||||
julia> response = ChatAgent.conversation(newAgent, "Hi! how are you?")
|
||||
```
|
||||
|
||||
Signature\n
|
||||
-----
|
||||
# TODO
|
||||
- [] update docstring
|
||||
- [PENDING] MCTS() for planning
|
||||
|
||||
# Signature
|
||||
"""
|
||||
function conversation(a::T, userinput::Dict) where {T<:agent}
|
||||
"""
|
||||
[] update document
|
||||
[PENDING] MCTS() for planning
|
||||
"""
|
||||
|
||||
# "newtopic" command to delete chat history
|
||||
if userinput[:text] == "newtopic"
|
||||
clearhistory(a)
|
||||
|
||||
Reference in New Issue
Block a user