-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make StreamableQuery symmetrically convert ChatQuery objects to non-s…
…treamable mode on the fly
- Loading branch information
James J Kalafus
committed
Feb 4, 2024
1 parent
27ad53b
commit 04ff962
Showing
2 changed files
with
19 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 17 additions & 5 deletions
22
...penAI/Public/Models/StreamableQuery.swift → ...AI/Public/Protocols/StreamableQuery.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,36 @@ | ||
// | ||
// File.swift | ||
// | ||
// Streamable.swift | ||
// | ||
// | ||
// Created by Sergii Kryvoblotskyi on 15/05/2023. | ||
// | ||
|
||
import Foundation | ||
|
||
protocol Streamable { | ||
|
||
var stream: Bool { get set } | ||
func makeStreamable() -> Self | ||
func makeNonStreamable() -> Self | ||
} | ||
|
||
extension Streamable { | ||
|
||
func makeStreamable() -> Self { | ||
guard !stream else { | ||
return self | ||
} | ||
var copy = self | ||
copy.stream = true | ||
return copy | ||
} | ||
|
||
func makeNonStreamable() -> Self { | ||
guard stream else { | ||
return self | ||
} | ||
var copy = self | ||
copy.stream = false | ||
return copy | ||
} | ||
} | ||
|