How to send reponse based on sender id

Question:
how can I create response specific for the sender id. So that two users don’t collide . Thank you!!

Repl link/Link to where the bug appears:

Screenshots, links, or other helpful context:

@app.route('/twilio/receiveMessage', methods=['POST'])
def receiveMessage():
    try:
        # Extract incoming parameters from Twilio
        message = request.form['Body']
        sender_id = request.form['From']

        # Get response from OpenAI
        #refind = ref_prompt(message)
        result = text_complition(message)

        # print(result['response'])
        if result['status'] == 1:
            send_message(sender_id, result['response'])
    except:
        pass

    return 'OK', 200
this is the API function where text_complition is called and 
def text_complition(query: str) -> dict:
  tools = [tool]

  try:
    agent = OpenAIFunctionsAgent(llm=llm, tools=tools, prompt=prompt)
    agent_executor = AgentExecutor(agent=agent,
                                   tools=tools,
                                   memory=memory,
                                   verbose=False)
    response = agent_executor.run(query)
    return {"status": 1, "response": response}
  except:
    return {"status": 0, "response": ""}

this is the text_completion function

To create a UUID (Universally Unique Identifier), this python function should do the trick:

import uuid
def generate_uuid():
  return uuid.uuid4()

This will generate an ID that will (almost – see below) never repeat.


According to this StackOverflow post, “the annual risk of a given person being hit by a meteorite is estimated to be one chance in 17 billion, which means the probability is about 0.00000000006 (6 × 10−11), equivalent to the odds of creating a few tens of trillions of UUIDs in a year and having one duplicate. In other words, only after generating 1 billion UUIDs every second for the next 100 years, the probability of creating just one duplicate would be about 50%.”

2 Likes