Skip to content

Commit daa22d9

Browse files
author
Yuanbo Li
committed
Fix Two Bugs:
1. [bedrock retrieve plugin]x-amz-bedrock-kb-source-uri is no longer exists, use s3Location instead 2. [s3 plugin] set content_type for s3 put_object, if not it will be set as binary type by default
1 parent 82bd0f5 commit daa22d9

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

plugins/aws_tools.difypkg

12.2 MB
Binary file not shown.

plugins/aws_tools/manifest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 0.0.18
1+
version: 0.0.20
22
type: plugin
33
author: langgenius
44
name: aws_tools

plugins/aws_tools/tools/bedrock_retrieve.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def convert_to_dify_kb_format(self, kb_repsonse):
1717
result_array = []
1818
for idx, item in enumerate(kb_repsonse['retrievalResults']):
1919
# 提取基础字段
20-
source_uri = item['metadata']['x-amz-bedrock-kb-source-uri']
20+
source_uri = item['location']['s3Location']['uri']
2121
page_number = item['metadata'].get('x-amz-bedrock-kb-document-page-number', 0)
2222
data_source_id = item['metadata'].get('x-amz-bedrock-kb-data-source-id', '')
2323
chunk_id = item['metadata'].get('x-amz-bedrock-kb-chunk-id','')

plugins/aws_tools/tools/s3_operator.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import Any, Union
22
from urllib.parse import urlparse
3+
import mimetypes
34

45
import boto3
56

@@ -52,8 +53,18 @@ def _invoke(
5253
if not text_content:
5354
yield self.create_text_message("text_content parameter is required for write operation")
5455

56+
# Infer content type from file extension
57+
content_type, _ = mimetypes.guess_type(key)
58+
if not content_type:
59+
content_type = "text/plain; charset=utf-8"
60+
5561
# Write content to S3
56-
self.s3_client.put_object(Bucket=bucket, Key=key, Body=text_content.encode("utf-8"))
62+
self.s3_client.put_object(
63+
Bucket=bucket,
64+
Key=key,
65+
Body=text_content.encode("utf-8"),
66+
ContentType=content_type
67+
)
5768
result = f"s3://{bucket}/{key}"
5869

5970
# Generate presigned URL for the written object if requested

0 commit comments

Comments
 (0)