I’m not able to receive the expected answer as it is returned in the Website Q&A with Embedding tutorial, after walking through the complete user guide. The complete OpenAI website page has been crawled and persisted on my local computer as instructed in the tutorial.
Take this question as an example: “What is our newest embeddings model?”
It appears that the answer from the create_context function includes the keyword as shown in the screenshot below such as “ext-embedding-ada-002”
. But I don’t understand why client.chat.completions.create still returned the answer “I don’t know”.
Has anyone experienced the same issues here? Is the official tutorial still valid?
My Code Snippet:
def answer_question(
df,
model="gpt-3.5-turbo",
question="Am I allowed to publish model outputs to Twitter, without a human review?",
max_len=1800,
size="ada",
debug=False,
max_tokens=150,
stop_sequence=None
):
"""
Answer a question based on the most similar context from the dataframe texts
"""
context = create_context(
question,
df,
max_len=max_len,
size=size,
)
# If debug, print the raw model response
if debug:
print("Context:\n" + context)
print("\n\n")
try:
# Create a chat completion using the question and context
response = client.chat.completions.create(
model="gpt-4-turbo-preview",
messages=[
{"role": "system", "content": "Answer the question based on the context below, and if the question can't be answered based on the context, say \"I don't know\"\n\n"},
{"role": "user", f"content": "Context: {context}\n\n---\n\nQuestion: {question}\nAnswer:"}
],
temperature=0,
max_tokens=max_tokens,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
stop=stop_sequence,
)
return response.choices[0].message.content
except Exception as e:
print(e)
return ""