Overview# I created apps using the Azure OpenAI Assistants API with Gradio and Next.js, so here are my notes.
Target Data# I used articles published on Zenn as the target data. First, I bulk downloaded them with the following code.
i f i f p u w f m r m r a r h o p o p o g l i r o m o m e s l r r e u r d a i f p u t i r s h t o w t b t t = = r e a r f o a r e f e o t x s i s q 1 l s t t r g l x s u m t . t r 4 o d 1 [ : p a i l e t o p p l m h e s m ] = o c e b a u i _ s c o = a f q i n = l n r r r + n o . o n = = k o . u m i f s e ( e t l = p p n s h e p w e p m " e r s a a i s t a a t e B s t d e r s o p h e r k c . 1 q t t i e o m i n i t r o t = s = t l a d h h n = a u l r ( t s t r t p i e p m . u u p . s t e t p r o d c p ( = e e r t . g ( e ( B s e n a l i e u x e i f e o x t e t : q s t e n n r f i q f i t s t x a q / u e a s d l " s u u n _ . _ t u d / e . [ ) a ( s d t e l d t p o ) t m z s j ' r " ) a s s S ( e a p i e t s a = t h : t ( t o c x t a f n s o r = i t a t s u l t h t u n . n t c t / e . p a ( . h l . g ( i 0 l p t x g ( s ) d , S d e ) c : e s e t e r s i o e t l s : x _ t e _ r " u v ( e : / t ( s = n w p / u s / p u p " a " a r ' z { a r o z m ) p l ] e u t l n n e i ) n r h ) s c ( a / n l ) e " t s a . . : . ) e r d s t x f t e p e t : i v l x _ c " i t o l t , p e + ( a s ' " t ? a / h h u r ' t ) s t ) m , e i [ l r c - . e n l 1 p x a e ] a i m [ } r s e ' . s t = p t e _ n a x r o a t t " k k h " ) = a ' T m ] r u ) u r e a ) 1 9 6 & p a g e = { p a g e } " Registering to the Vector Store# Upload data files with the following code.
i f f f f l c # i v i v f # r i f f f # # B v # f f # f f # i m r r r r o l s e f e o e t i o i # A e # i i # i o # f p o o o o a i a a a C _ c c r G s e l r l U T c l l l r o m m m m d e z p p r c t i t e p m e e p C C t G e e A e P f r _ n u i i e r o s v o v i t o s n i f f n l o H o e s s s _ f f i # f # i r i t e t d o g t d t r _ _ a e r _ e r e f n a t i i a o n _ r t . s s i i f # i # f o l r x o p l q o e k v t a _ c c _ c r s = m e l l m a s S _ = s u t l l l c e y c o t e o d t = _ e e e t s r t s t v e e e m e e e d t I s a o m r e e f O e U l e _ : e s e n b m e e y r e t e o t o e v b g r s n n s a Z t n g r e e n i c p _ p e t e f s s c p p n a n A n = s o _ o a r o r c e r i = e i a a . n E o d l t a i a l o e s l n r x i s t l t r v i i i v z d o i r v r t _ r _ t c e s s = n m m s t r o ( a m n m e n n t o ( y c n r i i m m ( u p s o e e e s e s o t a t c p e e o = e s b ) l s e n t r a f : e a r e e E n i i p p o r o . n r c _ _ t s t r o k e l o [ i s r s _ o ( r t a i f e d i c p p l f e a n v x t m m o o v e i g = e t n v o o _ r r i n ] t = . t e 1 i r " e = q = m n i a l l t r l i m m t e c ( p p r r e O n e " t o a e r = r s _ e e s e a ( t 0 d t . a d e u l m w e i i y l a s . c e f o o t t r p t t 2 r r m c e e t s d n e m i p ) t 0 / d [ m o e e s h _ e E n : e i : b t p " r r r e e 0 i _ e t c o t t . s t p i = f d y ] ( s i . e s n v x t _ n e o t E t t g t i n = n 2 e s o = l i r o d . d : e e n i a - f . n a a n t t e c ( s i t r i r l q d A v 4 v t = r i n e r a f a m n g " l t u i p s p r . c e f t n a _ o r l A o d e I o ( - e o _ c e . e t i t . d s v e a p l a f p b e b t p " r g . s n o o z b m = ( s " 0 r " s l n v n _ a l a f ( s / l e t i s e a a e o t E e v t r a u T . A 5 v e V t i t e a i e i f _ l t o s h l t n t m t r i r a f e o a d r r g Z - e e o e . c m d f s l i U i e a ) . e r d c s a _ o r m i c r s p _ e u e U 0 c = c r n b t e i . e l E s x d : b n e ( h ) . s n o s l t e r d O e t R 1 t t e t e o = l l n e L t t e a a a o v t r e o _ e o o p ) e E - o T o : . t r = e i a n n / d s m m p s = e o a = s r i : c t e n _ p r r r b a _ = v s s m a I * e e e i = c r s p _ d e e n v O r u e . s e t e m B . f n s n z t e r [ s = s n A ( P e s e S t v t v c ( e k t i a : ( e B o _ e o ] t v s v I " E v t t a e o e t p ) c x l m f A r i : c o e i A N i o o . c r c o u R t e e i i T _ d e r c n Z A e r r v t e t r r O " s ( # l s C s = s # e t g U I w e e e o s o _ p D ) f e H t v s s o R _ " " c r : r s o 3 a i S , r _ o e i R . r r E A t _ _ t s o r l k e S r c n e f _ e _ P o s s o e 4 e e i " a I e t g s i s m O I r t t r = X ) p r c Z s o e l t a P _ _ o o e " K c b h E . r b t e o i E K s r r . a X o a " e : f _ a _ r n N E t e e i s 2 n l ) d i s t s b e i A Y o s _ d s C f r ) l t c t a _ n I _ r . n i c i e e o h r t i g _ Z e l a s p r a _ r : e c d E E s i m t V m d b e a h , f N N . s e a j e y a _ { m e i D N c t : n o d - t i e s s f l P " r ( t " u c d } . i e O ) e ) s p h , " u l s I , a " l e ) p e : N t ) o s f l s T e a . i o = { _ ( d u l a f e Z n e p e d i } E a d l s _ l " N m o = a e ) N e f a f n _ " = i d i d s ) v l _ l _ t , e e a e p r c s n _ o e t d s l a o _ t l m r p r ( s _ o e s l a t l m o ( s r e _ n a m e ) # C r e a t e a v e c t o r s t o r e c a l e d " F i n a n c i a l S t a t e m e n t s "
Assistant Playground# I used the “Assistant Playground” to verify behavior.
One behavior that caught my attention was that when the same file was cited multiple times, the second citation onwards appeared with empty content.
Gradio# I prototyped an app using the Azure OpenAI Assistants API and Gradio. You can try it from the following Spaces.
https://huggingface.co/spaces/nakamura196/zenn
Please check the following for the implementation details.
https://huggingface.co/spaces/nakamura196/zenn/tree/main
There are some unconventional implementation aspects when combining Gradio’s Chatbot with the Azure OpenAI Assistants API, but I hope it serves as a useful reference.
Next.js# Similarly, I also prototyped an app using openai-assistants-quickstart. You can try it at the following link.
https://openai-assistants-quickstart-zenn.vercel.app/examples/basic-chat
The repository is as follows.
https://github.com/nakamura196/openai-assistants-quickstart_zenn
To use Azure OpenAI Service with openai-assistants-quickstart, I modified the openai.ts file as follows.
i e } m x ) p p e a d a ; o o n p e p r r d i p i t t p K l V o e o e { c i y y r o n : m s A n t e i z s : p n o u t r t n r p o : : e o r c O p o e " " p e c s g 2 e n e s p 0 n a s . t 2 A i s e - 4 I . n 4 - = e v o 0 } n . " 5 n v O , - f e . P 0 r w O E 1 o P N - m A E A p z N I r " u A _ e o r I A v p e _ P i e O E I e n p N _ w a e D K " i n P E , " A O Y ; I I , ( N { T ,
Issues# In both Gradio and Next.js, the following error occurred and I was unable to retrieve the content of Citation files.
https://community.openai.com/t/can-not-download-assistant-generated-file-download-link-assistants-api-v2/1002926/1
I plan to continue investigating this issue.
Summary# I hope this serves as a useful reference for using the Azure OpenAI Assistants API.