def send_prompt()

in infrastructure/cymbal-store-embeddings/cymbal_store.py [0:0]


def send_prompt(e: me.ClickEvent):
    state = me.state(State)
    if not state.conversations:
        for model in state.models:
            state.conversations.append(Conversation(model=model, messages=[]))
    input = state.input
    state.input = ""
    yield

    for conversation in state.conversations:
        model = conversation.model
        messages = conversation.messages
        history = messages[:]
        messages.append(ChatMessage(role="user", content=input))
        messages.append(ChatMessage(role="model", in_progress=True))
        yield

        if model == Models.GEMINI_2_0_FLASH.value:
            while True:
                intent_str = gemini_model.classify_intent(input)
                print(intent_str)
                logging.info(f"PRODUCTS LIST: {intent_str}")
                try:
                    json_intent = json.loads(intent_str)
                except json.JSONDecodeError as e:
                    print(f"Error decoding JSON: {e}")
                    continue
                break

            if json_intent["shouldRecommendProduct"] is True:
                search_embedding = gemini_model.generate_embedding(json_intent["summary"])
                products_list = get_products(db, str(search_embedding["embedding"]))
                logging.info(f"PRODUCTS LIST: {products_list}")
                print(f"PRODUCTS LIST: {products_list}")
                persona="You are friendly assistance in a store helping to find a products based on the client's request"
                safeguards="You should give information about the product, price and any supplemental information. Do not invent any new products and use for the answer the product defined in the context"
                context="""