NithikaShree commited on
Commit
dd767a0
·
verified ·
1 Parent(s): f3c9c7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -13
app.py CHANGED
@@ -6,15 +6,14 @@ from langchain_tavily import TavilySearch
6
  # =========================
7
  # Environment Variables
8
  # =========================
9
- # Set these in Hugging Face Spaces → Settings → Secrets
10
  GROQ_API_KEY = os.getenv("GROQ_API_KEY")
11
  TAVILY_API_KEY = os.getenv("TAVILY_API_KEY")
12
 
13
  if not GROQ_API_KEY or not TAVILY_API_KEY:
14
- raise ValueError("Please set GROQ_API_KEY and TAVILY_API_KEY in Hugging Face Secrets")
15
 
16
  # =========================
17
- # LLM & Search Setup
18
  # =========================
19
  llm = ChatGroq(
20
  model_name="openai/gpt-oss-120b",
@@ -27,6 +26,9 @@ search = TavilySearch(
27
  tavily_api_key=TAVILY_API_KEY
28
  )
29
 
 
 
 
30
  def google_style_search(query):
31
  if not query.strip():
32
  return "Please enter a search query."
@@ -40,31 +42,36 @@ Using the following web search information:
40
  {context}
41
 
42
  Question: {query}
43
- Answer in a clear, user-friendly, Google-style summary:
44
  """
45
 
46
  response = llm.invoke(prompt)
47
  return response.content.strip()
48
 
 
 
 
49
  google_css = """
50
- @import url('https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&family=Inter:wght@400;500;700&display=swap');
51
 
52
  body {
53
  background-color: #ffffff;
54
- font-family: 'Google Sans', 'Inter', Arial, sans-serif;
55
  }
56
 
57
  .gradio-container {
58
- max-width: 850px !important;
59
- margin-top: 60px;
60
  }
61
 
 
62
  #logo {
63
- font-size: 52px;
64
  font-weight: 700;
65
  text-align: center;
66
- margin-bottom: 35px;
67
- letter-spacing: -1px;
 
68
  }
69
 
70
  #logo span:nth-child(1) { color: #4285F4; }
@@ -78,7 +85,7 @@ body {
78
  border-radius: 24px !important;
79
  border: 1px solid #dfe1e5 !important;
80
  padding: 14px 20px !important;
81
- font-size: 16px !important;
82
  }
83
 
84
  .search-box textarea:focus {
@@ -96,7 +103,6 @@ body {
96
 
97
  .search-btn button:hover {
98
  border: 1px solid #dadce0 !important;
99
- background-color: #f8f9fa !important;
100
  }
101
 
102
  .answer-box textarea {
@@ -107,6 +113,9 @@ body {
107
  }
108
  """
109
 
 
 
 
110
  with gr.Blocks(css=google_css) as demo:
111
 
112
  gr.Markdown(
 
6
  # =========================
7
  # Environment Variables
8
  # =========================
 
9
  GROQ_API_KEY = os.getenv("GROQ_API_KEY")
10
  TAVILY_API_KEY = os.getenv("TAVILY_API_KEY")
11
 
12
  if not GROQ_API_KEY or not TAVILY_API_KEY:
13
+ raise ValueError("Set GROQ_API_KEY and TAVILY_API_KEY in Hugging Face Secrets")
14
 
15
  # =========================
16
+ # LLM & Search
17
  # =========================
18
  llm = ChatGroq(
19
  model_name="openai/gpt-oss-120b",
 
26
  tavily_api_key=TAVILY_API_KEY
27
  )
28
 
29
+ # =========================
30
+ # Search Logic
31
+ # =========================
32
  def google_style_search(query):
33
  if not query.strip():
34
  return "Please enter a search query."
 
42
  {context}
43
 
44
  Question: {query}
45
+ Answer in a clear, Google-style summary:
46
  """
47
 
48
  response = llm.invoke(prompt)
49
  return response.content.strip()
50
 
51
+ # =========================
52
+ # Google-like CSS (BIG LOGO)
53
+ # =========================
54
  google_css = """
55
+ @import url('https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&display=swap');
56
 
57
  body {
58
  background-color: #ffffff;
59
+ font-family: 'Google Sans', Arial, sans-serif;
60
  }
61
 
62
  .gradio-container {
63
+ max-width: 900px !important;
64
+ margin-top: 70px;
65
  }
66
 
67
+ /* BIG GOOGLE LOGO */
68
  #logo {
69
+ font-size: 72px;
70
  font-weight: 700;
71
  text-align: center;
72
+ margin-bottom: 40px;
73
+ letter-spacing: -2px;
74
+ line-height: 1;
75
  }
76
 
77
  #logo span:nth-child(1) { color: #4285F4; }
 
85
  border-radius: 24px !important;
86
  border: 1px solid #dfe1e5 !important;
87
  padding: 14px 20px !important;
88
+ font-size: 17px !important;
89
  }
90
 
91
  .search-box textarea:focus {
 
103
 
104
  .search-btn button:hover {
105
  border: 1px solid #dadce0 !important;
 
106
  }
107
 
108
  .answer-box textarea {
 
113
  }
114
  """
115
 
116
+ # =========================
117
+ # UI
118
+ # =========================
119
  with gr.Blocks(css=google_css) as demo:
120
 
121
  gr.Markdown(