5.3. Information Extraction
S: Hi, how should I call you?
U: My friends call me Jin, but you can call me Jinho. Some students call me Dr. Choi as well.How does the speaker want to be called? Respond in the one-line JSON format such as {"call_names": ["Mike", "Michael"]}: My friends call me Pete, my students call me Dr. Parker, and my parents call me Peter. def gpt_completion(input: str, regex: Pattern = None) -> str:
response = openai.ChatCompletion.create(
model='gpt-3.5-turbo',
messages=[{'role': 'user', 'content': input}]
)
output = response['choices'][0]['message']['content'].strip()
if regex is not None:
m = regex.search(output)
output = m.group().strip() if m else None
return outputLast updated
Was this helpful?