Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(doc handle): documentation handling for bedrock #3751

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

DenovVasil
Copy link
Contributor

@DenovVasil DenovVasil commented Dec 5, 2024

Description

Added document handling for bedrock.

image

Related issues

https://github.com/camunda/team-connectors/issues/969

@DenovVasil DenovVasil requested a review from a team as a code owner December 5, 2024 08:18
@DenovVasil DenovVasil marked this pull request as draft December 5, 2024 08:18
@DenovVasil DenovVasil self-assigned this Dec 5, 2024
@DenovVasil DenovVasil changed the title 969 add doc handling for bedrock and textract feat(doc handle): for bedrock and textract Dec 5, 2024
@DenovVasil DenovVasil force-pushed the 969-add-doc-handling-for-bedrock-and-textract branch from 7cb6e55 to b4c6bf5 Compare December 12, 2024 08:41
@DenovVasil DenovVasil force-pushed the 969-add-doc-handling-for-bedrock-and-textract branch from b4c6bf5 to 27f5854 Compare December 18, 2024 22:23
@DenovVasil DenovVasil marked this pull request as ready for review December 19, 2024 07:36
@DenovVasil DenovVasil force-pushed the 969-add-doc-handling-for-bedrock-and-textract branch from 27f5854 to 203f6de Compare December 19, 2024 07:42
@DenovVasil DenovVasil added this to the 8.7.0-alpha3 milestone Dec 19, 2024
@DenovVasil DenovVasil changed the title feat(doc handle): for bedrock and textract feat(doc handle): documentation handling for bedrock Dec 19, 2024

private MessageMapper createMessageMapper() {
var bedrockContentMapper = new BedrockContentMapper(new DocumentMapper());
return new MessageMapper(bedrockContentMapper);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we are not returning the new Message and the history but only the history ?
That requires changes in the documentation, and is it what is expected ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and Yes ))
I described this in the documentation pr

.toList();
var messageMapper = createMessageMapper();
var bedrockContentMapper = messageMapper.getBedrockContentMapper();
this.messagesHistory.add(prepareNewBedrockMessage(bedrockContentMapper));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having prepareNewBedrockMessage be part of MessageMapper would be clearer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense, I will do ))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@DenovVasil DenovVasil force-pushed the 969-add-doc-handling-for-bedrock-and-textract branch from 203f6de to 0c1e39a Compare December 19, 2024 13:34
@DenovVasil DenovVasil added this pull request to the merge queue Dec 19, 2024
Copy link
Collaborator

@johnBgood johnBgood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments only great work!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably done but just in case: remember the webmodeler pr :)


public class DocumentMapper {

public static final String UNSUPPORTED_DOC_TYPE_MSG = "Unsupported document type: ";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be "Unsupported document type: {}" and then in the logger.debug(UNSUPPORTED_DOC_TYPE_MSG, fileType)

fileType = fileType.isEmpty() ? FileUtil.defineType(contentType) : fileType;
} catch (MimeTypeException e) {
String errorMsg = UNSUPPORTED_CONTENT_TYPE_MSG + contentType;
LOGGER.debug(errorMsg);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have the context, but are we sure it's only a debug level message? not even warn ?

import java.util.Objects;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class BedrockContent {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be a record

import java.util.List;
import java.util.Objects;

public class BedrockMessage {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be a record


public static String defineType(String contentType) throws MimeTypeException {
MimeTypes mimeTypes = MimeTypes.getDefaultMimeTypes();
String extension = mimeTypes.forName(contentType).getExtension();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can mimeTypes.forName(contentType) throw an exception? if so shouldn't we handle it properly and wrap it?

Merged via the queue into main with commit 11b0f42 Dec 19, 2024
13 checks passed
@DenovVasil DenovVasil deleted the 969-add-doc-handling-for-bedrock-and-textract branch December 19, 2024 16:43
@Szik
Copy link

Szik commented Jan 8, 2025

QA testing done.
findings:

  • when defining a single document, the list-brakets "[]" are still needed or the following error is thown:
{"type":"io.camunda.connector.api.error.ConnectorException","message":"Cannot deserialize value of type `java.util.ArrayList<io.camunda.document.Document>` from Object value (token `JsonToken.START_OBJECT`)","code":"JSON_MISMATCH_ERROR"}

if this is intended, maybe this needs to be mentioned in the documentation

  • a returned error by the connector does not result in an incident error in operate. is this intended?

@sbuettner
Copy link
Contributor

@DenovVasil Can you make use of "Object" as the type and figure out whether its a single object document or multiple ones in the Connector?

@DenovVasil
Copy link
Contributor Author

QA testing done. findings:

  • when defining a single document, the list-brakets "[]" are still needed or the following error is thown:
{"type":"io.camunda.connector.api.error.ConnectorException","message":"Cannot deserialize value of type `java.util.ArrayList<io.camunda.document.Document>` from Object value (token `JsonToken.START_OBJECT`)","code":"JSON_MISMATCH_ERROR"}

if this is intended, maybe this needs to be mentioned in the documentation

  • a returned error by the connector does not result in an incident error in operate. is this intended?

We can provide a list of documents on the API bedrock, so for me this is expected behavior.
Example:

  1. Upload 2 documents via postman.
    2)Make request with both files.
    image
  2. Get response
    image

@DenovVasil
Copy link
Contributor Author

QA testing done. findings:

  • when defining a single document, the list-brakets "[]" are still needed or the following error is thown:
{"type":"io.camunda.connector.api.error.ConnectorException","message":"Cannot deserialize value of type `java.util.ArrayList<io.camunda.document.Document>` from Object value (token `JsonToken.START_OBJECT`)","code":"JSON_MISMATCH_ERROR"}

if this is intended, maybe this needs to be mentioned in the documentation

  • a returned error by the connector does not result in an incident error in operate. is this intended?

The documentation states that the documents are a list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants