farida5gaber commited on
Commit
87f91ca
·
verified ·
1 Parent(s): c60349f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -28
app.py CHANGED
@@ -13,32 +13,11 @@ def google_search_query(question):
13
  # Define the Google Search Tool
14
  google_search_tool = Tool(google_search=GoogleSearch())
15
 
16
- # Generate the response
17
- response = client.models.generate_content(
18
- model=MODEL_ID,
19
- contents=question,
20
- config=GenerateContentConfig(tools=[google_search_tool]),
21
- )
22
 
23
- # Extract AI response and search results
24
- ai_response = response.text # AI response as plain text
25
- search_results = response.candidates[0].grounding_metadata.search_entry_point.rendered_content
26
-
27
- return ai_response, search_results
28
- except Exception as e:
29
- return f"Error: {str(e)}", ""
30
-
31
- # Gradio Interface
32
- app = gr.Interface(
33
- fn=google_search_query,
34
- inputs=gr.Textbox(lines=2, label="Ask a Question"),
35
- outputs=[
36
- gr.Textbox(label="AI Response"),
37
- gr.HTML(label="Search Results"),
38
- ],
39
- title="Google Search with Gemini AI",
40
- description="Ask a question, and the AI will use Google search tools to provide an answer along with contextual search results.",
41
- )
42
-
43
- if __name__ == "__main__":
44
- app.launch(share=True)
 
13
  # Define the Google Search Tool
14
  google_search_tool = Tool(google_search=GoogleSearch())
15
 
16
+ # Make the prompt specific to perfumes and their production
17
+ perfume_prompt = f"""
18
+ You are an expert perfumer and fragrance chemist.
 
 
 
19
 
20
+ Answer the following question strictly in the context of:
21
+ - Perfumes and fragrances
22
+ - Perfume production and formulation
23
+ - Raw