kshahnathwani commited on
Commit
6ecf410
·
verified ·
1 Parent(s): ba350e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -2
app.py CHANGED
@@ -1,14 +1,50 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
  import os
 
4
 
5
- fancy_css = """..."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  CHORD_SYSTEM_PROMPT = """You are a music theory expert specialized in chord identification.
8
  Given a list of notes (like "C E G" or "D F# A C"), identify the chord name.
9
  Always respond with the chord name and a short explanation of the intervals.
10
  """
11
 
 
12
  HF_TOKEN = os.environ.get("HF_TOKEN")
13
  client = InferenceClient(token=HF_TOKEN, model="google/flan-t5-small")
14
 
@@ -35,7 +71,9 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
35
  yield "⚠️ No response from model (check model ID or token)."
36
 
37
  except Exception as e:
38
- yield f"⚠️ Error: {str(e)}"
 
 
39
 
40
  chatbot = gr.ChatInterface(
41
  fn=respond,
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
  import os
4
+ import traceback
5
 
6
+ fancy_css = """
7
+ #main-container {
8
+ background-color: #f0f0f0;
9
+ font-family: 'Arial', sans-serif;
10
+ }
11
+ .gradio-container {
12
+ max-width: 700px;
13
+ margin: 0 auto;
14
+ padding: 20px;
15
+ background: white;
16
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
17
+ border-radius: 10px;
18
+ }
19
+ .gr-button {
20
+ background-color: #4CAF50;
21
+ color: white;
22
+ border: none;
23
+ border-radius: 5px;
24
+ padding: 10px 20px;
25
+ cursor: pointer;
26
+ transition: background-color 0.3s ease;
27
+ }
28
+ .gr-button:hover {
29
+ background-color: #45a049;
30
+ }
31
+ .gr-chat {
32
+ font-size: 16px;
33
+ }
34
+ #title {
35
+ text-align: center;
36
+ font-size: 2em;
37
+ margin-bottom: 20px;
38
+ color: #333;
39
+ }
40
+ """
41
 
42
  CHORD_SYSTEM_PROMPT = """You are a music theory expert specialized in chord identification.
43
  Given a list of notes (like "C E G" or "D F# A C"), identify the chord name.
44
  Always respond with the chord name and a short explanation of the intervals.
45
  """
46
 
47
+ # Read token from Secrets (set in Space -> Settings -> Repository secrets)
48
  HF_TOKEN = os.environ.get("HF_TOKEN")
49
  client = InferenceClient(token=HF_TOKEN, model="google/flan-t5-small")
50
 
 
71
  yield "⚠️ No response from model (check model ID or token)."
72
 
73
  except Exception as e:
74
+ tb = traceback.format_exc()
75
+ yield f"⚠️ Error: {str(e)}\n\nTraceback:\n{tb}"
76
+
77
 
78
  chatbot = gr.ChatInterface(
79
  fn=respond,