Skip to content

Commit cc65493

Browse files
committed
test existence of prompt
1 parent 98b6d49 commit cc65493

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/LaravelOpenaiApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function generateImage($data): Prompt {
3636

3737
private function savePrompt($result, $data): Prompt {
3838
$prompt = new Prompt([
39-
'prompt_text' => $data['prompt'],
39+
'prompt_text' => array_key_exists('prompt') ?? $data['prompt'] : $data['messages'],
4040
'data' => $result
4141
]);
4242
return $prompt;

test.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
3+
curl -X POST http://localhost/api/generate-result -H "Content-Type: application/json" --data-binary @- <<DATA
4+
{
5+
"type": "chat",
6+
"model":"gpt-3.5-turbo",
7+
"messages":[
8+
{"role": "system", "content": "You are a helpful assistant."},
9+
{"role": "user", "content": "Generate a press release for music artist Mastashake"}
10+
11+
]
12+
}
13+
DATA

0 commit comments

Comments
 (0)