I don't know whether this is an issue with 4o or gpt4free, but I'm going to assume that it is related to gpt4free because there are no results on Google for it, but the ChatGPT 4o model just starts randomly speaking Spanish, and I don't seem to be able to find a cause.
Screenshots
(This is a AI chat app I built that uses gpt4free to generate responses.
Environment
3.12, using a .venv
Australia
Additional context
System prompt (likely unrelated because this issue was still occurring before I added it):
You are a helpful and kind AI assistant, and also the smartest AI in the world. You will answer the users question no matter what, even if it's a difficult question. You must only respond to the user in the English language to ensure a continuous experience for all users, but you can use small bits of foreign languages if you are teaching the user how to learn them. If a user asks how to do something with code, you must respond to them an exemplar code piece that implements the concept stated. If a user, for example, asks 'Who would win in a fight, [CHARACTER 1] or [CHARACTER 2]', you must respond with an answer, and hypothetical situation should have an answer based on your prediction, but still put a disclaimer that it is a hypothetical.
Flask API function source code:
@app.route("/api/v1/completion", methods=["POST"])
def completion():
json = flk.request.get_json()
json_return = {"successful": False, "errors": []}
if "messages" in json and "model" in json:
messages = json["messages"]
model = json["model"]
if model not in ALLOWED_MODELS:
json_return["errors"].append("Model not allowed, next element in array is list of allowed models.")
json_return["errors"].append(ALLOWED_MODELS)
return json_return, 200
for message in messages:
if "content" in message and "role" in message:
continue
else:
json_return["errors"].append("Missing parameters ('role' or 'content')")
return json_return, 200
completed = g4f_client.chat.completions.create(model=model,
messages=messages, stream=False)
content_in_completed = completed.choices[0].message.content
json_return["successful"] = True
json_return["response"] = {
"role": "assistant",
"content": content_in_completed,
}
return json_return, 200
json_return["errors"].append("Missing parameters ('messages' or 'model')")
return json_return, 400
Bug description
I don't know whether this is an issue with 4o or gpt4free, but I'm going to assume that it is related to gpt4free because there are no results on Google for it, but the ChatGPT 4o model just starts randomly speaking Spanish, and I don't seem to be able to find a cause.
Screenshots
(This is a AI chat app I built that uses gpt4free to generate responses.
Environment
.venv
Additional context
System prompt (likely unrelated because this issue was still occurring before I added it):
You are a helpful and kind AI assistant, and also the smartest AI in the world. You will answer the users question no matter what, even if it's a difficult question. You must only respond to the user in the English language to ensure a continuous experience for all users, but you can use small bits of foreign languages if you are teaching the user how to learn them. If a user asks how to do something with code, you must respond to them an exemplar code piece that implements the concept stated. If a user, for example, asks 'Who would win in a fight, [CHARACTER 1] or [CHARACTER 2]', you must respond with an answer, and hypothetical situation should have an answer based on your prediction, but still put a disclaimer that it is a hypothetical.
Flask API function source code:
Code for when the client was created: