Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,10 +10,37 @@ client=InferenceClient("Qwen/Qwen2.5-72B-Instruct")
|
|
10 |
# Open the water_cycle.txt file in read mode with UTF-8 encoding
|
11 |
with open("Safe_restaurant", "r", encoding="utf-8") as file:
|
12 |
# Read the entire contents of the file and store it in a variable
|
13 |
-
|
14 |
|
15 |
# Print the text below
|
16 |
-
print(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
def respond(message, history):
|
19 |
#responses = ["Yes", "No"]
|
|
|
10 |
# Open the water_cycle.txt file in read mode with UTF-8 encoding
|
11 |
with open("Safe_restaurant", "r", encoding="utf-8") as file:
|
12 |
# Read the entire contents of the file and store it in a variable
|
13 |
+
safe_restaurant = file.read()
|
14 |
|
15 |
# Print the text below
|
16 |
+
print(safe_restaurant)
|
17 |
+
|
18 |
+
#step 3 from smentic search(chunck data)
|
19 |
+
def preprocess_text(text):
|
20 |
+
# Strip extra whitespace from the beginning and the end of the text
|
21 |
+
cleaned_text = text.strip()
|
22 |
+
|
23 |
+
# Split the cleaned_text by every newline character (\n)
|
24 |
+
chunks = cleaned_text.split("\n")
|
25 |
+
|
26 |
+
# Create an empty list to store cleaned chunks
|
27 |
+
cleaned_chunks = []
|
28 |
+
|
29 |
+
# Write your for-in loop below to clean each chunk and add it to the cleaned_chunks list
|
30 |
+
for chunk in chunks:
|
31 |
+
chunk = chunk.strip()
|
32 |
+
if (chunk != ""):
|
33 |
+
cleaned_chunks.append(chunk)
|
34 |
+
# Print cleaned_chunks
|
35 |
+
print(cleaned_chunks)
|
36 |
+
# Print the length of cleaned_chunks
|
37 |
+
len(cleaned_chunks)
|
38 |
+
|
39 |
+
# Return the cleaned_chunks
|
40 |
+
return cleaned_chunks
|
41 |
+
|
42 |
+
# Call the preprocess_text function and store the result in a cleaned_chunks variable
|
43 |
+
cleaned_chunks = preprocess_text(safe_restaurant)
|
44 |
|
45 |
def respond(message, history):
|
46 |
#responses = ["Yes", "No"]
|