Class: Luo::AIUI
Constant Summary collapse
- PARAMS =
Dry::Schema.Params do required(:appid).filled(:string) required(:appkey).filled(:string) required(:uid).filled(:string) required(:text).filled(:string) end
Instance Method Summary collapse
Methods included from Configurable
Instance Method Details
#chat(messages, temperature: nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/luo/aiui.rb', line 26 def chat(, temperature: nil) if .is_a?(Messages) = .to_a end = .last&.fetch(:content, nil) params = PARAMS.call( appid: config.id, appkey: config.key, uid: config.uid.call, text: ) return params.errors unless params.success? request_aiui(params).body.dig("data", 0, "intent", "answer") end |
#request_aiui(params) ⇒ Object
22 23 24 |
# File 'lib/luo/aiui.rb', line 22 def request_aiui(params) client.post('/external/ls_log/aiui_request', params.to_h) end |