community: OCI Generative AI tool calling bug fix (#26910)

- [x] **PR title**: 
  "community: OCI Generative AI tool calling bug fix 


- [x] **PR message**: 
- **Description:** bug fix for streaming chat responses with tool calls.
Update to PR 24693
    - **Issue:** chat response content is repeated when streaming
    - **Dependencies:** NA
    - **Twitter handle:** NA


- [x] **Add tests and docs**: NA


- [x] **Lint and test**: make format, make lint and make test we run
successfully

---------

Co-authored-by: Arthur Cheng <arthur.cheng@oracle.com>
Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
Rave Harpaz 2024-10-30 19:35:25 -07:00 committed by GitHub
parent 128b07208e
commit 8d8d85379f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -158,7 +158,10 @@ class CohereProvider(Provider):
def chat_stream_to_text(self, event_data: Dict) -> str:
if "text" in event_data:
return event_data["text"]
if "finishedReason" in event_data or "toolCalls" in event_data:
return ""
else:
return event_data["text"]
else:
return ""