diff --git a/src/interface.jl b/src/interface.jl index c501d58..9ed6500 100755 --- a/src/interface.jl +++ b/src/interface.jl @@ -327,7 +327,8 @@ function conversation(a::T, usermsg::String) where {T<:agent} userintend = identifyUserIntention(a, usermsg) @show userintend if userintend == "chat" #WORKING - + summary = conversationSummary(a) + elseif userintend == "wine" @@ -376,7 +377,7 @@ end """ make a conversation summary. - ```julia + ```jldoctest julia> conversation = [ Dict(:role=> "user", :content=> "I would like to get a bottle of wine", :timestamp=> Dates.now()), Dict(:role=> "assistant", :content=> "What kind of Thai dishes are you having?", :timestamp=> Dates.now()), @@ -396,7 +397,7 @@ end Both wines are suitable for serving at 22 C temperature.", :timestamp=> Dates.now()), ] - julia> summary = conversationSummary() + julia> summary = conversationSummary(conversation) ``` """ function conversationSummary(a::T) where {T<:agent} @@ -518,79 +519,6 @@ function workContinue(a::agent) end -# function identifyUserIntention(a::T, usermsg::String) where {T<:agent} -# prompt = -# """ -# <|im_start|>system -# You are a helpful assistant. Your job is to determine intention of the question. -# Your choices are: -# chat: normal conversation that you don't need to do something. -# task: a request for you to do something. - -# Here are examples of how to determine intention of the question: -# Question: How are you? -# Answer: {chat}, this question intention is about chat. - -# Question: Ummm. -# Answer: {chat}, this question is about chat. - -# Question: Search for the stock prices of 'BJC' and 'IOU'on June 10th. -# Answer: {task}, this question is about asking you to do something. - -# Question: Hello -# Answer: {chat}, this question is about chat. - -# Question: 'BJC' and 'IOU'on June 10th. -# Answer: {task}, this question is about asking you to do something. - -# Question: What time is it? -# Answer: {task}, this question is about asking you to do something. - -# Question: What is the price of 'ABC' -# Answer: {task}, this question is about asking you to do something. - -# Question: Do you like coconut? -# Answer: {task}, this question is about asking you to do something. - -# Question: What is the weather tomorrow? -# Answer: {task}, this question is about asking you to do something. - -# Question: I'm fine. -# Answer: {chat}, this question is about chat. - -# Question: How to make a cake? -# Answer: {task}, this question is about asking you to do something. - -# Question: Did you turn off the light? -# Answer: {task}, this question is about asking you to do something. - -# Question: What is stock price of Tesla on June 6th? -# Answer: {task}, this question is about asking you to do something. - -# Question: Tell me some jokes. -# Answer: {chat}, this question is about chat. - -# Begin! - -# Here are the context for the question: -# {context} - -# <|im_end|> - -# <|im_start|>user -# Question: {input} -# <|im_end|> -# <|im_start|>assistant - -# """ - -# prompt = replace(prompt, "{input}" => usermsg) -# result = sendReceivePrompt(a, prompt) -# answer = result === nothing ? nothing : GeneralUtils.getStringBetweenCharacters(result, "{", "}") - -# return answer -# end - function identifyUserIntention(a::T, usermsg::String) where {T<:agent} prompt = """ @@ -615,11 +543,10 @@ function identifyUserIntention(a::T, usermsg::String) where {T<:agent} prompt = replace(prompt, "{input}" => usermsg) prompt = replace(prompt, "{earlier thought}" => a.thought) prompt = replace(prompt, "{context}" => "") - @show prompt + result = sendReceivePrompt(a, prompt) answer = result === nothing ? nothing : GeneralUtils.getStringBetweenCharacters(result, "{", "}") - @show answer - error("indentifyUserIntention done") + return answer end