This commit is contained in:
narawat lamaiin
2024-06-01 08:18:09 +07:00
parent 97c566a9d5
commit 1c863cd8ca
2 changed files with 123 additions and 119 deletions

View File

@@ -3,7 +3,7 @@ module llmfunction
export virtualWineUserChatbox, jsoncorrection, winestock,
virtualWineUserRecommendbox, userChatbox, userRecommendbox
using HTTP, JSON3, URIs, Random, PrettyPrinting
using HTTP, JSON3, URIs, Random, PrettyPrinting, UUIDs
using GeneralUtils
using ..type, ..util
@@ -168,8 +168,8 @@ julia>
# Signature
"""
function virtualWineUserChatbox(a::T1, input::T2, virtualCustomerChatHistory
)::Union{Tuple{String, Number, Number, Bool}, Tuple{String, Nothing, Number, Bool}} where {T1<:agent, T2<:AbstractString}
function virtualWineUserChatbox(config::T1, input::T2, virtualCustomerChatHistory
)::Union{Tuple{String, Number, Number, Bool}, Tuple{String, Nothing, Number, Bool}} where {T1<:AbstractDict, T2<:AbstractString}
previouswines =
"""
@@ -275,16 +275,16 @@ function virtualWineUserChatbox(a::T1, input::T2, virtualCustomerChatHistory
"""
pprint(prompt)
externalService = a.config[:externalservice][:text2textinstruct]
externalService = config[:externalservice][:text2textinstruct]
# send formatted input to user using GeneralUtils.sendReceiveMqttMsg
msgMeta = GeneralUtils.generate_msgMeta(
externalService[:mqtttopic],
senderName= "virtualWineUserChatbox",
senderId= a.id,
senderId= string(uuid4()),
receiverName= "text2textinstruct",
mqttBroker= a.config[:mqttServerInfo][:broker],
mqttBrokerPort= a.config[:mqttServerInfo][:port],
mqttBroker= config[:mqttServerInfo][:broker],
mqttBrokerPort= config[:mqttServerInfo][:port],
msgId = "dummyid" #CHANGE remove after testing finished
)
@@ -310,7 +310,7 @@ function virtualWineUserChatbox(a::T1, input::T2, virtualCustomerChatHistory
"isterminal": "..."
}
"""
responseJsonStr = jsoncorrection(a, _responseJsonStr, expectedJsonExample)
responseJsonStr = jsoncorrection(config, _responseJsonStr, expectedJsonExample)
responseDict = copy(JSON3.read(responseJsonStr))
text::AbstractString = responseDict[:text]
@@ -362,8 +362,8 @@ julia> result = winestock(agent, input)
# Signature
"""
function winestock(a::T1, input::T2
)::Union{Tuple{String, Number, Number, Bool}, Tuple{String, Nothing, Number, Bool}} where {T1<:agent, T2<:AbstractString}
function winestock(config::T1, input::T2
)::Union{Tuple{String, Number, Number, Bool}, Tuple{String, Nothing, Number, Bool}} where {T1<:AbstractDict, T2<:AbstractString}
# SELECT *
# FROM food
@@ -469,16 +469,16 @@ function winestock(a::T1, input::T2
"""
pprint(prompt)
externalService = a.config[:externalservice][:text2textinstruct]
externalService = config[:externalservice][:text2textinstruct]
# send formatted input to user using GeneralUtils.sendReceiveMqttMsg
msgMeta = GeneralUtils.generate_msgMeta(
externalService[:mqtttopic],
senderName= "virtualWineUserChatbox",
senderId= a.id,
senderId= string(uuid4()),
receiverName= "text2textinstruct",
mqttBroker= a.config[:mqttServerInfo][:broker],
mqttBrokerPort= a.config[:mqttServerInfo][:port],
mqttBroker= config[:mqttServerInfo][:broker],
mqttBrokerPort= config[:mqttServerInfo][:port],
msgId = "dummyid" #CHANGE remove after testing finished
)
@@ -505,7 +505,7 @@ function winestock(a::T1, input::T2
}
}
"""
responseJsonStr = jsoncorrection(a, _responseJsonStr, expectedJsonExample)
responseJsonStr = jsoncorrection(config, _responseJsonStr, expectedJsonExample)
_responseDict = copy(JSON3.read(responseJsonStr))
responseDict = _responseDict[:attributes]
@@ -559,8 +559,8 @@ function winestock(a::T1, input::T2
# return result, nothing, 0, false
end
function wineattributes_wordToNumber(a::T1, input::T2
)::Dict where {T1<:agent, T2<:AbstractString}
function wineattributes_wordToNumber(config::T1, input::T2
)::Dict where {T1<:AbstractDict, T2<:AbstractString}
systemmsg =
"""
@@ -656,16 +656,16 @@ function wineattributes_wordToNumber(a::T1, input::T2
"""
pprint(prompt)
externalService = a.config[:externalservice][:text2textinstruct]
externalService = config[:externalservice][:text2textinstruct]
# send formatted input to user using GeneralUtils.sendReceiveMqttMsg
msgMeta = GeneralUtils.generate_msgMeta(
externalService[:mqtttopic],
senderName= "wineattributes_wordToNumber",
senderId= a.id,
senderId= string(uuid4()),
receiverName= "text2textinstruct",
mqttBroker= a.config[:mqttServerInfo][:broker],
mqttBrokerPort= a.config[:mqttServerInfo][:port],
mqttBroker= config[:mqttServerInfo][:broker],
mqttBrokerPort= config[:mqttServerInfo][:port],
)
outgoingMsg = Dict(
@@ -691,7 +691,7 @@ function wineattributes_wordToNumber(a::T1, input::T2
}
}
"""
responseJsonStr = jsoncorrection(a, _responseJsonStr, expectedJsonExample)
responseJsonStr = jsoncorrection(config, _responseJsonStr, expectedJsonExample)
_responseDict = copy(JSON3.read(responseJsonStr))
responseDict = _responseDict[:attributes]