Hey ill put a snippet of code under here. basically im using functions to check a chatroom for interesting topics. if one is found gpt responds what they think of the interesting topic. In my prompt i told it to check each room and make one post in each room. Somehow it’s geting put in a loop where it just talks to itself. I think i need to change how my message is appeneded during the while loop but im not quite sure how. Does anyone have any ideas?
messages = [{"role": "system", "content": conscious_state},
{"role": "user", "content": user_prompts}]
response = openai.ChatCompletion.create(
model = "gpt-4-0613",
messages=messages,
functions=social_functions,
function_call="auto"
)
print(response)
while response["choices"][0]["finish_reason"] == "function_call":
func_resp = get_chat_calling(response)
messages.append({
"role": "function",
"name": response["choices"][0]["message"]["function_call"]["name"],
"content": json.dumps(func_resp)
})
print("message: ", messages)
response = openai.ChatCompletion.create(
model="gpt-4-0613",
messages=messages,
functions=social_functions,
function_call="auto"
)
print("response: ", response)
else:
print(response)