whitphx HF staff commited on
Commit
12ed164
1 Parent(s): efe69bf

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +23 -21
index.html CHANGED
@@ -21,36 +21,38 @@
21
  <gradio-lite>
22
  <gradio-file name="app.py" entrypoint>
23
  import gradio as gr
 
24
 
25
- from filters import as_gray
 
 
 
 
 
 
26
 
27
- def process(input_image):
28
- output_image = as_gray(input_image)
29
- return output_image
30
 
31
- demo = gr.Interface(
32
- process,
33
- "image",
34
- "image",
35
- examples=["lion.jpg", "logo.png"],
36
- )
37
 
38
- demo.launch()
39
- </gradio-file>
40
 
41
- <gradio-file name="filters.py">
42
- from skimage.color import rgb2gray
 
 
 
 
 
 
43
 
44
- def as_gray(image):
45
- return rgb2gray(image)
46
- </gradio-file>
47
 
48
- <gradio-file name="lion.jpg" url="https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/test_data/lion.jpg" />
49
- <gradio-file name="logo.png" url="https://raw.githubusercontent.com/gradio-app/gradio/main/guides/assets/logo.png" />
 
 
 
50
 
51
  <gradio-requirements>
52
- # Same syntax as requirements.txt
53
- scikit-image
54
  </gradio-requirements>
55
  </gradio-lite>
56
  </body>
 
21
  <gradio-lite>
22
  <gradio-file name="app.py" entrypoint>
23
  import gradio as gr
24
+ from js import self
25
 
26
+ session = None
27
+ try:
28
+ can_ai_create = await self.ai.canCreateTextSession()
29
+ if can_ai_create != "no":
30
+ session = await self.ai.createTextSession()
31
+ except:
32
+ pass
33
 
 
 
 
34
 
35
+ self.ai_text_session = session
 
 
 
 
 
36
 
 
 
37
 
38
+ async def prompt(message, history):
39
+ session = self.ai_text_session
40
+ if not session:
41
+ raise Exception("Gemini Nano is not available in your browser.")
42
+
43
+ stream = session.promptStreaming(message)
44
+ async for chunk in stream:
45
+ yield chunk
46
 
 
 
 
47
 
48
+ demo = gr.ChatInterface(fn=prompt)
49
+
50
+ demo.launch()
51
+
52
+ </gradio-file>
53
 
54
  <gradio-requirements>
55
+ transformers-js-py
 
56
  </gradio-requirements>
57
  </gradio-lite>
58
  </body>