Skip to content

Commit

Permalink
Fix parsing response with openai-compatible endpoints (#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter authored Aug 20, 2024
1 parent c872e7c commit 92269e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Fixed
- Parsing streaming response with some OpenAi compatible services.

## [0.30.0] - 2024-08-20

### Added
Expand Down
11 changes: 4 additions & 7 deletions griptape/drivers/prompt/openai_chat_prompt_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,11 @@ def try_stream(self, prompt_stack: PromptStack) -> Iterator[DeltaMessage]:
output_tokens=chunk.usage.completion_tokens,
),
)
elif chunk.choices is not None:
if len(chunk.choices) == 1:
choice = chunk.choices[0]
delta = choice.delta
if chunk.choices:
choice = chunk.choices[0]
delta = choice.delta

yield DeltaMessage(content=self.__to_prompt_stack_delta_message_content(delta))
else:
raise Exception("Completion with more than one choice is not supported yet.")
yield DeltaMessage(content=self.__to_prompt_stack_delta_message_content(delta))

def _base_params(self, prompt_stack: PromptStack) -> dict:
params = {
Expand Down

0 comments on commit 92269e1

Please sign in to comment.