mhamoody commited on
Commit
623443c
·
verified ·
1 Parent(s): 4e4166b
Files changed (1) hide show
  1. webapp.py +12 -1
webapp.py CHANGED
@@ -8,6 +8,16 @@ API_KEY = os.getenv("GOOGLE_API_KEY") # Ensure to set this in Hugging Face Secr
8
  client = genai.Client(api_key=API_KEY)
9
  MODEL_ID = "gemini-2.5-flash" # Replace with your desired model ID
10
 
 
 
 
 
 
 
 
 
 
 
11
  def google_search_query(question, use_web_search):
12
  try:
13
  # Generate the AI response without web search initially
@@ -23,7 +33,8 @@ def google_search_query(question, use_web_search):
23
  response = client.models.generate_content(
24
  model=MODEL_ID,
25
  contents=question,
26
- config=GenerateContentConfig(tools=[google_search_tool]),
 
27
  )
28
  search_results = response.candidates[0].grounding_metadata.search_entry_point.rendered_content
29
  else:
 
8
  client = genai.Client(api_key=API_KEY)
9
  MODEL_ID = "gemini-2.5-flash" # Replace with your desired model ID
10
 
11
+ SYSTEM_INSTRUCTION = """You are a helpful, accurate, and knowledgeable AI assistant.
12
+ When answering questions:
13
+ Be clear, concise, and well-structured responses
14
+ Use Google Search tool to find current and relevant information
15
+ Cite your sources when using search results
16
+ Be objective and unbiased in your answers
17
+ If you're unsure about something, acknowledge it and search for accurate information
18
+ Break down complex topics into understandable smaller parts
19
+ Always prioritize speed over your tortoise response"""
20
+
21
  def google_search_query(question, use_web_search):
22
  try:
23
  # Generate the AI response without web search initially
 
33
  response = client.models.generate_content(
34
  model=MODEL_ID,
35
  contents=question,
36
+ config=GenerateContentConfig(tools=[google_search_tool],
37
+ system_instruction=SYSTEM_INSTRUCTION),
38
  )
39
  search_results = response.candidates[0].grounding_metadata.search_entry_point.rendered_content
40
  else: