alamin655 commited on
Commit
7415289
1 Parent(s): af5e02d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -7
app.py CHANGED
@@ -6,7 +6,7 @@ import uuid
6
 
7
 
8
  cohere_api_key = os.getenv("COHERE_API_KEY")
9
- co = cohere.Client(cohere_api_key)
10
 
11
 
12
  def trigger_example(example):
@@ -17,7 +17,7 @@ def generate_response(user_message, cid, history=None):
17
 
18
  if history is None:
19
  history = []
20
- if cid == "":
21
  cid = str(uuid.uuid4())
22
 
23
  history.append(user_message)
@@ -58,8 +58,10 @@ examples = [
58
  "Explain gravity to a chicken.",
59
  "Is the world discrete or analog?",
60
  "What is the memory cost in a typical implementation of an all-gather operation?",
61
- "Give me a brief history of the golden era of Cantopop."
62
- ""
 
 
63
  ]
64
 
65
  custom_css = """
@@ -72,6 +74,14 @@ custom_css = """
72
  }
73
  """
74
 
 
 
 
 
 
 
 
 
75
  with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
76
  cid = gr.State("")
77
 
@@ -91,8 +101,8 @@ with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
91
 
92
  with gr.Column():
93
  with gr.Row():
94
- chatbot = gr.Chatbot(show_label=False)
95
-
96
  with gr.Row():
97
  user_message = gr.Textbox(lines=1, placeholder="Ask anything ...", label="Input", show_label=False)
98
 
@@ -120,8 +130,9 @@ with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
120
  cache_examples=False,
121
  fn=trigger_example,
122
  outputs=[chatbot],
 
123
  )
124
 
125
  if __name__ == "__main__":
126
  # demo.launch(debug=True)
127
- demo.queue(api_open=False, max_size=40).launch()
 
6
 
7
 
8
  cohere_api_key = os.getenv("COHERE_API_KEY")
9
+ co = cohere.Client(cohere_api_key, client_name="huggingface-rp")
10
 
11
 
12
  def trigger_example(example):
 
17
 
18
  if history is None:
19
  history = []
20
+ if cid == "" or None:
21
  cid = str(uuid.uuid4())
22
 
23
  history.append(user_message)
 
58
  "Explain gravity to a chicken.",
59
  "Is the world discrete or analog?",
60
  "What is the memory cost in a typical implementation of an all-gather operation?",
61
+ "Give me a brief history of the golden era of Cantopop.",
62
+ "Descrivi il processo di creazione di un capolavoro, come se fossi un artista del Rinascimento a Firenze.",
63
+ "Explique-moi le sens de la vie selon un grand auteur littéraire.",
64
+ "Give me an example of an endangered species and let me know what I can do to help preserve it"
65
  ]
66
 
67
  custom_css = """
 
74
  }
75
  """
76
 
77
+ PLACEHOLDER = """
78
+ <div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;">
79
+ <img src="https://txt.cohere.com/content/images/size/w2000/2024/04/r--Blog-Header.png" style="width: 80%; max-width: 450px; height: auto; opacity: 0.55; margin-bottom: 10px; border-radius: 10px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);">
80
+ <h1 style="font-size: 28px; margin-bottom: 2px; color: #000; opacity: 0.55;">Command R+ Chatbot</h1>
81
+ <p style="font-size: 18px; margin-bottom: 2px; color: #000; opacity: 0.65;">Ask me anything...</p>
82
+ </div>
83
+ """
84
+
85
  with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
86
  cid = gr.State("")
87
 
 
101
 
102
  with gr.Column():
103
  with gr.Row():
104
+ chatbot = gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, placeholder=PLACEHOLDER)
105
+
106
  with gr.Row():
107
  user_message = gr.Textbox(lines=1, placeholder="Ask anything ...", label="Input", show_label=False)
108
 
 
130
  cache_examples=False,
131
  fn=trigger_example,
132
  outputs=[chatbot],
133
+ examples_per_page=100
134
  )
135
 
136
  if __name__ == "__main__":
137
  # demo.launch(debug=True)
138
+ demo.queue(api_open=False, max_size=40).launch(show_api=False)