(data string, binary bool)
| 771 | } |
| 772 | |
| 773 | func (s *responseSink) writeRaw(data string, binary bool) error { |
| 774 | s.exchange.mu.Lock() |
| 775 | started := s.exchange.started |
| 776 | finished := s.exchange.finished |
| 777 | s.exchange.mu.Unlock() |
| 778 | if !started { |
| 779 | return fmt.Errorf("CopilotRequestHandler response sink Write() called before Start()") |
| 780 | } |
| 781 | if finished { |
| 782 | return fmt.Errorf("CopilotRequestHandler response sink Write() called after End()/Error()") |
| 783 | } |
| 784 | api, err := s.rpcAPI() |
| 785 | if err != nil { |
| 786 | return err |
| 787 | } |
| 788 | end := false |
| 789 | chunk := &rpc.LlmInferenceHTTPResponseChunkRequest{ |
| 790 | RequestID: s.requestID, |
| 791 | Data: data, |
| 792 | End: &end, |
| 793 | } |
| 794 | if binary { |
| 795 | b := true |
| 796 | chunk.Binary = &b |
| 797 | } |
| 798 | _, err = api.HttpResponseChunk(context.Background(), chunk) |
| 799 | return err |
| 800 | } |
| 801 | |
| 802 | func (s *responseSink) end() error { |
| 803 | s.exchange.mu.Lock() |
no test coverage detected