openai-assistants-quickstartの微修正

概要 OpenAIのAssistants APIを用いたRAG( Retrieval-augmented generation)を用いたチャット画面の構築にあたり、以下のリポジトリを使用しました。 https://github.com/openai/openai-assistants-quickstart この時、citationの扱いについて修正が必要であったため、備忘録としてメモします。 背景 上記のリポジトリを使い、OpenAIのAssistants APIを用いたRAGを試みました。 この時、デフォルトの設定では、以下のように、「4:13†」のように、引用箇所を示す記号がそのまま表示されてしまいました。 対策 annotateLastMessageを以下のように修正しました。file_pathをfile_citationに変更することで、引用箇所を置換することができた。 一例として、以下では、File APIへのリンクに置換しています。 c o n } s ; t s } e ) a t c c } a } r ; n G M o o ; n ) e n e e n n n i } ; t o t s s s o f u t s t t . t u ) r a t a l a ( p ; n t h g l u a t a d a ` e e e a p s i n a n [ [ L s s d t o n t n リ . a c ( t a M n o e o ン . s u ( M t e s t d t ク . t r p e e s . a L a ] p M r r s d s f t a t ( r e e e s L a o i s i e s n v a a g r o t a v s t M g s e E n M n p M a e e t , a . e . i e g m s M c t s t / s e e s = e h y s e f s s a s ( p a x i a = s g p s ( e g t l g a e r a a e , e e ( g s e g n = . s s a e ) v e n = t / . n s M o = e $ s n = e = t x { l o > s a " t a i t s { t f n c a { a i i = n e t g o l o ( i e n e u t 0 o s ) _ p a , n [ c d t s p = i a i - ) r > t t o 1 e a e n ) = v { t d . , > M i L f e o a i u { s n s l p s " t e d a ) M _ a g e c t e { s i e s s t d . a a L l g t a e e i s n . o t g t n M t e . e h x f s t i s - . l a r e g 1 e _ e ] p i ] ; l d ; a } c ) e ` A l l ( 結果、以下のようにリンクが表示されました。 ...

2024年11月28日 · 3 分 · Nakamura

OpenAIでストレージ内のすべてのファイルを削除する

概要 OpenAIでストレージ内のすべてのファイルを削除する方法に関する備忘録です。 以下のページが参考になりました。 https://community.openai.com/t/deleting-everything-in-storage/664945 背景 以下のようなコードによってアップロードした複数ファイルを一括削除したいケースがありました。 f f # # f # p p i i i r r l l U a l v Y i i e e s n e e o n n _ _ e d _ c u t t p s b t ( ( a t t p a o c f f t r h o t r a i i h e e l c _ n l l s a l h s e e m u t p _ _ = s p t = o r b b l h r i a a g = o e c e n t t l a l _ t c c o [ d s i i h h b o t e d t . . ( p a a n = h s f " e n t t v e t i d n d u . e a l a ( s b c s t e t p p e t t u _ a a o o t o a s c / t l f a r t ) o t h l . _ u u x , t v s s n t S h e t t / " D e c o a s * r K t r n ) . b f o e d t " h i r . x ) e l _ i t t l e s d h " f p t , e ) o e b o r r a r f f t e i i p t c s l l a o h . e e t f s h u f i = c p o l f o i l r e i u n o _ l n a c b e t f d o a _ s i m t s l t p c t o e h l h r f _ e e e e p t s a t a f i . m h t i o u s e h l n p s e . l b ] s o a , a t d c a _ h d a d n t d o t _ h p s e o e m l e l t ( t o h e t h r e e s v u e l c t t o o r f s t t h o i r s e , o p e r a t i o n . 方法 以下のコードを実行することに、一括削除を行うことができました。 ...

2024年7月24日 · 13 分 · Nakamura