REPL.outstream(repl) # ↑注目 contents = sprint() do io create_chat( OPENAI_API_KEY[], string(model), [Dict("role"=>"user", "content"=>line)]; streamcallback=let function (chunk) for line in split(chunk, '\n') line = strip(line) isempty(line) && continue if line != "data: [DONE]" chunk_obj = JSON3.read(line[6:end]) delta = chunk_obj.choices[1].delta if haskey(delta, :content) print(repl_out, delta.content) print(io, delta.content) end end end end end ) end println(repl_out) # 最後に改行を出力 _parse_lines(model, contents, REPL.repl_filename(repl, hp)) end
: 《中略》 struct TextDavinciAPIModel <: APIModel name::String end function APIModel(::Val{Symbol("text-davinci-003")}, name::AbstractString) TextDavinciAPIModel(name) end function chat_on_done(model::TextDavinciAPIModel, repl, hp, line) # : 《略》 end # : 《中略》 end