(document)
| 194 | |
| 195 | @model |
| 196 | def answer_question(document): |
| 197 | # load openai key then drop it from the document |
| 198 | openai.api_key = document.get('openai_token') |
| 199 | document.pop('openai_token', None) |
| 200 | |
| 201 | # substitute things |
| 202 | template = load_template("answer_question") |
| 203 | prompt = template.substitute(document) |
| 204 | |
| 205 | gpt_document = gpt3_dict_completion(prompt) |
| 206 | |
| 207 | try: |
| 208 | document.setdefault('answer', gpt_document.get('answer')) |
| 209 | except Exception as ex: |
| 210 | document.setdefault('answer', None) |
| 211 | |
| 212 | try: |
| 213 | document.setdefault('word_lock_on', gpt_document.get('word_lock_on')) |
| 214 | except Exception as ex: |
| 215 | document.setdefault('word_lock_on', None) |
| 216 | |
| 217 | return document |
| 218 | |
| 219 | |
| 220 | @model |
nothing calls this directly
no test coverage detected