@@ -159,34 +159,15 @@ function New-ChatGPTConversation {
159
159
}
160
160
161
161
# if prompt is not empty and it is a file, then read the file as the prompt
162
- $parsedprompt = Get-PromptContent ( $prompt )
162
+ $parsedprompt = Get-PromptContent - prompt $prompt - context $context
163
163
$prompt = $parsedprompt.content
164
-
165
- # if user provide the context, inject the data into the prompt by replace the context key with the context value
166
- if ($context ) {
167
- Write-Verbose ($resources.verbose_context_received -f ($context | ConvertTo-Json - Depth 10 ))
168
- foreach ($key in $context.keys ) {
169
- $prompt = $prompt -replace " {{$key }}" , $context [$key ]
170
- }
171
- Write-Verbose ($resources.verbose_prompt_context_injected -f $prompt )
172
- }
173
-
174
164
$telemetries.Add (" promptType" , $parsedprompt.type )
175
165
$telemetries.Add (" promptLib" , $parsedprompt.lib )
176
166
177
167
# if system is not empty and it is a file, then read the file as the system prompt
178
- $parsedsystem = Get-PromptContent ( $system )
168
+ $parsedsystem = Get-PromptContent - prompt $system - context $context
179
169
$system = $parsedsystem.content
180
170
181
- # if user provide the context, inject the data into the system prompt by replace the context key with the context value
182
- if ($context ) {
183
- Write-Verbose ($resources.verbose_context_received -f ($context | ConvertTo-Json - Depth 10 ))
184
- foreach ($key in $context.keys ) {
185
- $system = $system -replace " {{$key }}" , $context [$key ]
186
- }
187
- Write-Verbose ($resources.verbose_prompt_context_injected -f $system )
188
- }
189
-
190
171
$telemetries.Add (" systemPromptType" , $parsedsystem.type )
191
172
$telemetries.Add (" systemPromptLib" , $parsedsystem.lib )
192
173
@@ -245,9 +226,9 @@ function New-ChatGPTConversation {
245
226
$body = @ {model = " $model " ; messages = $messages }
246
227
247
228
$params = @ {
248
- Uri = $endpoint
249
- Method = " POST"
250
- Headers = $header
229
+ Uri = $endpoint
230
+ Method = " POST"
231
+ Headers = $header
251
232
}
252
233
253
234
if ($json ) {
@@ -402,9 +383,9 @@ function New-ChatGPTConversation {
402
383
# TODO #174 保留消息的个数是不是可以放宽
403
384
$body = @ {model = " $model " ; messages = ($systemPrompt + $messages [-5 .. -1 ]); stream = $stream }
404
385
$params = @ {
405
- Uri = $endpoint
406
- Method = " POST"
407
- Headers = $header
386
+ Uri = $endpoint
387
+ Method = " POST"
388
+ Headers = $header
408
389
}
409
390
410
391
if ($json ) {
0 commit comments