Skip to content

Commit

Permalink
fix ollama models, add claude haiku 3.5, fix open ai chat adapter emp…
Browse files Browse the repository at this point in the history
…ty choices (#101)
  • Loading branch information
wachterjohannes authored Dec 2, 2024
1 parent f4daa63 commit 6ca0706
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Chat/OpenaiChatAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ protected function createStreamedMessages(StreamResponse $responses): \Iterator

/** @var CreateStreamedResponse $response */
foreach ($responses as $response) {
if (0 === \count($response->choices)) {
continue;
}

$delta = $response->choices[0]->delta;

if (!$role instanceof AIChatMessageRoleEnum) {
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Chat/resources/stream.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
data: {"id":"chatcmpl-6yo21W6LVo8Tw2yBf7aGf2g17IeIl","object":"chat.completion.chunk","created":1679432086,"model":"gpt-4-0314","choices":[{"delta":{"role":"assistant"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-6yo21W6LVo8Tw2yBf7aGf2g17IeIl","object":"chat.completion.chunk","created":1679432086,"model":"gpt-4-0314","choices":[{"delta":{"content":"Lorem"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-6yo21W6LVo8Tw2yBf7aGf2g17IeIl","object":"chat.completion.chunk","created":1679432086,"model":"gpt-4-0314","choices":[{"delta":{"content":"Ipsum"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-6yo21W6LVo8Tw2yBf7aGf2g17IeIl","object":"chat.completion.chunk","created":1679432086,"model":"gpt-4-0314","choices":[]}
data: {"id":"chatcmpl-6yo21W6LVo8Tw2yBf7aGf2g17IeIl","object":"chat.completion.chunk","created":1679432086,"model":"gpt-4-0314","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}
data: [DONE]

0 comments on commit 6ca0706

Please sign in to comment.