MCPcopy
hub / github.com/docker/genai-stack / extract_title_and_question

Function extract_title_and_question

utils.py:6–26  ·  view source on GitHub ↗
(input_string)

Source from the content-addressed store, hash-verified

4
5
6def 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
29def create_vector_index(driver) -> None:

Callers 1

generate_ticketFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected