update
This commit is contained in:
94
src/utils.jl
94
src/utils.jl
@@ -363,12 +363,19 @@ end
|
||||
|
||||
# return thinkingmode
|
||||
# end
|
||||
#WORKING
|
||||
|
||||
|
||||
|
||||
""" Determine from a user message whether an assistant need to use tools.
|
||||
|
||||
Arguments:
|
||||
a, one of ChatAgent's agent.
|
||||
|
||||
Return:
|
||||
1. true/false # is LLM going to use tools
|
||||
2. objective # what LLM going to do
|
||||
"""
|
||||
function isUseTools(a::agentReflex)
|
||||
|
||||
# response = chat_mistral_openorca(a)
|
||||
|
||||
toollines = ""
|
||||
for (toolname, v) in a.tools
|
||||
if toolname ∉ ["chatbox"]
|
||||
@@ -396,81 +403,16 @@ function isUseTools(a::agentReflex)
|
||||
|
||||
# if LLM mentions any tools, use Plan/Thought/Act loop
|
||||
isusetool = false
|
||||
result = sendReceivePrompt(a, prompt, temperature=0.2)
|
||||
objective = sendReceivePrompt(a, prompt, temperature=0.2)
|
||||
for (toolname, v) in a.tools
|
||||
if occursin(toolname, result)
|
||||
if occursin(toolname, objective)
|
||||
isusetool = true
|
||||
break
|
||||
end
|
||||
end
|
||||
@show result
|
||||
plan = "N/A"
|
||||
if isusetool
|
||||
# toollines = ""
|
||||
# for (toolname, v) in a.tools
|
||||
# if toolname ∉ [""]
|
||||
# toolline = "$toolname: $(v[:description]) $(v[:input]) $(v[:output])\n"
|
||||
# toollines *= toolline
|
||||
# end
|
||||
# end
|
||||
# assistant_objective_prompt =
|
||||
# """
|
||||
# <|im_start|>system
|
||||
# $(a.roles[a.role])
|
||||
# The info you need from the user to be able to help them selecting their best wine:
|
||||
# - type of food
|
||||
# - occasion
|
||||
# - user's personal taste of wine
|
||||
# - wine price range
|
||||
# - ambient temperature at the serving location
|
||||
# - wines we have in stock
|
||||
# You provide a personalized recommendation of up to two wines based on the user's info above, and you describe the benefits of each wine in detail.
|
||||
|
||||
# You have access to the following tools:
|
||||
# $toollines
|
||||
|
||||
# Your conversation with the user:
|
||||
# $conversation
|
||||
|
||||
# Use the following format:
|
||||
# Objective: From your conversation with the user, ask yourself what do you need to do now?
|
||||
# <|im_end|>
|
||||
|
||||
# """
|
||||
# result_objective = sendReceivePrompt(a, assistant_objective_prompt, temperature=0.2)
|
||||
# @show result_objective
|
||||
|
||||
assistant_plan_prompt =
|
||||
"""
|
||||
<|im_start|>system
|
||||
$(a.roles[a.role])
|
||||
The info you need from the user to be able to help them selecting their best wine:
|
||||
- type of food
|
||||
- occasion
|
||||
- user's personal taste of wine
|
||||
- wine price range
|
||||
- ambient temperature at the serving location
|
||||
- wines we have in stock
|
||||
You provide a personalized recommendation of up to two wines based on the user's info above, and you describe the benefits of each wine in detail.
|
||||
|
||||
You have access to the following tools:
|
||||
$toollines
|
||||
|
||||
Use the following format:
|
||||
Objective: the objective you intend to do
|
||||
Plan: first you should always think about the objective, the info you need and the info you have thoroughly then extract and devise a step by step plan (pay attention to correct numeral calculation and commonsense).
|
||||
p.s.1 each step should be a single action.
|
||||
p.s.2 don't respond to the stimulus yet.
|
||||
<|im_end|>
|
||||
<|im_start|>assistant
|
||||
Objective: $result
|
||||
Plan:
|
||||
"""
|
||||
plan = sendReceivePrompt(a, assistant_plan_prompt, temperature=0.2)
|
||||
@show plan
|
||||
end
|
||||
|
||||
return isusetool, plan
|
||||
@show objective
|
||||
|
||||
return isusetool, objective
|
||||
end
|
||||
|
||||
|
||||
@@ -650,7 +592,7 @@ julia> agent.messages = [Dict(:role=> "user", :content=> "Hi there."),
|
||||
julia> messagesToString(agent.messages)
|
||||
"<|im_start|>user: Hi there.\n<|im_end|><|im_start|>assistant: Hello! How can I assist you today?\n<|im_end|>"
|
||||
```
|
||||
""" #WORKING
|
||||
"""
|
||||
function messagesToString(messages::AbstractVector{T}; addressAIas="assistant") where {T<:AbstractDict}
|
||||
conversation = ""
|
||||
if length(messages)!= 0
|
||||
@@ -681,7 +623,7 @@ function messagesToString(messages::AbstractVector{T}; addressAIas="assistant")
|
||||
|
||||
return conversation
|
||||
end
|
||||
#WORKING
|
||||
|
||||
function messagesToString_nomark(messages::AbstractVector{T}; addressAIas="assistant") where {T<:AbstractDict}
|
||||
conversation = ""
|
||||
if length(messages)!= 0
|
||||
|
||||
Reference in New Issue
Block a user