code:
import os
import json
import logging

import openai

from dotenv import load_dotenv
import azure.functions as func
from pymongo.mongo_client import MongoClient

load_dotenv("D:/projects/TwT/TrackingDevice-Functions/.env")
try:
client = MongoClient(os.getenv('MONGODB_CONN_STRING'))
db = client['Tracker']
devices_col = db['trackingDevices']
except Exception as e:
logging.error(f"Error while connecting to MongoDB: {str(e)}")
raise

INDEX_NAME = os.getenv('INDEX_NAME')
EMBED_MODEL = os.getenv('EMBED_MODEL')
openai_client = openai.OpenAI(api_key=os.getenv('OPENAI_API'))

def embed_text(text):
"""
Convert text to embeddings using embedding model.


Args:
    text (str): The text to be embedded.

Returns:
    list: Embedding vector.
"""
try:
    res = openai_client.embeddings.create(
        input=[text],
        model=EMBED_MODEL
    )
    return res.data[0].embedding
except Exception as e:
    logging.error("Error while embedding text.")
def search(query):
try:
queryVector = embed_text(query)
pipeline = [
{
'$vectorSearch': {
'exact': False,
'index': INDEX_NAME,
'path': 'embedding',
'queryVector': queryVector,
'limit': 5,
'numCandidates': 10
}
}
]
results = devices_col.aggregate(pipeline)
formatted_docs = []
for i, result in enumerate(results, start=1):
formatted_doc = (
f"Device {i}:\n"
f" - ID: {result.get('id')}\n"
f" - Agent Name: {result.get('agentName')}\n"
f" - Status: {result.get('status')}\n"
f" - Current Location: {result.get('currentLocation')}\n"
f" - Agent Manager: {result.get('agentManagerName')}\n"
f" - Agent Email: {result.get('agentEmail')}\n"
f" - Phone Number: {result.get('phone')}\n"
)
formatted_docs.append(formatted_doc)
return '\n'.join(formatted_docs)


except Exception as e:
    logging.error(f"Error during vectorSearch on database: {str(e)}")
    raise
def query(prompt):
try:
response = openai_client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{'role': "system", "content": "You are a helpful assistant that uses given database entries, answer the query based on this data."},
{'role': "user", "content":prompt}
]
)


    return response.choices[0].message.content.strip()
except openai.APIError as e:
    logging.error(f"OpenAI API Error: {str(e)}")
    raise
except Exception as e:
    logging.error(f"Error while completing chat: {str(e)}")
    raise
def main(req: func.HttpRequest) -> func.HttpResponse:
try:
data = req.get_json()
query_text = data.get('query')
# group_id = data.get('group_id')


    agents_details = search(query_text)
    prompt = f"""
            {query_text}\n
            Details for reference:\n
            {agents_details}\n"""

    response = query(prompt)

    return func.HttpResponse(
        json.dumps({'message':response}),
        status_code=200,
        mimetype="application/json"
    )
except Exception as e:
    logging.error(f"Error while querying (main): {str(e)}")
    return func.HttpResponse(
        json.dumps({'error':str(e)}),
        status_code=400,
        mimetype="application/json"
    )
error:
{
"error": "PlanExecutor error during aggregation :: caused by :: "queryVector" Unexpected type found when parsing vector, full error: {'ok': 0.0, 'errmsg': 'PlanExecutor error during aggregation :: caused by :: "queryVector" Unexpected type found when parsing vector', 'code': 8, 'codeName': 'UnknownError', '$clusterTime': {'clusterTime': Timestamp(1731912567, 20), 'signature': {'hash': b".\x1d!\xbfZ'\xb1>\x05\x18\xea\xa6>\xee\x0bl\xfb\xf7\xe1\xf7", 'keyId': 7397863455467765761}}, 'operationTime': Timestamp(1731912567, 20)}"
}

the same API works fine when I run it locally but does not work after deployment on azure functions app, i have redeployed the api with all api and connection strings included in the code and it's still not working