Skip to content

Commit

Permalink
fix kb document url
Browse files Browse the repository at this point in the history
  • Loading branch information
maekawataiki committed Aug 30, 2024
1 parent 91bd159 commit 2b62448
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/web/src/hooks/useRagKnowledgeBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import useRagKnowledgeBaseApi from './useRagKnowledgeBaseApi';
import { getPrompter } from '../prompts';
import { RetrieveResultItem } from '@aws-sdk/client-kendra';
import { ShownMessage } from 'generative-ai-use-cases-jp';
import { cleanEncode } from '../utils/URLUtils';

// s3://<BUCKET>/<PREFIX> から https://s3.<REGION>.amazonaws.com/<BUCKET>/<PREFIX> に変換する
const convertS3UriToUrl = (s3Uri: string, region: string): string => {
Expand Down Expand Up @@ -130,9 +131,7 @@ const useRagKnowledgeBase = (id: string) => {
// 後処理:Footnote の付与
const footnote = retrievedItemsKendraFormat
.map((item, idx) => {
const encodedURI = encodeURI(item.DocumentURI!)
.replace(/\(/g, '\\(')
.replace(/\)/g, '\\)');
const encodedURI = item.DocumentURI ? cleanEncode(item.DocumentURI) : '';
return message.includes(`[^${idx}]`)
? `[^${idx}]: [${item.DocumentTitle}](${encodedURI})`
: '';
Expand Down

0 comments on commit 2b62448

Please sign in to comment.