Skip to content

Feature Request: Support passing in custom prompt templates into find_themes #64

Description

@WarwickEverett-ipo

A small Quality of Life request more than anything else.

Currently you are unable to to pass in paths / custom prompt templates into the find_themes function and have these be passed down into the separate underlying functions such as sentiment_analysis or theme_generation

allowing users to do so would simplify usage and could be implemented by simply starting with a dictionary of the default prompts and updating that with what prompts the user passes in. would need clear guidance on what keys affect which part for users.

for example:

async def find_themes(
    responses_df: pd.DataFrame,
    llm: RunnableWithFallbacks,
    question: str,
    target_n_themes: int | None = None,
    system_prompt: str = CONSULTATION_SYSTEM_PROMPT,
    verbose: bool = True,
    concurrency: int = 10,
    prompt_templates: dict = {} # New argument
) -> dict[str, str | pd.DataFrame]:

   prompt = { <fill with default prompt ref for each function >   }  |  prompt_templates # updates the default list with user provided 

...
# functions already have prompt_template argument so shouldn't require any lower level changes.  just updating calls in find_themes function
sentiment_df, sentiment_unprocessables = await sentiment_analysis(
        responses_df,
        llm,
        question=question,
        system_prompt=system_prompt,
        prompt_template = prompt["sentiment"] # refer to appropriate prompt in dict. 
        concurrency=concurrency,
    )

Other option would be to pass them in using the **kwargs but then you'd have to work out which kwarg applies to which underlying function.

seems like quick win. Would have provided a PR however, the contributing.md says raise an issue, so here you go :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions