mgokg commited on
Commit
ea74c1e
·
verified ·
1 Parent(s): 9c2407c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -25
app.py CHANGED
@@ -32,16 +32,6 @@ def get_impressum_text(search_term):
32
  impressum_div = soup.find('body')
33
  return impressum_div.text
34
 
35
- if 'items' in search_results:
36
- for item in search_results['items']:
37
- link = item['link']
38
- response = requests.get(link, timeout=5) # Timeout hinzugefügt für Fehlerbehandlung
39
- response.raise_for_status() # Wirft eine Exception, wenn der Statuscode nicht 200 ist
40
- soup = BeautifulSoup(response.content, 'html.parser')
41
-
42
- impressum_div = soup.find('div', class_='MjjYud')
43
- return impressum_div.text.strip()
44
-
45
  def websearch(prompt):
46
 
47
  url = f"https://www.google.com/search?q={prompt}"
@@ -67,29 +57,38 @@ def websearch(prompt):
67
  return None
68
 
69
  def predict(prompt):
70
- # Create the model
71
  generation_config = {
72
- "temperature": 0.3,
73
- "top_p": 0.95,
74
- "top_k": 40,
75
- "max_output_tokens": 2048,
76
- "response_mime_type": "text/plain",
77
  }
78
 
79
  model = genai.GenerativeModel(
80
- #model_name="gemini-1.5-pro",
81
- model_name="gemini-2.0-flash-exp",
82
- generation_config=generation_config,
83
  )
84
 
85
  chat_session = model.start_chat(
86
- history=[
87
- ]
 
 
 
 
 
 
 
 
 
 
 
 
88
  )
89
-
90
- response = chat_session.send_message(prompt)
91
- #response = model.generate_content(contents=prompt, tools='google_search_retrieval')
92
- return response.text
93
 
94
  # Create the Gradio interface
95
  with gr.Blocks(css=custom_css) as demo:
 
32
  impressum_div = soup.find('body')
33
  return impressum_div.text
34
 
 
 
 
 
 
 
 
 
 
 
35
  def websearch(prompt):
36
 
37
  url = f"https://www.google.com/search?q={prompt}"
 
57
  return None
58
 
59
  def predict(prompt):
 
60
  generation_config = {
61
+ "temperature": 0.4,
62
+ "top_p": 0.95,
63
+ "top_k": 40,
64
+ "max_output_tokens": 8192,
65
+ "response_mime_type": "text/plain",
66
  }
67
 
68
  model = genai.GenerativeModel(
69
+ model_name="gemini-2.0-flash-exp",
70
+ generation_config=generation_config,
 
71
  )
72
 
73
  chat_session = model.start_chat(
74
+ history=[
75
+ {
76
+ "role": "user",
77
+ "parts": [
78
+ "return a json object with the contact details. leave blank if information is not available. here is the json schema:\n\n{\n \"organization\": \"\",\n \"address\": \"\",\n \"phone\": \"\",\n \"email\": \"\",\n \"website\": \"\"\n}\n\nyou can find the contact details here: \nImpressum – Aero-Club Bamberg e.V.\nAero-Club Bamberg\nhttps://aeroclub-bamberg.de › impressum\nAero-Club Bamberg e.V.. Zeppelinstraße 18. D-96052 Bamberg. Tel.: 0951 / 45 1 45. Fax: 0951 / 13 22 20. E-Mail: [email protected].\n",
79
+ ],
80
+ },
81
+ {
82
+ "role": "model",
83
+ "parts": [
84
+ "```json\n{\n \"organization\": \"Aero-Club Bamberg e.V.\",\n \"address\": \"Zeppelinstraße 18, D-96052 Bamberg\",\n \"phone\": \"0951 / 45 1 45\",\n \"email\": \"[email protected]\",\n \"website\": \"https://aeroclub-bamberg.de\"\n}\n```\n",
85
+ ],
86
+ },
87
+ ]
88
  )
89
+
90
+ response = chat_session.send_message("INSERT_INPUT_HERE")
91
+
 
92
 
93
  # Create the Gradio interface
94
  with gr.Blocks(css=custom_css) as demo: