MCPcopy Create free account
hub / github.com/FeatureBaseDB/DoctorGPT / answer_question

Function answer_question

lib/ai.py:196–217  ·  view source on GitHub ↗
(document)

Source from the content-addressed store, hash-verified

194
195@model
196def 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

Callers

nothing calls this directly

Calls 2

load_templateFunction · 0.85
gpt3_dict_completionFunction · 0.85

Tested by

no test coverage detected