update
This commit is contained in:
@@ -2,7 +2,8 @@ module interface
|
||||
|
||||
|
||||
export agentReact, addNewMessage, clearMessage, removeLatestMsg, generatePrompt_tokenPrefix,
|
||||
generatePrompt_tokenSuffix, conversation, work, detectCharacters, chunktext
|
||||
generatePrompt_tokenSuffix, conversation, work, detectCharacters, chunktext,
|
||||
findDetectedCharacter
|
||||
|
||||
using JSON3, DataStructures, Dates, UUIDs
|
||||
using CommUtils, GeneralUtils
|
||||
@@ -130,6 +131,12 @@ function agentReact(
|
||||
:input => "Input should be a search query with as much details as possible.",
|
||||
:output => "" ,
|
||||
),
|
||||
:nothing=>Dict(
|
||||
:name => "nothing",
|
||||
:description => "useful for when you don't need to use tools or actions",
|
||||
:input => "No input is needed",
|
||||
:output => "" ,
|
||||
),
|
||||
),
|
||||
msgMeta::Dict=Dict(
|
||||
:msgPurpose=> "updateStatus",
|
||||
@@ -359,7 +366,7 @@ function generatePrompt_react_mistral_openorca(a::T, usermsg::String,
|
||||
return prompt
|
||||
end
|
||||
|
||||
#WORKING
|
||||
|
||||
function conversation(a::T, usermsg::String) where {T<:agent}
|
||||
userintend = identifyUserIntention(a, usermsg)
|
||||
@show userintend
|
||||
@@ -367,7 +374,7 @@ function conversation(a::T, usermsg::String) where {T<:agent}
|
||||
|
||||
# AI thinking mode
|
||||
if userintend == "chat"
|
||||
a.context = conversationSummary(a) #BUG should be long conversation before use summary because it leaves out details
|
||||
a.context = conversationSummary(a) #TODO should be long conversation before use summary because it leaves out details
|
||||
_ = addNewMessage(a, "user", usermsg)
|
||||
prompt = generatePrompt_mistral_openorca(a, usermsg)
|
||||
@show prompt
|
||||
@@ -421,7 +428,7 @@ function conversation(a::T, usermsg::String) where {T<:agent}
|
||||
return respond
|
||||
end
|
||||
|
||||
#WORKING
|
||||
|
||||
function work(a::T, prompt::String) where {T<:agent}
|
||||
respond = nothing
|
||||
while true
|
||||
@@ -430,10 +437,14 @@ function work(a::T, prompt::String) where {T<:agent}
|
||||
|
||||
respond = sendReceivePrompt(a, prompt)
|
||||
@show respond
|
||||
try
|
||||
respond = split(respond, "Obs:")[1]
|
||||
catch
|
||||
end
|
||||
|
||||
headers = detectCharacters(respond,
|
||||
["QTS:", "Plan:", "Thought:", "Act:", "ActInput:", "Obs:", ".....", "ANS:"])
|
||||
@show headers
|
||||
respond = split(respond, "Obs:")[1]
|
||||
chunkedtext = chunktext(respond, headers)
|
||||
@show chunkedtext
|
||||
|
||||
@@ -443,9 +454,8 @@ function work(a::T, prompt::String) where {T<:agent}
|
||||
break
|
||||
else
|
||||
# check for tool being called
|
||||
ActInd = findDetectedCharacter(headers, "Act:")
|
||||
println(">>> ", chunkedtext[ActInd][:body])
|
||||
# toolname = toolNameBeingCalled(chunkedtext[ActInd][:body])
|
||||
ActInd = findDetectedCharacter(headers, "Act:")[1]
|
||||
toolname = toolNameBeingCalled(chunkedtext[ActInd][:body], ) #WORKING
|
||||
|
||||
# function call
|
||||
|
||||
|
||||
Reference in New Issue
Block a user