jtdearmon commited on
Commit
5883730
Β·
verified Β·
1 Parent(s): acf9ef4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -26
app.py CHANGED
@@ -1,9 +1,6 @@
1
  import os
2
  import requests
3
  import gradio as gr
4
- import base64
5
- import io
6
- from PIL import Image
7
 
8
  #
9
  # 1) Retrieve your Hugging Face token (with read access) for the private space
@@ -54,24 +51,21 @@ def handle_feedback(user_query, answer, feedback_option):
54
  return call_private_space(1, [user_query, answer, feedback_option])
55
 
56
  #
57
-
58
- #
59
- # 6) Build the UI *layout* to mirror your private space.
60
  #
61
- demo = gr.Blocks()
62
-
63
- with demo:
64
- # A row with the logo on the left, and a title on the right
65
  with gr.Row():
66
  with gr.Column(scale=1, min_width=100):
67
- if DAL_LOGO_IMG:
68
- gr.Image(
69
- value=DAL_LOGO_IMG,
70
- show_label=False,
71
- interactive=False,
72
- width=80,
73
- height=80
74
- )
75
  with gr.Column(scale=6):
76
  gr.Markdown("## Dallas RAG + Graph Demo")
77
  gr.Markdown(
@@ -79,8 +73,8 @@ with demo:
79
  "You can **toggle** whether the subgraph is summarized via OpenAI "
80
  "or used 'as is'. Only the last 5 queries are kept in the conversation."
81
  )
82
-
83
- # User input row
84
  user_query = gr.Textbox(
85
  label="Your Query",
86
  lines=1,
@@ -91,9 +85,11 @@ with demo:
91
  label="Use Graph Summaries?"
92
  )
93
  get_answer_btn = gr.Button("Get Answer")
 
 
94
  answer_output = gr.Markdown(label="AI Answer")
95
 
96
- # Feedback row
97
  feedback_radio = gr.Radio(
98
  choices=["πŸ‘", "βš–οΈ", "πŸ‘Ž"],
99
  value="βš–οΈ",
@@ -102,7 +98,7 @@ with demo:
102
  feedback_btn = gr.Button("Submit Feedback")
103
  feedback_result = gr.Markdown()
104
 
105
- # Wire up the .click() events to the private space calls
106
  get_answer_btn.click(
107
  fn=run_query,
108
  inputs=[user_query, use_summary_chk],
@@ -114,7 +110,7 @@ with demo:
114
  outputs=feedback_result
115
  )
116
 
117
- # Footer, same as private space
118
  gr.HTML(
119
  """
120
  <div style="text-align: center; margin-top: 20px;">
@@ -127,8 +123,6 @@ with demo:
127
  """
128
  )
129
 
130
- #
131
- # 7) Launch
132
- #
133
  if __name__ == "__main__":
134
  demo.launch()
 
1
  import os
2
  import requests
3
  import gradio as gr
 
 
 
4
 
5
  #
6
  # 1) Retrieve your Hugging Face token (with read access) for the private space
 
51
  return call_private_space(1, [user_query, answer, feedback_option])
52
 
53
  #
54
+ # 5) Build the UI layout to mirror your private space,
55
+ # now loading dal_logo.png locally from the *public* repo.
 
56
  #
57
+ with gr.Blocks() as demo:
58
+ # Top row: logo on the left, title on the right
 
 
59
  with gr.Row():
60
  with gr.Column(scale=1, min_width=100):
61
+ # Load the local dal_logo.png (make sure it's in the same folder!)
62
+ gr.Image(
63
+ value="dal_logo.png",
64
+ show_label=False,
65
+ interactive=False,
66
+ width=80,
67
+ height=80
68
+ )
69
  with gr.Column(scale=6):
70
  gr.Markdown("## Dallas RAG + Graph Demo")
71
  gr.Markdown(
 
73
  "You can **toggle** whether the subgraph is summarized via OpenAI "
74
  "or used 'as is'. Only the last 5 queries are kept in the conversation."
75
  )
76
+
77
+ # User query, checkbox, and 'Get Answer'
78
  user_query = gr.Textbox(
79
  label="Your Query",
80
  lines=1,
 
85
  label="Use Graph Summaries?"
86
  )
87
  get_answer_btn = gr.Button("Get Answer")
88
+
89
+ # Output area
90
  answer_output = gr.Markdown(label="AI Answer")
91
 
92
+ # Feedback section
93
  feedback_radio = gr.Radio(
94
  choices=["πŸ‘", "βš–οΈ", "πŸ‘Ž"],
95
  value="βš–οΈ",
 
98
  feedback_btn = gr.Button("Submit Feedback")
99
  feedback_result = gr.Markdown()
100
 
101
+ # Wire the buttons to the private space endpoints
102
  get_answer_btn.click(
103
  fn=run_query,
104
  inputs=[user_query, use_summary_chk],
 
110
  outputs=feedback_result
111
  )
112
 
113
+ # Footer
114
  gr.HTML(
115
  """
116
  <div style="text-align: center; margin-top: 20px;">
 
123
  """
124
  )
125
 
126
+ # Launch the public interface
 
 
127
  if __name__ == "__main__":
128
  demo.launch()