Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -117,6 +117,23 @@ def transcribe_function(state: AppState, new_chunk):
|
|
117 |
threading.Thread(target=auto_reset_state).start()
|
118 |
return state, full_text
|
119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
# Function to generate a response using the prompt and the context
|
121 |
def generate_response_with_prompt(context, question):
|
122 |
formatted_prompt = prompt.format(context=context, question=question)
|
|
|
117 |
threading.Thread(target=auto_reset_state).start()
|
118 |
return state, full_text
|
119 |
|
120 |
+
|
121 |
+
# Function to generate a full-text search query for Neo4j
|
122 |
+
def generate_full_text_query(input: str) -> str:
|
123 |
+
# Split the input into words, ignoring any empty strings
|
124 |
+
words = [el for el in input.split() if el]
|
125 |
+
|
126 |
+
# Check if there are no words
|
127 |
+
if not words:
|
128 |
+
return "" # Return an empty string or a default query if desired
|
129 |
+
|
130 |
+
# Create the full-text query with fuzziness (~2 for proximity search)
|
131 |
+
full_text_query = ""
|
132 |
+
for word in words[:-1]:
|
133 |
+
full_text_query += f" {word}~2 AND"
|
134 |
+
full_text_query += f" {words[-1]}~2"
|
135 |
+
return full_text_query.strip()
|
136 |
+
|
137 |
# Function to generate a response using the prompt and the context
|
138 |
def generate_response_with_prompt(context, question):
|
139 |
formatted_prompt = prompt.format(context=context, question=question)
|