Skip to content

Instantly share code, notes, and snippets.

@john-adeojo
Last active December 31, 2021 10:01
Show Gist options
  • Save john-adeojo/f599d5df787c3e65032c8040294b8221 to your computer and use it in GitHub Desktop.
Save john-adeojo/f599d5df787c3e65032c8040294b8221 to your computer and use it in GitHub Desktop.
# Knowledge engine question and answer
if button:
response_json = openai.Answer.create(
search_model="ada",
model="davinci",
question=question,
file=openai.File.list()['data'][-1]['id'], # Get latest file
examples_context= "In 2017, U.S. life expectancy was 78.6 years." ,
examples=[["What is human life expectancy in the United States?", "78 years."]],
max_rerank=300,
max_tokens=100,
stop=["\n", "<|endoftext|>"]
)
# Return answer to UI
st.markdown(response_json["answers"][0], unsafe_allow_html=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment