Backend
__main__.py
Entry point that launches a uvicorn server and connects the backend reading, generation, and writing functionalities
main()
Start uvicorn server
Source code in src/chatbot_util/__main__.py
15 16 17 18 19 20 21 22 23 24 | |
start()
Read info from files, append generated questions, then write to new file, indicating whether the run was interrupted
Source code in src/chatbot_util/__main__.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
verify()
Determine whether the updated Permutated.csv has any modified or missing entries (and not just new ones)
Source code in src/chatbot_util/__main__.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
api.py
API routes and implementations for the uvicorn server launched in __main__.py
config()
Return CDN links to FAQ - Enter Here.csv and Other.txt
Status codes
200= no errors encountered while reading links from config
Config keys
faq= CDN link toFAQ - Enter Here.csvother= CDN link toOther.txt
Source code in src/chatbot_util/api.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
files()
Report on data file status
Status codes
200= no errors encountered while scanning for files
present
True= all files are presentFalse= some files are missing
Source code in src/chatbot_util/api.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
generate(response)
Create chain, read info from files, append generated questions, then write to new file
Status codes
201= successfully generatedPermutated.csv429= request denied because generation is in progress
verified
True= verifiedFalse= unverified, check diffNone= generation interrupted
Source code in src/chatbot_util/api.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
health(response)
Health check for both uvicorn and ollama servers
Status codes
200= uvicorn and ollama are ready500= ollama is not available
Source code in src/chatbot_util/api.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
interrupt()
Interrupt the current generation task
Status codes
200= successfully interrupted generation ofPermutated.csv
Source code in src/chatbot_util/api.py
101 102 103 104 105 106 107 108 109 110 111 | |
progress()
Report on generation progress
Status codes
200= successfully retrieved progress status
Response keys
index= index of topic currently generating queries for, [1-total]total= total number of topics to generate queries for
Source code in src/chatbot_util/api.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
upload(files)
Replace data files via upload and return list of status codes
Status codes
201= no errors encountered when replacing file(s)422= validation error while processing file(s)
uploaded
True= succssfully replaced all filesFalse= some files failed to be replaced
Source code in src/chatbot_util/api.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
chain.py
Setup language model and output parser, then generate and append new questions
Progress
Representation of generation progress with utility method for updating and logging
Source code in src/chatbot_util/chain.py
11 12 13 14 15 16 17 18 19 20 21 22 23 | |
update(index)
Update and log generation progress
Source code in src/chatbot_util/chain.py
20 21 22 23 | |
generate(store, phrases)
Generate and append new questions to store
Source code in src/chatbot_util/chain.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
handle_interrupt()
Helper to reset chain state when interrupted
Source code in src/chatbot_util/chain.py
33 34 35 36 37 38 39 40 41 42 43 44 | |
invoke(prompt, phrases)
Define chat model, then create the chain
Source code in src/chatbot_util/chain.py
79 80 81 82 83 84 85 86 87 88 89 | |
parse(response, phrases)
Parse lines from LLM and clean them before returning
Source code in src/chatbot_util/chain.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
file_io.py
Reads toml config, csv, employees, and answers, and writes generated result to csv
create_file(f)
Create or replace a data file
Source code in src/chatbot_util/file_io.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
read()
Read questions from csv file, read teams, employees, phrases and answers from text files
Source code in src/chatbot_util/file_io.py
204 205 206 207 208 209 210 211 212 213 214 215 216 | |
read_answers(lines)
Read and return answers for cen and teams
Source code in src/chatbot_util/file_io.py
170 171 172 173 174 175 176 177 178 179 | |
read_basic(lines)
Read and return basic answers for topics other than CEN
Source code in src/chatbot_util/file_io.py
160 161 162 163 164 165 166 167 | |
read_cen(lines)
Read and return cen_answers
Source code in src/chatbot_util/file_io.py
147 148 149 150 151 152 153 154 155 156 157 | |
read_config()
Read links from config file
Source code in src/chatbot_util/file_io.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
read_employees(lines)
Read and return employee list
Source code in src/chatbot_util/file_io.py
123 124 125 126 127 128 129 130 131 132 133 | |
read_entries(filename, teams)
Read and return topics and basic answers
Source code in src/chatbot_util/file_io.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
read_other(filename)
Read and return employees, phrases, and answers
Source code in src/chatbot_util/file_io.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
read_phrases(lines)
Read and return phrases to find and replace
Source code in src/chatbot_util/file_io.py
136 137 138 139 140 141 142 143 144 | |
read_teams(lines)
Read and return teams
Source code in src/chatbot_util/file_io.py
82 83 84 | |
write(store, teams, employees, answers, nums)
Format questions and topics, write to csv file
Source code in src/chatbot_util/file_io.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
utils.py
Utilities for logging and creating + cleaning answers based on file content
Answers
Bases: TypedDict
Representation of the answer dict variants expected for each topic
Source code in src/chatbot_util/utils.py
25 26 27 28 29 | |
Indices
Bases: TypedDict
Representation of the indices dict variants expected for each topic
Source code in src/chatbot_util/utils.py
39 40 41 42 43 | |
Nums
Bases: TypedDict
Representation of the nums dict variants expected for each topic
Source code in src/chatbot_util/utils.py
32 33 34 35 36 | |
clean_entry(question, answer)
Clean up unnecessary quotes
Source code in src/chatbot_util/utils.py
128 129 130 131 132 133 134 135 136 137 138 | |
create_answer(topic, question, teams, employees, answers, nums, indices)
Convert topics to answers depending on whether the topic is a person, CEN, or other
Source code in src/chatbot_util/utils.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
create_cen_answer(question, cen_answers, num_cen, cen_index)
Update CEN topics to be the relevant answer
Source code in src/chatbot_util/utils.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
create_cen_answer_helper(question, cen_answer)
Format answer based on question content
Source code in src/chatbot_util/utils.py
56 57 58 59 60 61 62 63 64 65 66 | |
create_other_answer(answers, num, index)
Update other topics to be the relevant answer
Source code in src/chatbot_util/utils.py
87 88 89 90 91 92 93 94 95 96 | |
create_person_answer(topic, employees)
Update person topics to be their contact info
Source code in src/chatbot_util/utils.py
46 47 48 49 50 51 52 53 | |