mgokg commited on
Commit
fd1055b
·
verified ·
1 Parent(s): ad7c5c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -26
app.py CHANGED
@@ -6,7 +6,6 @@ import json
6
  import os
7
 
8
  secreturl = os.environ.get('secret_url')
9
-
10
  custom_css = """
11
  #md {
12
  height: 350px;
@@ -22,8 +21,7 @@ custom_css = """
22
  }
23
  """
24
 
25
-
26
- def parse_links(prompt):
27
  #anfrage ='fill in the missing contact information. do not reference the json object. do not use html tags inside the json object. it must be valid json. do not return explanaitons or any other text. thanks for your efforts:)'
28
  Name=prompt
29
  #outputs.value = "# Bitte warten"
@@ -52,7 +50,7 @@ def parse_links(prompt):
52
  "provider": "local",
53
  "model": "xenova-bge-small-en-v1.5"
54
  },
55
- "optimizationMode": "speed",
56
  "focusMode": "webSearch",
57
  #"query": f"Impressum Name={prompt}\n{anfrage}. outputformat=json",
58
  "query": f"antworte kurz und knapp. {prompt}. antworte auf deutsch. return plain text only für text zu sprache\n",
@@ -68,25 +66,11 @@ def parse_links(prompt):
68
 
69
  response = requests.post(url, json=payload, headers=headers)
70
  ergebnis = response.json().get('message')
71
- #ergebnis=gr.Markdown()
72
- ergebnis =ergebnis.replace("[1]", " ")
73
- ergebnis =ergebnis.replace("[2]", " ")
74
- ergebnis =ergebnis.replace("[3]", " ")
75
- ergebnis =ergebnis.replace("[4]", " ")
76
- ergebnis =ergebnis.replace("[5]", " ")
77
- ergebnis =ergebnis.replace("[6]", " ")
78
- ergebnis =ergebnis.replace("[7]", " ")
79
- ergebnis =ergebnis.replace("[8]", " ")
80
- ergebnis =ergebnis.replace("[9]", " ")
81
- ergebnis =ergebnis.replace("[10]", " ")
82
- ergebnis =ergebnis.replace("[11]", " ")
83
- ergebnis =ergebnis.replace("[12]", " ")
84
- ergebnis =ergebnis.replace("[13]", " ")
85
- ergebnis =ergebnis.replace("[14]", " ")
86
- ergebnis =ergebnis.replace("[15]", " ")
87
- ergebnis =ergebnis.replace("[16]", " ")
88
- ergebnis =ergebnis.replace("[17]", " ")
89
- ergebnis =ergebnis.replace("[18]", " ")
90
  return ergebnis
91
  # return as Dictionary, for gr.JSON
92
  #return {"body_text": body_text}
@@ -107,9 +91,8 @@ with gr.Blocks(css=custom_css, theme = gr.themes.Default(font=[gr.themes.GoogleF
107
  links_output = gr.Markdown(label="Antwort",elem_id="md")
108
  ort_input = gr.Textbox(label="Frage", placeholder="ask anything...", scale= 3, value="")
109
  #clearbutton = gr.Button("clear", elem_id="clear")
110
- button = gr.Button("senden", elem_id="senden")
111
-
112
- button.click(fn=parse_links, inputs=ort_input, outputs=links_output)
113
  #clearbutton.click(fn=clear, inputs=[], outputs=links_output)
114
 
115
  demo.launch()
 
6
  import os
7
 
8
  secreturl = os.environ.get('secret_url')
 
9
  custom_css = """
10
  #md {
11
  height: 350px;
 
21
  }
22
  """
23
 
24
+ def question(prompt):
 
25
  #anfrage ='fill in the missing contact information. do not reference the json object. do not use html tags inside the json object. it must be valid json. do not return explanaitons or any other text. thanks for your efforts:)'
26
  Name=prompt
27
  #outputs.value = "# Bitte warten"
 
50
  "provider": "local",
51
  "model": "xenova-bge-small-en-v1.5"
52
  },
53
+ "optimizationMode": "speed", #hier soll der wert stehen der ausgewählt wurd
54
  "focusMode": "webSearch",
55
  #"query": f"Impressum Name={prompt}\n{anfrage}. outputformat=json",
56
  "query": f"antworte kurz und knapp. {prompt}. antworte auf deutsch. return plain text only für text zu sprache\n",
 
66
 
67
  response = requests.post(url, json=payload, headers=headers)
68
  ergebnis = response.json().get('message')
69
+
70
+ for i in range(1, 19):
71
+ ergebnis = ergebnis.replace(f"[{i}]", " ")
72
+
73
+ ergebnis = gr.Markdown()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  return ergebnis
75
  # return as Dictionary, for gr.JSON
76
  #return {"body_text": body_text}
 
91
  links_output = gr.Markdown(label="Antwort",elem_id="md")
92
  ort_input = gr.Textbox(label="Frage", placeholder="ask anything...", scale= 3, value="")
93
  #clearbutton = gr.Button("clear", elem_id="clear")
94
+ button = gr.Button("senden", elem_id="senden")
95
+ button.click(fn=question, inputs=ort_input, outputs=links_output)
 
96
  #clearbutton.click(fn=clear, inputs=[], outputs=links_output)
97
 
98
  demo.launch()