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
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 |
# File 'lib/little_ghost/providers/openai_compatible.rb', line 575 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
571 572 573 |
# File 'lib/little_ghost/providers/openai_compatible.rb', line 571 def stream_done nil end |