import gradio as gr from js import self session = None try: can_ai_create = await self.ai.canCreateTextSession() if can_ai_create != "no": session = await self.ai.createTextSession() except: pass self.ai_text_session = session async def prompt(message, history): session = self.ai_text_session if not session: raise Exception("Gemini Nano is not available in your browser.") stream = session.promptStreaming(message) async for chunk in stream: yield chunk demo = gr.ChatInterface(fn=prompt) demo.launch() transformers-js-py