[Python] How to Reduce time when formatting the Cypher result?

Discussão em 'Python' iniciado por Stack, Março 26, 2025.

  1. Stack

    Stack Membro Participativo

    I'm retrieving results from a Cypher query, which includes the article's date and text.

    After fetching the results, I'm formatting them before passing them to the LLM for response generation. Currently, I'm using the following approach for formatting:

    context_text = "\n".join(map(lambda row: f"{row['article.date']} {row['article.text']}", results))


    However, this formatting step alone takes 10-15 seconds. How can I optimize this process to reduce execution time?

    context_text = "\n".join(
    [f"[{row['article.date']}] {row['article.text']}" for row in results]
    )


    Changing code to this, doesn't help either.

    Continue reading...

Compartilhe esta Página