mgokg commited on
Commit
1aa8a78
·
verified ·
1 Parent(s): a8b7167

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -1
app.py CHANGED
@@ -6,12 +6,34 @@ from gradio_client import Client
6
  from selenium.webdriver.support.wait import WebDriverWait
7
  from selenium.webdriver.support import expected_conditions as EC
8
  from selenium.webdriver.chrome.options import Options
 
 
 
 
9
  import time
10
 
11
  options = webdriver.ChromeOptions()
12
  options.add_argument('--headless')
13
  wd = webdriver.Chrome(options=options)
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  def selenium(message):
16
 
17
  try:
@@ -23,7 +45,8 @@ def selenium(message):
23
  element = wd.find_element(By.TAG_NAME, "body")
24
  #texts = [element.text for element in elements]
25
  time.sleep(1)
26
- return element.text
 
27
 
28
  except WebDriverException as e:
29
  return "fehler"
 
6
  from selenium.webdriver.support.wait import WebDriverWait
7
  from selenium.webdriver.support import expected_conditions as EC
8
  from selenium.webdriver.chrome.options import Options
9
+ from gradio_client import Client
10
+ import speech_recognition as sr
11
+ import groq
12
+ import os
13
  import time
14
 
15
  options = webdriver.ChromeOptions()
16
  options.add_argument('--headless')
17
  wd = webdriver.Chrome(options=options)
18
 
19
+ #get your api-key @groq.com. its free!
20
+ api_key = os.getenv('groq')
21
+ client = groq.Client(api_key=api_key)
22
+
23
+ # Use Llama 3 70B powered by Groq for answering
24
+ def update(prompt, ort):
25
+ try:
26
+ completion = client.chat.completions.create(
27
+ model="Mixtral-8x7b-32768",
28
+ messages=[
29
+ {"role": "system", "content": "You are a helpful assistant."},
30
+ {"role": "user", "content": f". gefragt sind die nächsten 3 zugverbindungen von bad kissingen nach {ort} du findest die antwort im kontext. liefer als antwort ein 2 spaltige tabelle. linke spalte: abfahrtszeit, fahrtdauer, ankunftszeit.rechte spalte: abfahrtsort,leer,zielort. formatiere die tabelle in markdown\n kontext: \n {prompt}"}
31
+ ],
32
+ )
33
+ return completion.choices[0].message.content
34
+ except Exception as e:
35
+ return f"Error in response generation: {str(e)}"
36
+
37
  def selenium(message):
38
 
39
  try:
 
45
  element = wd.find_element(By.TAG_NAME, "body")
46
  #texts = [element.text for element in elements]
47
  time.sleep(1)
48
+ results = update(message,element.text)
49
+ return results
50
 
51
  except WebDriverException as e:
52
  return "fehler"