Class: LittleGhost::Providers::OpenAICompatible::ResponsesNormalizer
- Inherits:
-
Normalizer
- Object
- Normalizer
- LittleGhost::Providers::OpenAICompatible::ResponsesNormalizer
- Defined in:
- lib/little_ghost/providers/openai_compatible.rb
Overview
:nodoc:
Instance Method Summary collapse
Methods inherited from Normalizer
Constructor Details
This class inherits a constructor from LittleGhost::Providers::OpenAICompatible::Normalizer
Instance Method Details
#consume(event) ⇒ Object
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 |
# File 'lib/little_ghost/providers/openai_compatible.rb', line 648 def consume(event) type = event["type"] case type when "response.created" response = event.fetch("response") [start_event(response["id"], response["model"])] when "response.output_text.delta" [text_delta(event.fetch("delta"))] when "response.reasoning_text.delta", "response.reasoning_summary_text.delta" [reasoning_delta(event.fetch("delta"))] when "response.output_item.added" item = event.fetch("item") return [] unless item["type"] == "function_call" [tool_start(event.fetch("output_index"), item["call_id"] || item["id"], item["name"])] when "response.function_call_arguments.delta" [tool_delta(event.fetch("output_index"), event.fetch("delta"))] when "response.output_item.done" item = event.fetch("item") return [] unless item["type"] == "function_call" [tool_stop(event.fetch("output_index"), complete_arguments: item["arguments"])] when "response.completed", "response.incomplete" response = event.fetch("response") @message_id ||= response["id"] @model = response["model"] || @model @stop_reason = (type == "response.incomplete") ? :max_tokens : stop_reason(response["status"]) events = [] events << usage_event(responses_usage(response["usage"])) if response["usage"] events << final_event when "response.failed" error = event.dig("response", "error") || {} raise StreamError.from(error, prefix: "Provider stream failed") when "error" error = event["error"] || event raise StreamError.from(error, prefix: "Provider stream error") else [] end end |
#stream_done ⇒ Object
644 645 646 |
# File 'lib/little_ghost/providers/openai_compatible.rb', line 644 def stream_done nil end |