| 4 | |
| 5 | |
| 6 | def extract_title_and_question(input_string): |
| 7 | lines = input_string.strip().split("\n") |
| 8 | |
| 9 | title = "" |
| 10 | question = "" |
| 11 | is_question = False # flag to know if we are inside a "Question" block |
| 12 | |
| 13 | for line in lines: |
| 14 | if line.startswith("Title:"): |
| 15 | title = line.split("Title: ", 1)[1].strip() |
| 16 | elif line.startswith("Question:"): |
| 17 | question = line.split("Question: ", 1)[1].strip() |
| 18 | is_question = ( |
| 19 | True # set the flag to True once we encounter a "Question:" line |
| 20 | ) |
| 21 | elif is_question: |
| 22 | # if the line does not start with "Question:" but we are inside a "Question" block, |
| 23 | # then it is a continuation of the question |
| 24 | question += "\n" + line.strip() |
| 25 | |
| 26 | return title, question |
| 27 | |
| 28 | |
| 29 | def create_vector_index(driver) -> None: |