#someone tried the new way to use the api
1 messages · Page 1 of 1 (latest)
u tried the old method as well? what is better in it?
Output text was more reasonable and detailed
do you know why is that? cuz actually they use the same models and it looks like just easier code but not neccerly better
do you know if they made the create_context function better? the one that use cosine similarrity checks
as I am not developer from openai, I don't know in detail what they did in models.
I have tested using gpt-4 turbo model
what was the intstructions u puted and the question u asked? im curious cuz i try build a chatbot for custom uses case.
I have tested JSON creating
what is it mean?
Using that model, I have tested JSON creating task.
Using gpt-4 model, sometimes, it could not create json
but using gpt-4 turbo, it always created json
I felt improvement there so
intresting..
yes,
can i share with u piece of my code and u tell me what do u think about it and if better for me to move to the new api way?
no worries,
def generate_answer(
df,
question,
messages,
model="gpt-4",
max_len=500,
size="ada",
max_tokens=150,
stop_sequence=None,
):
try:
context,most_useful_link = create_context(question, df, max_len=max_len, size=size)
# Continue with further processing using 'context' and 'useful_link'
except Exception as e:
# Handle the error or exception as per your requirement
print(f"An error occurred: {e}")
# You can also log the error, raise a more specific exception, or take other appropriate actions
try:
combined_message_content = f"You are the AI assistant, designed to provide helpful information and guidance on various topics. Please offer informative and concise responses based on the context provided in this conversation. If you encounter a question for which there is no specific guideline available, kindly respond with 'I don't know.'\n\nContext: {context}\n\nQuestion: {question}"
messages.append({"role": "user", "content": combined_message_content})
response = openai.ChatCompletion.create(
model=model,
messages=messages,
temperature=0.1,
max_tokens=max_tokens,
stream=True
)
# Break the response into chunks and yield them
for chunk in response:
#print(chunk.choices[0].delta.get("content", ""),
#end = "",
#flush = True)
yield chunk.choices[0].delta.get("content", "")
# Append the link to the final chunk and yield it
print(combined_message_content)
final_chunk =f'\nRelated link: {most_useful_link}'
yield final_chunk
- can you just replace model="gpt-4" to model="gpt-4-1106-preview"?