#Why is the Assisant not following instructions?

1 messages · Page 1 of 1 (latest)

spring flume
#

def create_thread():
config = read_config()
thread_id = config.get('thread_id')
if not thread_id:
thread = client.beta.threads.create()
thread_id = thread.id
config['thread_id'] = thread_id
write_config(config)
return thread_id

def add_user_message(content):
config = read_config()
thread_id = config.get('thread_id')
create_thread()
client.beta.threads.messages.create(
thread_id=thread_id,
role="user",
content=content
)

def initiate_run(assistant_id):
config = read_config()
thread_id = config.get('thread_id')
create_thread()
return client.beta.threads.runs.create(
thread_id=thread_id,
assistant_id=assistant_id,
instructions="If a message is sent in english, translate it into farsi, if its sent in farsi, translate it to english."
)

def wait_for_run_completion(run_id):
config = read_config()
thread_id = config.get('thread_id')
while True:
run_status = client.beta.threads.runs.retrieve(thread_id=thread_id, run_id=run_id)
if run_status.status == "completed":
break
time.sleep(1)

def get_latest_assistant_message():
config = read_config()
thread_id = config.get('thread_id')
create_thread()
response = client.beta.threads.messages.list(thread_id=thread_id, limit=1, order='desc')
messages = response.data
for message in messages:
if message.role == "assistant":
return message.content[0].text.value
return "No response from the assistant."

the AI doesn't transalte anyhthing - it doesn't follow thje set instructions why is this

visual emberBOT
#

Hi @spring flume. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

There could be several reasons why the Assistant is not following the instructions as expected. Here are a few possibilities based on the information provided in the knowledge sources:

  1. Overwriting Instructions: According to a forum post (https://community.openai.com/t/534101), if you provide an instruction with the run method, it will overwrite the one with the assistant. Make sure you're not overwriting the instructions unintentionally.

  2. Check Run Status: Another point from the same forum post (https://community.openai.com/t/534101) is that you must continue to check the status of the run to finally get an answer after the AI has been writing (or retrieving or coding) and is finished. A script that immediately checks just once isn’t enough waiting. In your code, you have a wait_for_run_completion function that checks the run status, make sure it's being used correctly.

  3. Message Handling: In another forum post (https://community.openai.com/t/638516), a user found that they had to add the message to the thread before starting the run. Make sure you're handling the messages correctly in your add_user_message and initiate_run functions.

  4. Language Support: The Assistant might not be able to translate between English and Farsi. The language capabilities of the Assistant depend on the underlying model and the specific implementation of OpenAI's API.

If you're still having trouble, it might be helpful to reach out to OpenAI's support or check their documentation for more information.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@spring flume kapa.ai is still learning and improving, please let us know how it did by reacting below

spring flume
#

so how would i fix it?

#

@visual ember how do i fix it in my code?

visual emberBOT
#

Let me check the knowledge base for you. One moment! :books:

#

Based on the information provided in the knowledge sources, I'm unable to provide a specific code fix for your issue. The knowledge sources do not contain enough information about the specific problem you're encountering or the context of your code.

However, here are some general suggestions based on the potential issues I mentioned earlier:

  1. Overwriting Instructions: Make sure you're not overwriting the instructions unintentionally. Check the places in your code where you're setting instructions and ensure they're not being overwritten later.

  2. Check Run Status: Ensure that you're using the wait_for_run_completion function correctly to wait for the run to complete before trying to retrieve the assistant's message.

  3. Message Handling: Make sure you're adding the user message to the thread before starting the run. Check the order of operations in your add_user_message and initiate_run functions.

  4. Language Support: If the issue is with language support, you might need to use a different method or service for translation.

If you're still having trouble, I recommend reaching out to OpenAI's support or checking their documentation for more information.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: