Class: LLMs::Parsers::OpenAICompatibleChatResponseStreamParser
- Inherits:
-
SSEChatResponseStreamParser
- Object
- SSEChatResponseStreamParser
- LLMs::Parsers::OpenAICompatibleChatResponseStreamParser
- Defined in:
- lib/llms/parsers/open_ai_compatible_chat_response_stream_parser.rb
Instance Method Summary collapse
Methods inherited from SSEChatResponseStreamParser
Methods included from PartialJsonParser
Constructor Details
This class inherits a constructor from LLMs::Parsers::SSEChatResponseStreamParser
Instance Method Details
#full_response ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/llms/parsers/open_ai_compatible_chat_response_stream_parser.rb', line 8 def full_response # to match the format for non-streamed responses, all tool call arguments # must be serialized back to a JSON string converted_choices = @choices.map do |c| dup_c = c.dup dup_c['tool_calls']&.each do |tc| tc['function']['arguments'] = JSON.dump(tc['function']['arguments']) end dup_c end { 'id' => @id, 'model' => @model, # TODO I think this should be converted_choices, but providers are inconsistent in their response formats - switch to this after more testing 'choices' => @choices, #converted_choices, 'usage' => @usage, 'created' => @created } end |