aws-samples / bedrock-claude-chat

AWS-native chatbot using Bedrock + Claude (+Mistral)
MIT No Attribution
687 stars 230 forks source link

Feat/text file attach #412

Open satoxiw opened 3 days ago

satoxiw commented 3 days ago

Issue #, if available:

Description of changes: テキストファイルをリクエストに添付できる機能を追加しました。 MIME Typeで"text/*"となるものが対象ですが、環境によってはMIME Typeが正しく設定されないケースがあり、その場合は拡張子で判断するようになっています。対象となる拡張子は下記コード中に埋めていますが、これだと対象を追加しにくいかもしれないので、何か良い案があったらご指摘ください。 https://github.com/aws-samples/bedrock-claude-chat/compare/v1...satoxiw:bedrock-claude-chat:feat/text-file-attach?expand=1#diff-4f4332c2118277ddc90f75e9489ace8c6be3e9c60c88165e58063e8f25aa4734R37

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Yukinobu-Mine commented 3 days ago

拡張子からの MIME type の推定は、このあたりのライブラリが使えそうです。 (既にフロントエンドの依存関係に含まれてるので、import するだけで使えると思います) https://www.npmjs.com/package/mime

このライブラリが内部的に参照してるマッピング情報はこちらのようです。 https://github.com/jshttp/mime-db/blob/master/db.json

statefb commented 2 hours ago

Related issue: #198 Partially solved

statefb commented 1 hour ago

getAllTextExtensionsした結果をそのままhard codingしてしまった方が早い?

["appcache","manifest","ics","ifb","coffee","litcoffee","css","csv","html","htm","shtml","jade","js","mjs","jsx","less","md","markdown","mml","mdx","n3","txt","text","conf","def","list","log","in","ini","dsc","rtx","rtf","sgml","sgm","shex","slim","slm","spdx","stylus","styl","tsv","t","tr","roff","man","me","ms","ttl","uri","uris","urls","vcard","curl","dcurl","mcurl","scurl","sub","ged","fly","flx","gv","3dml","spot","jad","wml","wmls","vtt","wgsl","s","asm","c","cc","cxx","cpp","h","hh","dic","htc","f","for","f77","f90","hbs","java","lua","mkd","nfo","opml","org","p","pas","pde","sass","scss","etx","sfv","ymp","uu","vcs","vcf","xml","yaml","yml"]