File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Core/Sources/PromptToCodeService Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ final class OpenAIPromptToCodeAPI: PromptToCodeAPI {
6262
6363 # Code
6464
65- ```
65+ ``` \( language . rawValue )
6666 \( code)
6767 ```
6868 """
@@ -75,10 +75,16 @@ final class OpenAIPromptToCodeAPI: PromptToCodeAPI {
7575 return . init { continuation in
7676 Task {
7777 var content = " "
78+ var extracted = extractCodeAndDescription ( from: content)
7879 do {
7980 for try await fragment in stream {
8081 content. append ( fragment)
81- continuation. yield ( extractCodeAndDescription ( from: content) )
82+ extracted = extractCodeAndDescription ( from: content)
83+ if !content. isEmpty, extracted. code. isEmpty {
84+ continuation. yield ( ( code: content, description: " " ) )
85+ } else {
86+ continuation. yield ( extracted)
87+ }
8288 }
8389 continuation. finish ( )
8490 } catch {
@@ -134,3 +140,4 @@ final class OpenAIPromptToCodeAPI: PromptToCodeAPI {
134140 return ( code, description)
135141 }
136142}
143+
You can’t perform that action at this time.
0 commit comments