derek-thomas HF staff commited on
Commit
165d244
1 Parent(s): 7dfa79f

Adding rich text box

Browse files
app.py CHANGED
@@ -4,6 +4,7 @@ from pathlib import Path
4
  from time import perf_counter
5
 
6
  import gradio as gr
 
7
  from jinja2 import Environment, FileSystemLoader
8
  from transformers import AutoTokenizer
9
 
@@ -103,7 +104,7 @@ def process_example(text, history=[]):
103
 
104
  with gr.Blocks() as demo:
105
  gr.Markdown(intro_md)
106
- endpoint_status = gr.Textbox(check_endpoint_status, label="Inference Endpoint Status", every=1)
107
  with gr.Tab("Arabic-RAG"):
108
  chatbot = gr.Chatbot(
109
  [],
 
4
  from time import perf_counter
5
 
6
  import gradio as gr
7
+ from gradio_rich_textbox import RichTextbox
8
  from jinja2 import Environment, FileSystemLoader
9
  from transformers import AutoTokenizer
10
 
 
104
 
105
  with gr.Blocks() as demo:
106
  gr.Markdown(intro_md)
107
+ endpoint_status = RichTextbox(check_endpoint_status, label="Inference Endpoint Status", every=1)
108
  with gr.Tab("Arabic-RAG"):
109
  chatbot = gr.Chatbot(
110
  [],
backend/query_llm.py CHANGED
@@ -65,6 +65,9 @@ def check_endpoint_status():
65
  status = data.get('status', {}).get('state', 'No status found')
66
  message = data.get('status', {}).get('message', 'No message found')
67
 
68
- return f"Status: {status}\nMessage: {message}"
 
 
 
69
  except requests.exceptions.RequestException as e:
70
- return f"Failed to get status: {str(e)}"
 
65
  status = data.get('status', {}).get('state', 'No status found')
66
  message = data.get('status', {}).get('message', 'No message found')
67
 
68
+ if status == "scaledToZero":
69
+ return f"<div style='color: red; font-size: 20px; font-weight: bold;'>Status: {status}<br>Message: {message}</div>"
70
+ else:
71
+ return f"<div>Status: {status}<br>Message: {message}</div>"
72
  except requests.exceptions.RequestException as e:
73
+ return f"<div>Failed to get status: {str(e)}</div>"
gradio_packages/gradio_rich_textbox-0.2.0-py3-none-any.whl ADDED
Binary file (26.3 kB). View file
 
requirements.txt CHANGED
@@ -8,4 +8,5 @@ farm-haystack[inference]
8
  ipywidgets==8.1.1
9
  plotly==5.18.0
10
  lancedb==0.3.2
11
- bitsandbytes==0.41.1
 
 
8
  ipywidgets==8.1.1
9
  plotly==5.18.0
10
  lancedb==0.3.2
11
+ bitsandbytes==0.41.1
12
+ ./gradio_packages/gradio_rich_textbox-0.2.0-py3-none-any.whl