def create_conversation_profile()

in src/agent_assist/agent_assist.py [0:0]


    def create_conversation_profile(
        self,
        display_name,
        knowledge_base_id: str,
        project_id,
        suggestion_type: str,
        no_small_talk: bool = True,
        only_end_user: bool = True,
        max_results: int = 3,
        language_code: str = "en-US") -> types.ConversationProfile:
        """ Create & configure a conversation profile as per the given input.

        Args:
            display_name (str):
                Required. Human readable name for this
                profile. Max length 1024 bytes.
            project_id (str):
                Required. The project to create a conversation profile for.
            knowledge_base_id (str):
                The knowledge base id of the knowledge base to be configured
                with the conversation profile.
            suggestion_type (str):
                The agent assist feature to be configured with the
                conversation profile.
                Allowed values are: ARTICLE_SUGGESTION, FAQ & SMART_REPLY.
            no_small_talk (bool):
                Do not trigger if last utterance is small talk.
            only_end_user (bool):
                Only trigger suggestion if participant role of last
                utterance is END_USER.
            max_results (int):
                Maximum number of results to return.
                Currently, if unset, defaults to 10. And the max number is 20.
            language_code (str):
                Language code for the conversation profile. If not
                specified, the language is en-US. Language at
                ConversationProfile should be set for all non en-us
                languages. This should be a
                `BCP-47 <https://www.rfc-editor.org/rfc/bcp/bcp47.txt>`__
                language tag. Example: "en-US".

        Returns:
            Conversation profile to be used for incoming
            Dialogueflow conversations.
            type: google.cloud.dialogflow_v2beta1.types.ConversationProfile
        """

        client = services.conversation_profiles.ConversationProfilesClient(
            credentials = self.creds
            )

        project_path = client.common_project_path(project_id)
        logging.info(f"Project Path : {project_path}")

        conversation_profile = types.ConversationProfile()
        conversation_profile.display_name = display_name
        conversation_profile.language_code = language_code

        hac_config = types.HumanAgentAssistantConfig
        feature_config = hac_config.SuggestionFeatureConfig()

        # Configuring Suggestion Type
        suggestion_feature = types.SuggestionFeature()
        suggestion_feature.type_ = suggestion_type

        feature_config.suggestion_feature = suggestion_feature

        # Configuring the trigger settings
        trigger_settings = hac_config.SuggestionTriggerSettings()
        trigger_settings.no_small_talk = no_small_talk
        trigger_settings.only_end_user = only_end_user

        feature_config.suggestion_trigger_settings = trigger_settings

        # Configuring the query config.
        query_config = hac_config.SuggestionQueryConfig()

        kb_path = KnowledgeBasesClient.knowledge_base_path(
            project_id, knowledge_base_id
            )
        logging.info(f"Knowledge Base Path : {kb_path}")
        query_config.knowledge_base_query_source.knowledge_bases=[kb_path]

        query_config.max_results = max_results
        feature_config.query_config = query_config

        conversation_profile.human_agent_assistant_config.human_agent_suggestion_config.feature_configs = [feature_config] # noqa: E501

        request = types.conversation_profile.CreateConversationProfileRequest(
                    parent= project_path,
                    conversation_profile=conversation_profile,
                )

        # Make the request
        response = client.create_conversation_profile(request=request)
        logging.info("Conversation Profile created...")
        logging.info(f"Display Name: {response.display_name}")
        logging.info(f"Name: {response.name}")

        return response