diff --git a/assets/large_language_models/components_pipelines/data_ingestion_db_to_acs/asset.yaml b/assets/large_language_models/components_pipelines/data_ingestion_db_to_acs/asset.yaml deleted file mode 100644 index dbebe8dc08..0000000000 --- a/assets/large_language_models/components_pipelines/data_ingestion_db_to_acs/asset.yaml +++ /dev/null @@ -1,4 +0,0 @@ -spec: spec.yaml -type: component -categories: -- Retrieval Augmented Generation \ No newline at end of file diff --git a/assets/large_language_models/components_pipelines/data_ingestion_db_to_acs/spec.yaml b/assets/large_language_models/components_pipelines/data_ingestion_db_to_acs/spec.yaml deleted file mode 100644 index 67a15e43aa..0000000000 --- a/assets/large_language_models/components_pipelines/data_ingestion_db_to_acs/spec.yaml +++ /dev/null @@ -1,340 +0,0 @@ -$schema: https://azuremlschemas.azureedge.net/latest/pipelineComponent.schema.json -type: pipeline -tags: - Preview: "" -name: llm_ingest_db_to_acs -display_name: LLM - SQL Datastore to ACS Pipeline -version: 0.0.97 -description: Single job pipeline to chunk data from AzureML sql data store, and create ACS embeddings index -settings: - default_compute: serverless -inputs: - db_datastore: - type: string - description: database datastore uri in the format of 'azureml://datastores/{datastore_name}' - embeddings_model: - type: string - description: The model used to generate embeddings. 'azure_open_ai://endpoint/{endpoint_name}/deployment/{deployment_name}/model/{model_name}' - chat_aoai_deployment_name: - type: string - optional: true - description: The name of the chat AOAI deployment - embedding_aoai_deployment_name: - type: string - description: The name of the embedding AOAI deployment - embeddings_dataset_name: - type: string - description: The name of the acs index - max_tables: - type: integer - optional: true - max_columns: - type: integer - optional: true - max_rows: - type: integer - optional: true - max_sampling_rows: - type: integer - optional: true - max_text_length: - type: integer - optional: true - max_knowledge_pieces: - type: integer - optional: true - selected_tables: - type: string - optional: true - column_settings: - type: string - optional: true - llm_config: - type: string - optional: true - description: The name of the llm config - runtime: - type: string - optional: false - description: The name of the runtime - serverless_instance_count: - type: integer - optional: true - default: "1" - serverless_instance_type: - type: string - optional: true - default: Standard_DS3_v2 - embedding_connection: - type: string - optional: true - description: Azure OpenAI workspace connection ARM ID for embeddings - llm_connection: - type: string - optional: true - description: Azure OpenAI workspace connection ARM ID for LLM - acs_connection: - type: string - optional: true - description: Azure Cognitive Search workspace connection ARM ID - acs_config: - type: string - description: JSON describing the acs index to create or update for embeddings - sample_data: - type: uri_folder - description: "Sample data to be used for data ingestion. format: 'azureml:samples-test:1'" - optional: true - # path: "azureml:samples-test:1" - # data ingest setting - sample_acs_config: - type: string - description: "JSON describing the acs index to create or update for samples" - include_builtin_examples: - type: boolean - default: true - optional: true - tools: - type: string - optional: true - description: 'The name of the tools for dbcopilot. Supported tools: "tsql", "python". Format: ["tsql", "python"]' - knowledge_pieces: - type: string - optional: true - description: "The list of knowledge pieces to be used for grounding." - include_views: - type: boolean - optional: true - description: "Whether to turn on views." - instruct_template: - type: string - optional: true - description: "The instruct template for the LLM." - managed_identity_enabled: - type: boolean - default: false - optional: true - description: "Whether to connect using managed identity." -outputs: - grounding_index: - type: uri_folder - db_context: - type: uri_folder -jobs: - db_meta_loading_generator: - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - asset_uri: - path: ${{parent.inputs.db_datastore}} - max_tables: - path: ${{parent.inputs.max_tables}} - max_columns: - path: ${{parent.inputs.max_columns}} - max_rows: - path: ${{parent.inputs.max_rows}} - max_sampling_rows: - path: ${{parent.inputs.max_sampling_rows}} - max_text_length: - path: ${{parent.inputs.max_text_length}} - max_knowledge_pieces: - path: ${{parent.inputs.max_knowledge_pieces}} - selected_tables: - path: ${{parent.inputs.selected_tables}} - column_settings: - path: ${{parent.inputs.column_settings}} - include_views: - path :${{parent.inputs.include_views}} - outputs: - output_chunk_file: - type: uri_folder - output_grounding_context_file: ${{parent.outputs.db_context}} - environment_variables: - MANAGED_IDENTITY_ENABLED: ${{parent.inputs.managed_identity_enabled}} - component: "azureml:llm_dbcopilot_grounding:0.0.70" - type: command - generate_meta_embeddings: - type: command - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - component: "azureml:llm_rag_generate_embeddings:0.0.66" - inputs: - chunks_source: - type: uri_folder - path: ${{parent.jobs.db_meta_loading_generator.outputs.output_chunk_file}} - embeddings_model: ${{parent.inputs.embeddings_model}} - outputs: - embeddings: - mode: upload - type: uri_folder - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI: ${{parent.inputs.embedding_connection}} - # generate_meta_embeddings: - # resources: - # instance_count: ${{parent.inputs.serverless_instance_count}} - # instance_type: ${{parent.inputs.serverless_instance_type}} - # properties: - # compute_specification: - # automatic: true - # retry_settings: - # timeout: 3600 - # max_retries: 3 - # environment_variables: - # AZUREML_WORKSPACE_CONNECTION_ID_AOAI: ${{parent.inputs.embedding_connection}} - # inputs: - # chunks_source: - # path: ${{parent.jobs.db_meta_loading_generator.outputs.output_chunk_file}} - # embeddings_model: - # path: ${{parent.inputs.embeddings_model}} - # outputs: - # embeddings: - # mode: upload - # type: uri_folder - # component: "azureml:llm_rag_generate_embeddings_parallel:0.0.9" - # type: parallel - create_meta_acs_index_job: - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI: ${{parent.inputs.embedding_connection}} - AZUREML_WORKSPACE_CONNECTION_ID_ACS: ${{parent.inputs.acs_connection}} - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - embeddings: - path: ${{parent.jobs.generate_meta_embeddings.outputs.embeddings}} - acs_config: - path: ${{parent.inputs.acs_config}} - outputs: - index: ${{parent.outputs.grounding_index}} - component: "azureml:llm_rag_update_acs_index:0.0.70" - type: command - ######################################### - db_sample_loading_generator: - type: command - component: "azureml:llm_dbcopilot_grounding_ground_samples:0.0.45" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - sample_folder: - type: uri_folder - path: ${{parent.inputs.sample_data}} - include_builtin: ${{parent.inputs.include_builtin_examples}} - tools: ${{parent.inputs.tools}} - grounding_context: ${{parent.jobs.db_meta_loading_generator.outputs.output_grounding_context_file}} - outputs: - output_chunk_file: - type: uri_folder - ######################################### - generate_sample_embeddings: - type: command - component: "azureml:llm_rag_generate_embeddings:0.0.66" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - chunks_source: - type: uri_folder - path: ${{parent.jobs.db_sample_loading_generator.outputs.output_chunk_file}} - embeddings_model: ${{parent.inputs.embeddings_model}} - outputs: - embeddings: - type: uri_folder - mode: upload - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI: ${{parent.inputs.embedding_connection}} - ######################################### - create_sample_acs_index_job: - type: command - component: "azureml:llm_rag_update_acs_index:0.0.70" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - embeddings: - type: uri_folder - path: ${{parent.jobs.generate_sample_embeddings.outputs.embeddings}} - acs_config: ${{parent.inputs.sample_acs_config}} - outputs: - index: - type: uri_folder - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI: ${{parent.inputs.embedding_connection}} - AZUREML_WORKSPACE_CONNECTION_ID_ACS: ${{parent.inputs.acs_connection}} - ######################################### - register_mlindex_asset_job: - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - storage_uri: - path: ${{parent.jobs.create_meta_acs_index_job.outputs.index}} - asset_name: - path: ${{parent.inputs.embeddings_dataset_name}} - outputs: - asset_id: - type: uri_file - component: "azureml:llm_rag_register_mlindex_asset:0.0.70" - type: command - create_prompt_flow: - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI_EMBEDDING: ${{parent.inputs.embedding_connection}} - AZUREML_WORKSPACE_CONNECTION_ID_AOAI_CHAT: ${{parent.inputs.llm_connection}} - MANAGED_IDENTITY_ENABLED: ${{parent.inputs.managed_identity_enabled}} - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - identity: - type: user_identity - inputs: - index_name: - path: ${{parent.inputs.embeddings_dataset_name}} - grounding_embedding_uri: - path: ${{parent.jobs.create_meta_acs_index_job.outputs.index}} - example_embedding_uri: - path: ${{parent.jobs.create_sample_acs_index_job.outputs.index}} - db_context_uri: - path: ${{parent.jobs.db_meta_loading_generator.outputs.output_grounding_context_file}} - asset_uri: - path: ${{parent.inputs.db_datastore}} - embedding_aoai_deployment_name: - path: ${{parent.inputs.embedding_aoai_deployment_name}} - chat_aoai_deployment_name: - path: ${{parent.inputs.chat_aoai_deployment_name}} - llm_config: - path: ${{parent.inputs.llm_config}} - runtime: - path: ${{parent.inputs.runtime}} - knowledge_pieces: - path: ${{parent.inputs.knowledge_pieces}} - include_views: - path: ${{parent.inputs.include_views}} - instruct_template: - path: ${{parent.inputs.instruct_template}} - component: "azureml:llm_dbcopilot_create_promptflow:0.0.70" - type: command diff --git a/assets/large_language_models/components_pipelines/data_ingestion_db_to_faiss/asset.yaml b/assets/large_language_models/components_pipelines/data_ingestion_db_to_faiss/asset.yaml deleted file mode 100644 index dbebe8dc08..0000000000 --- a/assets/large_language_models/components_pipelines/data_ingestion_db_to_faiss/asset.yaml +++ /dev/null @@ -1,4 +0,0 @@ -spec: spec.yaml -type: component -categories: -- Retrieval Augmented Generation \ No newline at end of file diff --git a/assets/large_language_models/components_pipelines/data_ingestion_db_to_faiss/spec.yaml b/assets/large_language_models/components_pipelines/data_ingestion_db_to_faiss/spec.yaml deleted file mode 100644 index eb3c723bf3..0000000000 --- a/assets/large_language_models/components_pipelines/data_ingestion_db_to_faiss/spec.yaml +++ /dev/null @@ -1,324 +0,0 @@ -$schema: https://azuremlschemas.azureedge.net/latest/pipelineComponent.schema.json -type: pipeline -tags: - Preview: "" -name: llm_ingest_db_to_faiss -display_name: LLM - SQL Datastore to FAISS Pipeline -version: 0.0.97 -description: Single job pipeline to chunk data from AzureML sql data store, and create FAISS embeddings index -settings: - default_compute: serverless -inputs: - db_datastore: - type: string - description: database datastore uri in the format of 'azureml://datastores/{datastore_name}' - embeddings_model: - type: string - description: The model used to generate embeddings. 'azure_open_ai://endpoint/{endpoint_name}/deployment/{deployment_name}/model/{model_name}' - chat_aoai_deployment_name: - type: string - optional: true - description: The name of the chat AOAI deployment - embedding_aoai_deployment_name: - type: string - description: The name of the embedding AOAI deployment - embeddings_dataset_name: - type: string - description: The name of the faiss index - max_tables: - type: integer - optional: true - max_columns: - type: integer - optional: true - max_rows: - type: integer - optional: true - max_sampling_rows: - type: integer - optional: true - max_text_length: - type: integer - optional: true - max_knowledge_pieces: - type: integer - optional: true - selected_tables: - type: string - optional: true - column_settings: - type: string - optional: true - llm_config: - type: string - optional: true - description: The name of the llm config - serverless_instance_count: - type: integer - optional: true - default: "1" - serverless_instance_type: - type: string - optional: true - default: Standard_DS3_v2 - embedding_connection: - type: string - optional: true - description: Azure OpenAI workspace connection ARM ID for embeddings - llm_connection: - type: string - optional: true - description: Azure OpenAI workspace connection ARM ID for LLM - runtime: - type: string - optional: false - description: The name of the runtime - sample_data: - type: uri_folder - description: "Sample data to be used for data ingestion. format: 'azureml:samples-test:1'" - optional: true - # path: "azureml:samples-test:1" - # data ingest setting - include_builtin_examples: - type: boolean - default: true - optional: true - tools: - type: string - optional: true - description: 'The name of the tools for dbcopilot. Supported tools: "tsql", "python". Format: ["tsql", "python"]' - knowledge_pieces: - type: string - optional: true - description: "The list of knowledge pieces to be used for grounding." - include_views: - type: boolean - optional: true - description: "Whether to turn on views." - instruct_template: - type: string - optional: true - description: "The instruct template for the LLM." - managed_identity_enabled: - type: boolean - default: false - optional: true - description: "Whether to connect using managed identity." -outputs: - grounding_index: - type: uri_folder - db_context: - type: uri_folder -jobs: - db_meta_loading_generator: - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - asset_uri: - path: ${{parent.inputs.db_datastore}} - max_tables: - path: ${{parent.inputs.max_tables}} - max_columns: - path: ${{parent.inputs.max_columns}} - max_rows: - path: ${{parent.inputs.max_rows}} - max_sampling_rows: - path: ${{parent.inputs.max_sampling_rows}} - max_text_length: - path: ${{parent.inputs.max_text_length}} - max_knowledge_pieces: - path: ${{parent.inputs.max_knowledge_pieces}} - selected_tables: - path: ${{parent.inputs.selected_tables}} - column_settings: - path: ${{parent.inputs.column_settings}} - include_views: - path :${{parent.inputs.include_views}} - outputs: - output_chunk_file: - type: uri_folder - output_grounding_context_file: ${{parent.outputs.db_context}} - environment_variables: - MANAGED_IDENTITY_ENABLED: ${{parent.inputs.managed_identity_enabled}} - component: "azureml:llm_dbcopilot_grounding:0.0.70" - type: command - generate_meta_embeddings: - type: command - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - component: "azureml:llm_rag_generate_embeddings:0.0.66" - inputs: - chunks_source: - type: uri_folder - path: ${{parent.jobs.db_meta_loading_generator.outputs.output_chunk_file}} - embeddings_model: ${{parent.inputs.embeddings_model}} - outputs: - embeddings: - mode: upload - type: uri_folder - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI: ${{parent.inputs.embedding_connection}} - # generate_meta_embeddings: - # resources: - # instance_count: ${{parent.inputs.serverless_instance_count}} - # instance_type: ${{parent.inputs.serverless_instance_type}} - # properties: - # compute_specification: - # automatic: true - # retry_settings: - # timeout: 3600 - # max_retries: 3 - # environment_variables: - # AZUREML_WORKSPACE_CONNECTION_ID_AOAI: ${{parent.inputs.embedding_connection}} - # inputs: - # chunks_source: - # path: ${{parent.jobs.db_meta_loading_generator.outputs.output_chunk_file}} - # embeddings_model: - # path: ${{parent.inputs.embeddings_model}} - # outputs: - # embeddings: - # mode: upload - # type: uri_folder - # component: "azureml:llm_rag_generate_embeddings_parallel:0.0.9" - # type: parallel - create_meta_faiss_index_job: - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI: ${{parent.inputs.embedding_connection}} - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - embeddings: - path: ${{parent.jobs.generate_meta_embeddings.outputs.embeddings}} - outputs: - index: ${{parent.outputs.grounding_index}} - component: "azureml:llm_rag_create_faiss_index:0.0.71" - type: command - - ######################################### - db_sample_loading_generator: - type: command - component: "azureml:llm_dbcopilot_grounding_ground_samples:0.0.45" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - sample_folder: - type: uri_folder - path: ${{parent.inputs.sample_data}} - include_builtin: ${{parent.inputs.include_builtin_examples}} - tools: ${{parent.inputs.tools}} - grounding_context: ${{parent.jobs.db_meta_loading_generator.outputs.output_grounding_context_file}} - outputs: - output_chunk_file: - type: uri_folder - ######################################### - generate_sample_embeddings: - type: command - component: "azureml:llm_rag_generate_embeddings:0.0.66" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - chunks_source: - type: uri_file - path: ${{parent.jobs.db_sample_loading_generator.outputs.output_chunk_file}} - embeddings_model: ${{parent.inputs.embeddings_model}} - outputs: - embeddings: - type: uri_folder - mode: upload - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI: ${{parent.inputs.embedding_connection}} - ######################################### - create_sample_faiss_index_job: - type: command - component: "azureml:llm_rag_create_faiss_index:0.0.71" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - embeddings: - type: uri_folder - path: ${{parent.jobs.generate_sample_embeddings.outputs.embeddings}} - outputs: - index: - type: uri_folder - ######################################### - register_mlindex_asset_job: - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - storage_uri: - path: ${{parent.jobs.create_meta_faiss_index_job.outputs.index}} - asset_name: - path: ${{parent.inputs.embeddings_dataset_name}} - outputs: - asset_id: - type: uri_file - component: "azureml:llm_rag_register_mlindex_asset:0.0.70" - type: command - create_prompt_flow: - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI_EMBEDDING: ${{parent.inputs.embedding_connection}} - AZUREML_WORKSPACE_CONNECTION_ID_AOAI_CHAT: ${{parent.inputs.llm_connection}} - MANAGED_IDENTITY_ENABLED: ${{parent.inputs.managed_identity_enabled}} - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - identity: - type: user_identity - inputs: - index_name: - path: ${{parent.inputs.embeddings_dataset_name}} - grounding_embedding_uri: - path: ${{parent.jobs.create_meta_faiss_index_job.outputs.index}} - example_embedding_uri: - path: ${{parent.jobs.create_sample_faiss_index_job.outputs.index}} - db_context_uri: - path: ${{parent.jobs.db_meta_loading_generator.outputs.output_grounding_context_file}} - asset_uri: - path: ${{parent.inputs.db_datastore}} - embedding_aoai_deployment_name: - path: ${{parent.inputs.embedding_aoai_deployment_name}} - chat_aoai_deployment_name: - path: ${{parent.inputs.chat_aoai_deployment_name}} - llm_config: - path: ${{parent.inputs.llm_config}} - runtime: - path: ${{parent.inputs.runtime}} - knowledge_pieces: - path: ${{parent.inputs.knowledge_pieces}} - include_views: - path: ${{parent.inputs.include_views}} - instruct_template: - path: ${{parent.inputs.instruct_template}} - component: "azureml:llm_dbcopilot_create_promptflow:0.0.70" - type: command diff --git a/assets/large_language_models/components_pipelines/data_ingestion_dbcopilot_acs_e2e/asset.yaml b/assets/large_language_models/components_pipelines/data_ingestion_dbcopilot_acs_e2e/asset.yaml deleted file mode 100644 index dbebe8dc08..0000000000 --- a/assets/large_language_models/components_pipelines/data_ingestion_dbcopilot_acs_e2e/asset.yaml +++ /dev/null @@ -1,4 +0,0 @@ -spec: spec.yaml -type: component -categories: -- Retrieval Augmented Generation \ No newline at end of file diff --git a/assets/large_language_models/components_pipelines/data_ingestion_dbcopilot_acs_e2e/spec.yaml b/assets/large_language_models/components_pipelines/data_ingestion_dbcopilot_acs_e2e/spec.yaml deleted file mode 100644 index 16bea458ab..0000000000 --- a/assets/large_language_models/components_pipelines/data_ingestion_dbcopilot_acs_e2e/spec.yaml +++ /dev/null @@ -1,319 +0,0 @@ -$schema: https://azuremlschemas.azureedge.net/latest/pipelineComponent.schema.json -type: pipeline - -name: llm_ingest_dbcopilot_acs_e2e -version: 0.0.66 -display_name: Data Ingestion for DB Data Output to ACS E2E Deployment -description: Single job pipeline to chunk data from AzureML DB Datastore and create acs embeddings index - -settings: - default_compute: serverless - -inputs: - db_datastore: - type: string - description: "database datastore uri in the format of 'azureml://datastores/{datastore_name}'" - sample_data: - type: uri_folder - description: "Sample data to be used for data ingestion. format: 'azureml:samples-test:1'" - optional: true - # path: "azureml:samples-test:1" - # data ingest setting - embeddings_model: - type: string - description: "The model used to generate embeddings. 'azure_open_ai://endpoint/{endpoint_name}/deployment/{deployment_name}/model/{model_name}'" - chat_aoai_deployment_name: - type: string - description: "The name of the chat AOAI deployment" - optional: true - embedding_aoai_deployment_name: - type: string - description: "The name of the embedding AOAI deployment" - # grounding settings - max_tables: - type: integer - optional: true - max_columns: - type: integer - optional: true - max_rows: - type: integer - optional: true - max_sampling_rows: - type: integer - optional: true - max_text_length: - type: integer - optional: true - max_knowledge_pieces: - type: integer - optional: true - selected_tables: - type: string - optional: true - description: 'The list of tables to be ingested. If not specified, all tables will be ingested. Format: ["table1","table2","table3"]' - column_settings: - type: string - optional: true - # copilot settings - tools: - type: string - optional: true - description: 'The name of the tools for dbcopilot. Supported tools: "tsql", "python". Format: ["tsql", "python"]' - # deploy settings - endpoint_name: - type: string - description: "The name of the endpoint" - deployment_name: - type: string - description: "The name of the deployment" - default: "blue" - mir_environment: - type: string - description: "The name of the mir environment. Format: azureml://registries/{registry_name}/environments/llm-dbcopilot-mir" - # compute settings - serverless_instance_count: - type: integer - default: 1 - optional: true - serverless_instance_type: - type: string - default: "Standard_DS3_v2" - optional: true - embedding_connection: - type: string - optional: true - description: "Azure OpenAI workspace connection ARM ID for embeddings" - llm_connection: - type: string - optional: true - description: "Azure OpenAI workspace connection ARM ID for llm" - acs_connection: - type: string - optional: true - description: "Azure Cognitive Search workspace connection ARM ID" - acs_config_meta: - type: string - description: "JSON describing the acs index to create or update for embeddings" - sample_acs_config: - type: string - description: "JSON describing the acs index to create or update for samples" - temperature: - type: number - default: 0.0 - optional: true - top_p: - type: number - default: 0.0 - optional: true - include_builtin_examples: - type: boolean - default: true - optional: true - knowledge_pieces: - type: string - optional: true - description: "The list of knowledge pieces to be used for grounding." - include_views: - type: boolean - optional: true - description: "Whether to turn on views." - instruct_template: - type: string - optional: true - description: "The instruct template for the LLM." - managed_identity_enabled: - type: boolean - default: false - optional: true - description: "Whether to connect using managed identity." - egress_public_network_access: - type: string - optional: true - default: "enabled" - description: "This option allows the resource to send outbound traffic to the public Internet or not, there are two choices disabled and enabled, the default is enabled" -outputs: - grounding_index: - type: uri_folder - db_context: - type: uri_folder -jobs: - ######################################### - db_meta_loading_generator: - type: command - component: "azureml:llm_dbcopilot_grounding:0.0.70" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - asset_uri: ${{parent.inputs.db_datastore}} - max_tables: ${{parent.inputs.max_tables}} - max_columns: ${{parent.inputs.max_columns}} - max_rows: ${{parent.inputs.max_rows}} - max_sampling_rows: ${{parent.inputs.max_sampling_rows}} - max_text_length: ${{parent.inputs.max_text_length}} - max_knowledge_pieces : ${{parent.inputs.max_knowledge_pieces}} - selected_tables: ${{parent.inputs.selected_tables}} - column_settings: ${{parent.inputs.column_settings}} - include_views: ${{parent.inputs.include_views}} - outputs: - output_chunk_file: - type: uri_folder - output_grounding_context_file: - type: uri_folder - path: ${{parent.outputs.db_context}} - environment_variables: - MANAGED_IDENTITY_ENABLED: ${{parent.inputs.managed_identity_enabled}} - ######################################### - generate_meta_embeddings: - type: command - component: "azureml:llm_rag_generate_embeddings:0.0.66" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - chunks_source: - type: uri_folder - path: ${{parent.jobs.db_meta_loading_generator.outputs.output_chunk_file}} - embeddings_model: ${{parent.inputs.embeddings_model}} - outputs: - embeddings: - type: uri_folder - mode: upload - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI: ${{parent.inputs.embedding_connection}} - ######################################### - create_meta_acs_index_job: - type: command - component: "azureml:llm_rag_update_acs_index:0.0.70" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - embeddings: - type: uri_folder - path: ${{parent.jobs.generate_meta_embeddings.outputs.embeddings}} - acs_config: ${{parent.inputs.acs_config_meta}} - outputs: - index: - type: uri_folder - path: ${{parent.outputs.grounding_index}} - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI: ${{parent.inputs.embedding_connection}} - AZUREML_WORKSPACE_CONNECTION_ID_ACS: ${{parent.inputs.acs_connection}} - ######################################### - db_sample_loading_generator: - type: command - component: "azureml:llm_dbcopilot_grounding_ground_samples:0.0.45" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - sample_folder: - type: uri_folder - path: ${{parent.inputs.sample_data}} - include_builtin: ${{parent.inputs.include_builtin_examples}} - tools: ${{parent.inputs.tools}} - grounding_context: ${{parent.jobs.db_meta_loading_generator.outputs.output_grounding_context_file}} - outputs: - output_chunk_file: - type: uri_folder - ######################################### - generate_sample_embeddings: - type: command - component: "azureml:llm_rag_generate_embeddings:0.0.66" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - chunks_source: - type: uri_folder - path: ${{parent.jobs.db_sample_loading_generator.outputs.output_chunk_file}} - embeddings_model: ${{parent.inputs.embeddings_model}} - outputs: - embeddings: - type: uri_folder - mode: upload - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI: ${{parent.inputs.embedding_connection}} - ######################################### - create_sample_acs_index_job: - type: command - component: "azureml:llm_rag_update_acs_index:0.0.70" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - embeddings: - type: uri_folder - path: ${{parent.jobs.generate_sample_embeddings.outputs.embeddings}} - acs_config: ${{parent.inputs.sample_acs_config}} - outputs: - index: - type: uri_folder - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI: ${{parent.inputs.embedding_connection}} - AZUREML_WORKSPACE_CONNECTION_ID_ACS: ${{parent.inputs.acs_connection}} - ######################################### - endpoint_deployment_job: - type: command - component: "azureml:llm_dbcopilot_deploy_endpoint:0.0.46" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - identity: - type: user_identity - inputs: - grounding_embedding_uri: - type: uri_folder - path: ${{parent.jobs.create_meta_acs_index_job.outputs.index}} - example_embedding_uri: - type: uri_folder - path: ${{parent.jobs.create_sample_acs_index_job.outputs.index}} - db_context_uri: - type: uri_file - path: ${{parent.jobs.db_meta_loading_generator.outputs.output_grounding_context_file}} - endpoint_name: ${{parent.inputs.endpoint_name}} - deployment_name: ${{parent.inputs.deployment_name}} - asset_uri: ${{parent.inputs.db_datastore}} - embedding_aoai_deployment_name: ${{parent.inputs.embedding_aoai_deployment_name}} - chat_aoai_deployment_name: ${{parent.inputs.chat_aoai_deployment_name}} - mir_environment: ${{parent.inputs.mir_environment}} - selected_tables: ${{parent.inputs.selected_tables}} - max_tables: ${{parent.inputs.max_tables}} - max_rows: ${{parent.inputs.max_rows}} - max_columns: ${{parent.inputs.max_columns}} - max_text_length: ${{parent.inputs.max_text_length}} - max_knowledge_pieces: ${{parent.inputs.max_knowledge_pieces}} - temperature: ${{parent.inputs.temperature}} - top_p: ${{parent.inputs.top_p}} - tools: ${{parent.inputs.tools}} - knowledge_pieces: ${{parent.inputs.knowledge_pieces}} - include_views: ${{parent.inputs.include_views}} - instruct_template: ${{parent.inputs.instruct_template}} - egress_public_network_access: ${{parent.inputs.egress_public_network_access}} - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI_EMBEDDING: ${{parent.inputs.embedding_connection}} - AZUREML_WORKSPACE_CONNECTION_ID_AOAI_CHAT: ${{parent.inputs.llm_connection}} - MANAGED_IDENTITY_ENABLED: ${{parent.inputs.managed_identity_enabled}} diff --git a/assets/large_language_models/components_pipelines/data_ingestion_dbcopilot_faiss_e2e/asset.yaml b/assets/large_language_models/components_pipelines/data_ingestion_dbcopilot_faiss_e2e/asset.yaml deleted file mode 100644 index dbebe8dc08..0000000000 --- a/assets/large_language_models/components_pipelines/data_ingestion_dbcopilot_faiss_e2e/asset.yaml +++ /dev/null @@ -1,4 +0,0 @@ -spec: spec.yaml -type: component -categories: -- Retrieval Augmented Generation \ No newline at end of file diff --git a/assets/large_language_models/components_pipelines/data_ingestion_dbcopilot_faiss_e2e/spec.yaml b/assets/large_language_models/components_pipelines/data_ingestion_dbcopilot_faiss_e2e/spec.yaml deleted file mode 100644 index b68803265d..0000000000 --- a/assets/large_language_models/components_pipelines/data_ingestion_dbcopilot_faiss_e2e/spec.yaml +++ /dev/null @@ -1,303 +0,0 @@ -$schema: https://azuremlschemas.azureedge.net/latest/pipelineComponent.schema.json -type: pipeline - -name: llm_ingest_dbcopilot_faiss_e2e -version: 0.0.66 -display_name: Data Ingestion for DB Data Output to FAISS E2E Deployment -description: Single job pipeline to chunk data from AzureML DB Datastore and create faiss embeddings index - -settings: - default_compute: serverless - -inputs: - db_datastore: - type: string - description: "database datastore uri in the format of 'azureml://datastores/{datastore_name}'" - sample_data: - type: uri_folder - description: "Sample data to be used for data ingestion. format: 'azureml:samples-test:1'" - optional: true - # path: "azureml:samples-test:1" - # data ingest setting - embeddings_model: - type: string - description: "The model used to generate embeddings. 'azure_open_ai://endpoint/{endpoint_name}/deployment/{deployment_name}/model/{model_name}'" - chat_aoai_deployment_name: - type: string - description: "The name of the chat AOAI deployment" - optional: true - embedding_aoai_deployment_name: - type: string - description: "The name of the embedding AOAI deployment" - # grounding settings - max_tables: - type: integer - optional: true - max_columns: - type: integer - optional: true - max_rows: - type: integer - optional: true - max_sampling_rows: - type: integer - optional: true - max_text_length: - type: integer - optional: true - max_knowledge_pieces: - type: integer - optional: true - selected_tables: - type: string - optional: true - description: 'The list of tables to be ingested. If not specified, all tables will be ingested. Format: ["table1","table2","table3"]' - column_settings: - type: string - optional: true - # copilot settings - tools: - type: string - optional: true - description: 'The name of the tools for dbcopilot. Supported tools: "tsql", "python". Format: ["tsql", "python"]' - # deploy settings - endpoint_name: - type: string - description: "The name of the endpoint" - deployment_name: - type: string - description: "The name of the deployment" - default: "blue" - mir_environment: - type: string - description: "The name of the mir environment. Format: azureml://registries/{registry_name}/environments/llm-dbcopilot-mir" - # compute settings - serverless_instance_count: - type: integer - default: 1 - optional: true - serverless_instance_type: - type: string - default: "Standard_DS3_v2" - optional: true - embedding_connection: - type: string - optional: true - description: "Azure OpenAI workspace connection ARM ID for embeddings" - llm_connection: - type: string - optional: true - description: "Azure OpenAI workspace connection ARM ID for llm" - temperature: - type: number - default: 0.0 - optional: true - top_p: - type: number - default: 0.0 - optional: true - include_builtin_examples: - type: boolean - default: true - optional: true - knowledge_pieces: - type: string - optional: true - description: "The list of knowledge pieces to be used for grounding." - include_views: - type: boolean - optional: true - description: "Whether to turn on views." - instruct_template: - type: string - optional: true - description: "The instruct template for the LLM." - managed_identity_enabled: - type: boolean - default: false - optional: true - description: "Whether to connect using managed identity." - egress_public_network_access: - type: string - optional: true - default: "enabled" - description: "This option allows the resource to send outbound traffic to the public Internet or not, there are two choices disabled and enabled, the default is enabled" -outputs: - grounding_index: - type: uri_folder - db_context: - type: uri_folder -jobs: - ######################################### - db_meta_loading_generator: - type: command - component: "azureml:llm_dbcopilot_grounding:0.0.70" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - asset_uri: ${{parent.inputs.db_datastore}} - max_tables: ${{parent.inputs.max_tables}} - max_columns: ${{parent.inputs.max_columns}} - max_rows: ${{parent.inputs.max_rows}} - max_sampling_rows: ${{parent.inputs.max_sampling_rows}} - max_text_length: ${{parent.inputs.max_text_length}} - max_knowledge_pieces: ${{parent.inputs.max_knowledge_pieces}} - selected_tables: ${{parent.inputs.selected_tables}} - column_settings: ${{parent.inputs.column_settings}} - include_views: ${{parent.inputs.include_views}} - outputs: - output_chunk_file: - type: uri_folder - output_grounding_context_file: - type: uri_folder - path: ${{parent.outputs.db_context}} - environment_variables: - MANAGED_IDENTITY_ENABLED: ${{parent.inputs.managed_identity_enabled}} - ######################################### - generate_meta_embeddings: - type: command - component: "azureml:llm_rag_generate_embeddings:0.0.66" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - chunks_source: - type: uri_folder - path: ${{parent.jobs.db_meta_loading_generator.outputs.output_chunk_file}} - embeddings_model: ${{parent.inputs.embeddings_model}} - outputs: - embeddings: - type: uri_folder - mode: upload - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI: ${{parent.inputs.embedding_connection}} - ######################################### - create_meta_faiss_index_job: - type: command - component: "azureml:llm_rag_create_faiss_index:0.0.71" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - embeddings: - type: uri_folder - path: ${{parent.jobs.generate_meta_embeddings.outputs.embeddings}} - outputs: - index: - type: uri_folder - path: ${{parent.outputs.grounding_index}} - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI: ${{parent.inputs.embedding_connection}} - ######################################### - db_sample_loading_generator: - type: command - component: "azureml:llm_dbcopilot_grounding_ground_samples:0.0.45" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - sample_folder: - type: uri_folder - path: ${{parent.inputs.sample_data}} - include_builtin: ${{parent.inputs.include_builtin_examples}} - tools: ${{parent.inputs.tools}} - grounding_context: ${{parent.jobs.db_meta_loading_generator.outputs.output_grounding_context_file}} - outputs: - output_chunk_file: - type: uri_folder - ######################################### - generate_sample_embeddings: - type: command - component: "azureml:llm_rag_generate_embeddings:0.0.66" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - chunks_source: - type: uri_file - path: ${{parent.jobs.db_sample_loading_generator.outputs.output_chunk_file}} - embeddings_model: ${{parent.inputs.embeddings_model}} - outputs: - embeddings: - type: uri_folder - mode: upload - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI: ${{parent.inputs.embedding_connection}} - ######################################### - create_sample_faiss_index_job: - type: command - component: "azureml:llm_rag_create_faiss_index:0.0.71" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - inputs: - embeddings: - type: uri_folder - path: ${{parent.jobs.generate_sample_embeddings.outputs.embeddings}} - outputs: - index: - type: uri_folder - ######################################### - endpoint_deployment_job: - type: command - component: "azureml:llm_dbcopilot_deploy_endpoint:0.0.46" - resources: - instance_count: ${{parent.inputs.serverless_instance_count}} - instance_type: ${{parent.inputs.serverless_instance_type}} - properties: - compute_specification: - automatic: true - identity: - type: user_identity - inputs: - grounding_embedding_uri: - type: uri_folder - path: ${{parent.jobs.create_meta_faiss_index_job.outputs.index}} - example_embedding_uri: - type: uri_folder - path: ${{parent.jobs.create_sample_faiss_index_job.outputs.index}} - db_context_uri: - type: uri_file - path: ${{parent.jobs.db_meta_loading_generator.outputs.output_grounding_context_file}} - endpoint_name: ${{parent.inputs.endpoint_name}} - deployment_name: ${{parent.inputs.deployment_name}} - asset_uri: ${{parent.inputs.db_datastore}} - embedding_aoai_deployment_name: ${{parent.inputs.embedding_aoai_deployment_name}} - chat_aoai_deployment_name: ${{parent.inputs.chat_aoai_deployment_name}} - mir_environment: ${{parent.inputs.mir_environment}} - selected_tables: ${{parent.inputs.selected_tables}} - max_tables: ${{parent.inputs.max_tables}} - max_rows: ${{parent.inputs.max_rows}} - max_columns: ${{parent.inputs.max_columns}} - max_text_length: ${{parent.inputs.max_text_length}} - max_knowledge_pieces: ${{parent.inputs.max_knowledge_pieces}} - tools: ${{parent.inputs.tools}} - temperature: ${{parent.inputs.temperature}} - top_p: ${{parent.inputs.top_p}} - knowledge_pieces: ${{parent.inputs.knowledge_pieces}} - include_views: ${{parent.inputs.include_views}} - instruct_template: ${{parent.inputs.instruct_template}} - egress_public_network_access: ${{parent.inputs.egress_public_network_access}} - environment_variables: - AZUREML_WORKSPACE_CONNECTION_ID_AOAI_EMBEDDING: ${{parent.inputs.embedding_connection}} - AZUREML_WORKSPACE_CONNECTION_ID_AOAI_CHAT: ${{parent.inputs.llm_connection}} - MANAGED_IDENTITY_ENABLED: ${{parent.inputs.managed_identity_enabled}} diff --git a/assets/large_language_models/dbcopilot/components/llm_dbcopilot_create_promptflow/asset.yaml b/assets/large_language_models/dbcopilot/components/llm_dbcopilot_create_promptflow/asset.yaml deleted file mode 100644 index dbebe8dc08..0000000000 --- a/assets/large_language_models/dbcopilot/components/llm_dbcopilot_create_promptflow/asset.yaml +++ /dev/null @@ -1,4 +0,0 @@ -spec: spec.yaml -type: component -categories: -- Retrieval Augmented Generation \ No newline at end of file diff --git a/assets/large_language_models/dbcopilot/components/llm_dbcopilot_create_promptflow/spec.yaml b/assets/large_language_models/dbcopilot/components/llm_dbcopilot_create_promptflow/spec.yaml deleted file mode 100644 index 431430302b..0000000000 --- a/assets/large_language_models/dbcopilot/components/llm_dbcopilot_create_promptflow/spec.yaml +++ /dev/null @@ -1,51 +0,0 @@ -$schema: https://azuremlschemas.azureedge.net/latest/commandComponent.schema.json -type: command -tags: - Preview: "" -name: llm_dbcopilot_create_promptflow -display_name: LLM - Create DBCopilot Prompt Flow -version: 0.0.70 -inputs: - index_name: - type: string - optional: false - grounding_embedding_uri: - type: uri_folder - optional: false - mode: direct - embedding_aoai_deployment_name: - type: string - optional: false - db_context_uri: - type: uri_folder - optional: false - mode: direct - asset_uri: - type: string - optional: false - chat_aoai_deployment_name: - type: string - optional: true - example_embedding_uri: - type: uri_folder - optional: true - mode: direct - llm_config: - type: string - optional: true - runtime: - type: string - optional: false - knowledge_pieces: - type: string - optional: true - include_views: - type: boolean - optional: true - instruct_template: - type: string - optional: true -outputs: {} -code: ../src -environment: azureml:llm-dbcopilot-embeddings@latest -command: python prompt_flow_creation.py --index_name '${{inputs.index_name}}' --grounding_embedding_uri '${{inputs.grounding_embedding_uri}}' --embedding_aoai_deployment_name '${{inputs.embedding_aoai_deployment_name}}' --db_context_uri '${{inputs.db_context_uri}}' --asset_uri '${{inputs.asset_uri}}' $[[--chat_aoai_deployment_name '${{inputs.chat_aoai_deployment_name}}']] $[[--example_embedding_uri '${{inputs.example_embedding_uri}}']] $[[--llm_config '${{inputs.llm_config}}']] --runtime '${{inputs.runtime}}' $[[--knowledge_pieces '${{inputs.knowledge_pieces}}']] $[[--include_views '${{inputs.include_views}}']] $[[--instruct_template '${{inputs.instruct_template}}']] diff --git a/assets/large_language_models/dbcopilot/components/llm_dbcopilot_deploy_endpoint/asset.yaml b/assets/large_language_models/dbcopilot/components/llm_dbcopilot_deploy_endpoint/asset.yaml deleted file mode 100644 index dbebe8dc08..0000000000 --- a/assets/large_language_models/dbcopilot/components/llm_dbcopilot_deploy_endpoint/asset.yaml +++ /dev/null @@ -1,4 +0,0 @@ -spec: spec.yaml -type: component -categories: -- Retrieval Augmented Generation \ No newline at end of file diff --git a/assets/large_language_models/dbcopilot/components/llm_dbcopilot_deploy_endpoint/spec.yaml b/assets/large_language_models/dbcopilot/components/llm_dbcopilot_deploy_endpoint/spec.yaml deleted file mode 100644 index fe1e0fa4f1..0000000000 --- a/assets/large_language_models/dbcopilot/components/llm_dbcopilot_deploy_endpoint/spec.yaml +++ /dev/null @@ -1,84 +0,0 @@ -$schema: https://azuremlschemas.azureedge.net/latest/commandComponent.schema.json -type: command -tags: {} -name: llm_dbcopilot_deploy_endpoint -display_name: LLM - DBCopilot Deploy Endpoint Component -version: 0.0.46 -inputs: - deployment_name: - type: string - optional: false - endpoint_name: - type: string - optional: false - grounding_embedding_uri: - type: uri_folder - optional: false - mode: direct - embedding_aoai_deployment_name: - type: string - optional: false - chat_aoai_deployment_name: - type: string - optional: false - db_context_uri: - type: uri_folder - optional: false - mode: direct - asset_uri: - type: string - optional: false - mir_environment: - type: string - optional: false - example_embedding_uri: - type: uri_folder - optional: true - mode: direct - selected_tables: - type: string - optional: true - max_tables: - type: integer - optional: true - max_columns: - type: integer - optional: true - max_rows: - type: integer - optional: true - max_text_length: - type: integer - optional: true - max_knowledge_pieces: - type: integer - optional: true - tools: - type: string - optional: true - temperature: - type: number - optional: true - top_p: - type: number - optional: true - knowledge_pieces: - type: string - optional: true - sku: - type: string - optional: true - include_views: - type: boolean - optional: true - instruct_template: - type: string - optional: true - egress_public_network_access: - type: string - optional: true - default: "enabled" -outputs: {} -code: ../src -environment: azureml:llm-dbcopilot-embeddings@latest -command: python endpoint_deployment.py --deployment_name '${{inputs.deployment_name}}' --endpoint_name '${{inputs.endpoint_name}}' --grounding_embedding_uri '${{inputs.grounding_embedding_uri}}' --embedding_aoai_deployment_name '${{inputs.embedding_aoai_deployment_name}}' --chat_aoai_deployment_name '${{inputs.chat_aoai_deployment_name}}' --db_context_uri '${{inputs.db_context_uri}}' --asset_uri '${{inputs.asset_uri}}' --mir_environment '${{inputs.mir_environment}}' $[[--example_embedding_uri '${{inputs.example_embedding_uri}}']] $[[--selected_tables '${{inputs.selected_tables}}']] $[[--max_tables '${{inputs.max_tables}}']] $[[--max_columns '${{inputs.max_columns}}']] $[[--max_rows '${{inputs.max_rows}}']] $[[--max_text_length '${{inputs.max_text_length}}']] $[[--max_knowledge_pieces '${{inputs.max_knowledge_pieces}}']] $[[--tools '${{inputs.tools}}']] $[[--temperature '${{inputs.temperature}}']] $[[--top_p '${{inputs.top_p}}']] $[[--knowledge_pieces '${{inputs.knowledge_pieces}}']] $[[--sku '${{inputs.sku}}']] $[[--include_views '${{inputs.include_views}}']] $[[--instruct_template '${{inputs.instruct_template}}']] $[[--egress_public_network_access '${{inputs.egress_public_network_access}}']] diff --git a/assets/large_language_models/dbcopilot/components/llm_dbcopilot_grounding/asset.yaml b/assets/large_language_models/dbcopilot/components/llm_dbcopilot_grounding/asset.yaml deleted file mode 100644 index dbebe8dc08..0000000000 --- a/assets/large_language_models/dbcopilot/components/llm_dbcopilot_grounding/asset.yaml +++ /dev/null @@ -1,4 +0,0 @@ -spec: spec.yaml -type: component -categories: -- Retrieval Augmented Generation \ No newline at end of file diff --git a/assets/large_language_models/dbcopilot/components/llm_dbcopilot_grounding/spec.yaml b/assets/large_language_models/dbcopilot/components/llm_dbcopilot_grounding/spec.yaml deleted file mode 100644 index a55ad713a8..0000000000 --- a/assets/large_language_models/dbcopilot/components/llm_dbcopilot_grounding/spec.yaml +++ /dev/null @@ -1,45 +0,0 @@ -$schema: https://azuremlschemas.azureedge.net/latest/commandComponent.schema.json -type: command -tags: - Preview: "" -name: llm_dbcopilot_grounding -version: 0.0.70 -inputs: - asset_uri: - type: string - optional: true - max_tables: - type: integer - optional: true - max_columns: - type: integer - optional: true - max_rows: - type: integer - optional: true - max_sampling_rows: - type: integer - optional: true - max_text_length: - type: integer - optional: true - max_knowledge_pieces: - type: integer - optional: true - selected_tables: - type: string - optional: true - column_settings: - type: string - optional: true - include_views: - type: boolean - optional: true -outputs: - output_chunk_file: - type: uri_folder - output_grounding_context_file: - type: uri_folder -code: ../src -environment: azureml:llm-dbcopilot-embeddings@latest -command: python database_grounding.py --output_chunk_file '${{outputs.output_chunk_file}}' --output_grounding_context_file '${{outputs.output_grounding_context_file}}' $[[--asset_uri '${{inputs.asset_uri}}']] $[[--max_tables '${{inputs.max_tables}}']] $[[--max_columns '${{inputs.max_columns}}']] $[[--max_rows '${{inputs.max_rows}}']] $[[--max_sampling_rows '${{inputs.max_sampling_rows}}']] $[[--max_text_length '${{inputs.max_text_length}}']] $[[--max_knowledge_pieces '${{inputs.max_knowledge_pieces}}']] $[[--selected_tables '${{inputs.selected_tables}}']] $[[--column_settings '${{inputs.column_settings}}']] $[[--include_views '${{inputs.include_views}}']] diff --git a/assets/large_language_models/dbcopilot/components/llm_dbcopilot_grounding_ground_samples/asset.yaml b/assets/large_language_models/dbcopilot/components/llm_dbcopilot_grounding_ground_samples/asset.yaml deleted file mode 100644 index dbebe8dc08..0000000000 --- a/assets/large_language_models/dbcopilot/components/llm_dbcopilot_grounding_ground_samples/asset.yaml +++ /dev/null @@ -1,4 +0,0 @@ -spec: spec.yaml -type: component -categories: -- Retrieval Augmented Generation \ No newline at end of file diff --git a/assets/large_language_models/dbcopilot/components/llm_dbcopilot_grounding_ground_samples/spec.yaml b/assets/large_language_models/dbcopilot/components/llm_dbcopilot_grounding_ground_samples/spec.yaml deleted file mode 100644 index 2f0a7a6230..0000000000 --- a/assets/large_language_models/dbcopilot/components/llm_dbcopilot_grounding_ground_samples/spec.yaml +++ /dev/null @@ -1,25 +0,0 @@ -$schema: https://azuremlschemas.azureedge.net/latest/commandComponent.schema.json -type: command -tags: {} -name: llm_dbcopilot_grounding_ground_samples -display_name: LLM - DBCopilot Grounding Ground Samples Component -version: 0.0.45 -inputs: - grounding_context: - type: uri_folder - optional: false - include_builtin: - type: boolean - optional: true - tools: - type: string - optional: true - sample_folder: - type: uri_folder - optional: true -outputs: - output_chunk_file: - type: uri_folder -code: ../src -environment: azureml:llm-dbcopilot-embeddings@latest -command: python example_grounding.py --output_chunk_file '${{outputs.output_chunk_file}}' --grounding_context '${{inputs.grounding_context}}' $[[--include_builtin '${{inputs.include_builtin}}']] $[[--tools '${{inputs.tools}}']] $[[--sample_folder '${{inputs.sample_folder}}']] diff --git a/assets/large_language_models/dbcopilot/components/src/__init__.py b/assets/large_language_models/dbcopilot/components/src/__init__.py deleted file mode 100644 index c59cddd4f8..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -"""Utilities for dbcopilot embedding components.""" diff --git a/assets/large_language_models/dbcopilot/components/src/component_base.py b/assets/large_language_models/dbcopilot/components/src/component_base.py deleted file mode 100644 index a6c5f6e8ea..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/component_base.py +++ /dev/null @@ -1,207 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -"""Component base class.""" -import argparse -import functools -import inspect -import json -import logging -import os -import sys -import time -from functools import cached_property -from typing import Dict, Optional - -from azure.ai.ml import MLClient -from azure.ai.ml.identity import AzureMLOnBehalfOfCredential -from azure.identity import DefaultAzureCredential, ManagedIdentityCredential -from azureml.core import Run, Workspace -from azureml.core.authentication import AzureCliAuthentication, MsiAuthentication -from db_copilot_tool.telemetry import set_print_logger, track_function - - -def main_entry_point(function_name: str): - """main_entry_point.""" - - def decorator(cls): - @track_function(name=f"{cls.__name__}.{function_name}") - def wrapper(**kwargs): - instance = cls() - getattr(instance, function_name)(**kwargs) - - set_print_logger() - if len(sys.argv) > 0: - class_file_name = os.path.abspath(inspect.getsourcefile(cls)) - entry_file_name = os.path.abspath(sys.argv[0]) - if os.path.basename(entry_file_name) == os.path.basename(class_file_name): - logging.basicConfig( - format="[%(asctime)s] [%(levelname)s] [%(filename)s] %(message)s", - level=logging.INFO, - ) - logging.info("Arguments: %s", sys.argv) - parser = argparse.ArgumentParser( - description=f"{function_name} command line interface" - ) - sig = inspect.signature(getattr(cls, function_name)) - for param in sig.parameters.values(): - if param.name == "self": - continue - type_value = ( - param.annotation - if param.annotation != bool - else lambda x: x in ("True", "true", "1", True) - ) - if param.default == inspect.Parameter.empty: - parser.add_argument( - f"--{param.name}", type=type_value, required=True - ) - else: - parser.add_argument( - f"--{param.name}", type=type_value, default=param.default - ) - - # Parse the command-line arguments - args = parser.parse_args() - logging.info("\n".join(f"{k}={v}" for k, v in vars(args).items())) - try: - wrapper(**vars(args)) - except Exception as ex: - raise ex - finally: - logging.info("finally") - time.sleep(5) - return cls - - return decorator - - -class ComponentBase: - """ComponentBase.""" - - def __init__(self) -> None: - """__init__.""" - pass - - parameter_type_mapping = {} - - parameter_mode_mapping = {} - - @classmethod - def get_parameter_type_mapping(cls) -> Dict[str, str]: - """get_parameter_type_mapping.""" - return cls.parameter_type_mapping - - @classmethod - def get_parameter_mode_mapping(cls) -> Dict[str, str]: - """get_parameter_mode_mapping.""" - return cls.parameter_mode_mapping - - @cached_property - def workspace(self): - """workspace.""" - return self.run.experiment.workspace - - @functools.cached_property - def run(self) -> Run: - """run.""" - try: - run = Run.get_context() - return run - except Exception as ex: - logging.error("Failed to get run from run context. Error: %s", ex) - raise ex - - @functools.cached_property - def default_headers(self): - """default_headers.""" - headers = { - "Authorization": "Bearer %s" % self.run_token, - "Content-Type": "application/json", - } - return headers - - @functools.cached_property - def run_token(self): - """run_token.""" - return os.environ.get("AZUREML_RUN_TOKEN", "") - - @functools.cached_property - def service_endpoint(self): - """service_endpoint.""" - return os.environ.get("AZUREML_SERVICE_ENDPOINT", "") - - @functools.cached_property - def workspace_scope(self): - """workspace_scope.""" - return os.environ.get("AZUREML_WORKSPACE_SCOPE", "") - - @staticmethod - def parse_llm_config(config_str: str) -> Optional[str]: - """parse_llm_config.""" - config = json.loads(config_str) - return config["deployment_name"] - - -class OBOComponentBase(ComponentBase): - """OBOComponentBase.""" - - def __init__(self) -> None: - """__init__.""" - super().__init__() - - @functools.cached_property - def azureml_auth(self): - """azureml_auth.""" - client_id = os.environ.get("DEFAULT_IDENTITY_CLIENT_ID", None) - if "OBO_ENDPOINT" in os.environ: - logging.info("Using OBO authentication") - os.environ["MSI_ENDPOINT"] = os.environ.get("OBO_ENDPOINT", "") - auth = MsiAuthentication() - elif client_id is not None: - logging.info("Using Managed Identity authentication") - auth = ManagedIdentityCredential(client_id=client_id) - else: - logging.info("Using Azure CLI authentication") - auth = AzureCliAuthentication() - return auth - - @functools.cached_property - def mlclient_credential(self): - """mlclient_credential.""" - for key, value in os.environ.items(): - logging.debug("%s: %s", key, value) - if "OBO_ENDPOINT" in os.environ: - logging.info("Using OBO authentication") - credential = AzureMLOnBehalfOfCredential() - os.environ["MSI_ENDPOINT"] = os.environ.get("OBO_ENDPOINT", "") - elif "MSI_ENDPOINT" in os.environ and os.environ.get("MSI_ENDPOINT") != "": - logging.info("Using MSI authentication") - credential = ManagedIdentityCredential( - client_id=os.environ.get("DEFAULT_IDENTITY_CLIENT_ID") - ) - else: - credential = DefaultAzureCredential( - exclude_managed_identity_credential=True - ) - return credential - - @functools.cached_property - def workspace(self) -> Workspace: - """workspace.""" - run = Run.get_context() - workspace: Workspace = run.experiment.workspace - return workspace - - @functools.cached_property - def ml_client(self) -> MLClient: - """ml_client.""" - credential = self.mlclient_credential - workspace = self.workspace - logging.info("workspace: %s", workspace) - client = MLClient( - credential=credential, - subscription_id=workspace._subscription_id, - resource_group_name=workspace._resource_group, - workspace_name=workspace._workspace_name, - ) - return client diff --git a/assets/large_language_models/dbcopilot/components/src/database_grounding.py b/assets/large_language_models/dbcopilot/components/src/database_grounding.py deleted file mode 100644 index 69543e5d80..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/database_grounding.py +++ /dev/null @@ -1,85 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -"""Component for grounding database tables and columns.""" -import json -import logging -from typing import Dict - -from component_base import ComponentBase, main_entry_point -from db_copilot.db_provider.grounding.grounding_service import GroundingConfig -from db_copilot_tool.contracts.embedding_config import EmbeddingConfig -from db_copilot_tool.tools.db_executor_factory import DBExecutorConfig -from db_copilot_tool.tools.db_provider_adapter import DBProviderServiceAdapter, DBProviderServiceConfig -from db_copilot_tool.tools.dummy_embedding_service import DummyEmbeddingService - - -@main_entry_point("ground") -class DataBaseGrounding(ComponentBase): - """DataBaseGrounding Class.""" - - parameter_type_mapping: Dict[str, str] = { - "output_chunk_file": "uri_folder", - "output_ngram_file": "uri_folder", - "output_grounding_context_file": "uri_folder", - } - - def ground( - self, - output_chunk_file: str, - output_grounding_context_file: str, - asset_uri: str = None, - max_tables: int = None, - max_columns: int = None, - max_rows: int = None, - max_sampling_rows: int = None, - max_text_length: int = None, - max_knowledge_pieces: int = None, - selected_tables: str = None, - column_settings: str = None, - include_views: bool = False, - ): - """Ground database tables and columns.""" - from utils.asset_utils import get_datastore_uri - - logging.info("Grounding...") - embedding_config = EmbeddingConfig() - - grounding_config = GroundingConfig() - if max_tables: - grounding_config.max_tables = max_tables - if max_columns: - grounding_config.max_columns = max_columns - if max_rows: - grounding_config.max_rows = max_rows - if max_sampling_rows: - grounding_config.max_sampling_rows = max_sampling_rows - if max_text_length: - grounding_config.max_text_length = max_text_length - if max_knowledge_pieces: - grounding_config.max_knowledge_pieces = max_knowledge_pieces - - db_executor_config = DBExecutorConfig() - if selected_tables: - db_executor_config.tables = json.loads(selected_tables) - if not isinstance(db_executor_config.tables, list): - raise ValueError("selected_tables must be a list") - if column_settings: - db_executor_config.column_settings = json.loads(column_settings) - if not isinstance(db_executor_config.column_settings, dict): - raise ValueError("column_settings must be a dict") - if include_views: - if db_executor_config.metadata is None: - db_executor_config.metadata = {} - db_executor_config.metadata["include_views"] = include_views - datastore_uri = get_datastore_uri(self.workspace, asset_uri) - db_provider_config = DBProviderServiceConfig( - db_uri=datastore_uri, - embedding_service_config=embedding_config, - grounding_config=grounding_config, - db_executor_config=db_executor_config, - ) - - db_provider = DBProviderServiceAdapter(db_provider_config, workspace=self.workspace) - assert isinstance(db_provider.embedding_service, DummyEmbeddingService) - db_provider.embedding_service.dump(output_chunk_file) - db_provider.dump_context(output_grounding_context_file) diff --git a/assets/large_language_models/dbcopilot/components/src/db_copilot_mir/code/app_management.py b/assets/large_language_models/dbcopilot/components/src/db_copilot_mir/code/app_management.py deleted file mode 100644 index 29468ffd00..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/db_copilot_mir/code/app_management.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -"""App management module.""" -import importlib -import json -import logging -from dataclasses import dataclass - -from flask import Flask - - -@dataclass -class AppConfig: - """App config.""" - - module_name: str = "app" - app_name: str = "app" - port: int = 8080 - - @staticmethod - def load_from_file(file: str = "app_config.json"): - """Load the app config from file.""" - with open(file) as f: - data = json.load(f) - return AppConfig(**data) - - -def start_flask_app(config: AppConfig): - """Start the flask app.""" - logging.info(f"Starting Flask app: {config.module_name}.{config.app_name} at port {config.port}") - app_module = importlib.import_module(f"app_code.{config.module_name}") - app = getattr(app_module, config.app_name) - assert isinstance(app, Flask) - app.run(host="localhost", port=config.port) diff --git a/assets/large_language_models/dbcopilot/components/src/db_copilot_mir/code/general_score.py b/assets/large_language_models/dbcopilot/components/src/db_copilot_mir/code/general_score.py deleted file mode 100644 index 83e1f7a1df..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/db_copilot_mir/code/general_score.py +++ /dev/null @@ -1,108 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -"""General score script for db_copilot_mir.""" -import logging -import socket -import subprocess -import threading -import time - -import requests -from app_management import AppConfig, start_flask_app -from azureml.contrib.services.aml_request import AMLRequest, rawhttp -from azureml.contrib.services.aml_response import AMLResponse -from db_copilot_tool.telemetry import set_print_logger -from flask import Response, stream_with_context - - -def pick_random_port(): - """Pick a random port.""" - with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - s.bind(("localhost", 0)) - return s.getsockname()[1] - - -def run_command(command): - """Run a command.""" - logging.info(f"Running command: {command}") - process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) - if process: - while True: - output = process.stdout.readline() - error = process.stderr.readline() - if output == b"" and error == b"" and process.poll() is not None: - break - if output: - logging.info(output.decode().strip()) - if error: - logging.error(error.decode().strip()) - else: - logging.error("Failed to start process") - - -def init(): - """Initialize the score script.""" - set_print_logger() - global app_thread - global app_port - # global rslex_thread - # rslex_thread = None - app_thread = None - app_port = pick_random_port() - app_config = AppConfig.load_from_file() - app_config.port = app_port - - def start_flask(): - start_flask_app(app_config) - - if not app_thread or not app_thread.is_alive(): - app_thread = threading.Thread(target=start_flask) - app_thread.start() - - # rslex_mount = os.environ.get("RSLEX-MOUNT", None) - - # if rslex_mount and (not rslex_thread or not rslex_thread.is_alive()): - - # def start_rslex(): - # cmd = f"/tmp/dbcopilot/rslex-fuse-cli --mount-point /tmp/workspace_mount/ --source-url {rslex_mount}" - # run_command(cmd) - - # rslex_thread = threading.Thread(target=start_rslex) - # rslex_thread.start() - - time.sleep(3) - if not app_thread.is_alive(): - raise Exception("App thread failed to start") - # if rslex_thread and not rslex_thread.is_alive(): - # raise Exception("Rslex thread failed to start") - - # for file in os.listdir("/tmp/workspace_mount/"): - # logging.info(f"File: {file}") - logging.info(f"Init complete: Pork:{app_port}") - - -@rawhttp -def run(request: AMLRequest): - """Score script.""" - logging.info(f"Request: {request.__dict__}") - api = request.headers.get("api", None) - is_stream = request.headers.get("is_stream", False) - if is_stream: - is_stream = is_stream in ("true", "True") - if api: - api.lstrip("/") - url = f"http://localhost:{app_port}/{api}" if api else f"http://localhost:{app_port}" - logging.info(f"Router url: {url}. Is stream: {is_stream}") - response = requests.request(request.method, url, headers=request.headers, data=request.data, stream=is_stream) - logging.info("Request processed") - if is_stream: - - def generate(): - for content in response.iter_content(chunk_size=1024): - logging.info(f"Content: {content}") - yield content - logging.info("Stream complete") - - return Response(stream_with_context(generate()), mimetype="application/json", status=200) - else: - return AMLResponse(response.text, response.status_code) diff --git a/assets/large_language_models/dbcopilot/components/src/db_copilot_mir/code/score.py b/assets/large_language_models/dbcopilot/components/src/db_copilot_mir/code/score.py deleted file mode 100644 index 50b0910a03..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/db_copilot_mir/code/score.py +++ /dev/null @@ -1,119 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -"""File for MIR endpoint score function.""" -import json -import logging -import os -from typing import Optional - -from azureml.contrib.services.aml_request import AMLRequest, rawhttp -from azureml.contrib.services.aml_response import AMLResponse -from db_copilot_tool.contracts.db_copilot_config import DBCopilotConfig -from db_copilot_tool.history_service.history_service import HistoryService -from db_copilot_tool.telemetry import set_print_logger -from db_copilot_tool.tools.db_copilot_adapter import DBCopilotAdapter -from flask import Response, stream_with_context -from promptflow.connections import AzureOpenAIConnection - - -def init(): - """Initialize the class.""" - global db_copilot - set_print_logger() - - current_dir = os.path.dirname(os.path.realpath(__file__)) - with open(os.path.join(current_dir, "secrets.json")) as f: - secret_manager: dict = json.load(f) - embedding_aoai_connection = AzureOpenAIConnection( - api_key=secret_manager.get("embedding-aoai-api-key"), - api_base=secret_manager.get("embedding-aoai-api-base"), - api_type="azure", - api_version="2023-03-15-preview", - ) - chat_aoai_connection = AzureOpenAIConnection( - api_key=secret_manager.get("chat-aoai-api-key"), - api_base=secret_manager.get("chat-aoai-api-base"), - api_type="azure", - api_version="2023-03-15-preview", - ) - dbcopilot_config_file = os.path.join(current_dir, "db_copilot_config.json") - with open(dbcopilot_config_file) as f: - db_copilot_config_dict: dict = json.load(f) - logging.info("DBCopilot config: %s", db_copilot_config_dict) - # validate config - db_copilot_config = DBCopilotConfig(**db_copilot_config_dict) - history_service = HistoryService(db_copilot_config.history_service_config) - db_copilot = DBCopilotAdapter( - db_copilot_config, - embedding_aoai_connection=embedding_aoai_connection, - chat_aoai_connection=chat_aoai_connection, - history_service=history_service, - ) - - -def stream_generate( - question: str, - session_id: Optional[str], - temperature: float = None, - top_p: float = None, -): - """generate.""" - for cells in db_copilot.stream_generate(question, session_id, temperature, top_p): - logging.info("Cells: %s", cells) - yield json.dumps(cells) - - -def generate( - question: str, - session_id: Optional[str], - temperature: float = None, - top_p: float = None, -): - """generate.""" - cells = list(db_copilot.stream_generate(question, session_id, temperature, top_p))[ - -1 - ] - logging.info("Cells: %s", cells) - return json.dumps(cells) - - -@rawhttp -def run(request: AMLRequest): - """run.""" - session_id = request.headers.get("session-id", None) - if not session_id: - session_id = request.headers.get("aml-session-id", None) - request_id = request.headers.get("x-request-id", None) - temperature = request.headers.get("llm-temperature", None) - top_p = request.headers.get("llm-top-p", None) - is_stream = request.headers.get("llm-stream", False) - question = request.get_data(as_text=True) - logging.info("Request question: %s", question) - logging.info("Request session id: %s", session_id) - logging.info("Request temperature: %s", temperature) - logging.info("Request top p: %s", top_p) - logging.info("Request is stream: %s", is_stream) - logging.info("Request id: %s", request_id) - try: - if is_stream: - return Response( - stream_with_context( - ( - json.dumps(item) - for item in db_copilot.stream_generate( - question, session_id, temperature, top_p - ) - ) - ), - mimetype="application/json", - status=200, - ) - else: - return AMLResponse( - list(db_copilot.generate(question, session_id, temperature, top_p)), - json_str=True, - status_code=200, - ) - except Exception as e: - logging.exception("Exception: %s", e) - return AMLResponse(str(e), 500) diff --git a/assets/large_language_models/dbcopilot/components/src/db_copilot_mir/code/score_zero.py b/assets/large_language_models/dbcopilot/components/src/db_copilot_mir/code/score_zero.py deleted file mode 100644 index d1f64d76f4..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/db_copilot_mir/code/score_zero.py +++ /dev/null @@ -1,466 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -"""File for MIR endpoint score function.""" -import json -import logging -import os -import tempfile -import uuid -from dataclasses import asdict, dataclass -from enum import Enum -from typing import Dict, List, Optional, Union - -from azureml.contrib.services.aml_request import AMLRequest, rawhttp -from azureml.contrib.services.aml_response import AMLResponse -from db_copilot.contract.memory_core import MemoryItem -from db_copilot_tool.contracts.db_copilot_config import DBCopilotConfig -from db_copilot_tool.history_service.dialogue_sessions import DialogueSession -from db_copilot_tool.history_service.history_service import ( - HistoryService, - HistoryServiceConfig, -) -from db_copilot_tool.telemetry import set_print_logger -from db_copilot_tool.tools.azureml_asset_handler import DatastoreUploader -from db_copilot_tool.tools.db_copilot_adapter import DBCopilotAdapter -from db_copilot_tool.tools.memory_cache import MemoryCache -from flask import Response, stream_with_context -from promptflow.connections import AzureOpenAIConnection - - -def init(): - """Initialize the class.""" - set_print_logger() - current_dir = os.path.dirname(os.path.realpath(__file__)) - cache_dir = os.getenv("AZUREML_MODEL_DIR") - global embedding_aoai_connection, chat_aoai_connection, shared_config, history_service - global db_copilots - global db_copilots_shared - db_copilots = MemoryCache(60 * 60) - db_copilots_shared = MemoryCache(24 * 30 * 60 * 60) - # setting up history service - history_service_cache_dir = os.path.join(tempfile.tempdir, "history_cache") - if not os.path.exists(history_service_cache_dir): - os.makedirs(history_service_cache_dir) - history_service_config = HistoryServiceConfig( - history_service_enabled=True, - cache_dir=history_service_cache_dir, - expire_seconds=3600, - max_cache_size_mb=100, - ) - history_service = HistoryService(history_service_config) - # setting up db copilot - with open(os.path.join(current_dir, "secrets.json")) as f: - secret_manager: dict = json.load(f) - api_key = secret_manager.get("embedding-aoai-api-key", None) - if api_key: - logging.info("Using api_key access Azure OpenAI") - embedding_aoai_connection = AzureOpenAIConnection( - api_key=secret_manager.get("embedding-aoai-api-key"), - api_base=secret_manager.get("embedding-aoai-api-base"), - api_type="azure", - api_version="2023-03-15-preview", - ) - chat_aoai_connection = AzureOpenAIConnection( - api_key=secret_manager.get("chat-aoai-api-key"), - api_base=secret_manager.get("chat-aoai-api-base"), - api_type="azure", - api_version="2023-03-15-preview", - ) - else: - logging.info("using managed identity access Azure OpenAI") - embedding_aoai_connection = AzureOpenAIConnection( - api_base=secret_manager.get("embedding-aoai-api-base"), - api_type="azure", - api_version="2023-03-15-preview", - ) - chat_aoai_connection = AzureOpenAIConnection( - api_base=secret_manager.get("chat-aoai-api-base"), - api_type="azure", - api_version="2023-03-15-preview", - ) - embedding_deploy_name = secret_manager.get("embedding-deploy-name") - chat_deploy_name = secret_manager.get("chat-deploy-name") - shared_config_file = os.path.join(current_dir, "shared_config.json") - if os.path.exists(shared_config_file): - with open(shared_config_file) as f: - shared_config = json.load(f) - else: - shared_config = {} - shared_config["embedding_aoai_deployment_name"] = embedding_deploy_name - shared_config["chat_aoai_deployment_name"] = chat_deploy_name - assert isinstance(shared_config, dict) - if cache_dir: - for visibility in [Visibility.Private, Visibility.Shared]: - folder_path = os.path.join(cache_dir, visibility.value.lower()) - if os.path.exists(folder_path): - for db_name in os.listdir(folder_path): - if os.path.exists( - os.path.join(folder_path, db_name, "config.json") - ): - with open( - os.path.join(folder_path, db_name, "config.json"), "r" - ) as f: - logging.info(f"Loading config for {db_name}") - config_json = json.load(f) - config = DBCopilotConfig(**config_json) - set_db_copilot_adapter( - db_name, config, visibility=visibility - ) - - config_file = os.path.join(current_dir, "configs.json") - if os.path.exists(config_file): - with open(config_file) as f: - configs = json.load(f) - if isinstance(configs, list): - for config in configs: - name = config.get("db_name", None) or config.get( - "datastore_uri", None - ) - if "db_name" in config: - config.pop("db_name", None) - config = {**shared_config, **config} - db_copilot_config = DBCopilotConfig(**config) - set_db_copilot_adapter( - name, db_copilot_config, visibility=Visibility.Shared - ) - else: - raise ValueError(f"Invalid config file: {configs}") - - -def cleanup(): - """Clean up db_copilots cache.""" - if db_copilots: - logging.info("Cleaning up db_copilots") - db_copilots.delete() - if db_copilots_shared: - logging.info("Cleaning up db_copilots_shared") - db_copilots_shared.delete() - - -def set_db_copilot_adapter(db_name, db_copilot_config, visibility): - """Set a dbcopilot adapter.""" - cache_dir = os.getenv("AZUREML_MODEL_DIR") - cache_uri = os.getenv("DBCOPILOT_CACHE_URI") - - def simple_db_name(db_name): - if db_name.startswith("azureml://"): - return db_name.split("/")[-1].replace(".", "_") - return db_name - - instruct_template = os.getenv("INSTRUCT_TEMPLATE", None) - if cache_uri: - cache_folder = os.path.join( - cache_dir, visibility.value.lower(), simple_db_name(db_name) - ) - with DatastoreUploader( - f"{cache_uri}{visibility.value.lower()}/{simple_db_name(db_name)}", - cache_folder, - ): - db_copilot_adapter = DBCopilotAdapter( - db_copilot_config, - embedding_aoai_connection=embedding_aoai_connection, - chat_aoai_connection=chat_aoai_connection, - history_service=history_service, - cache_folder=cache_folder, - instruct_template=instruct_template, - ) - else: - db_copilot_adapter = DBCopilotAdapter( - db_copilot_config, - embedding_aoai_connection=embedding_aoai_connection, - chat_aoai_connection=chat_aoai_connection, - history_service=history_service, - instruct_template=instruct_template, - ) - if visibility == Visibility.Shared: - db_copilots_shared.set(db_name, db_copilot_adapter) - else: - db_copilots.set(db_name, db_copilot_adapter) - - -class CaseInsensitiveEnum(Enum): - """CaseInsensitiveEnum.""" - - @classmethod - def _missing_(cls, value): - if isinstance(value, str): - for member in cls: - if member.name.lower() == value.lower(): - return member - raise ValueError(f"{value} is not a valid {cls.__name__}") - - -class RequestType(CaseInsensitiveEnum): - """RequestType.""" - - Chat = "Chat" - Grounding = "Grounding" - GetSources = "GetSources" - SampleQueries = "SampleQueries" - Summary = "Summary" - - -class Visibility(CaseInsensitiveEnum): - """Visibility.""" - - Shared = "Shared" - Private = "Private" - - -@dataclass -class RequestBody: - """RequestBody.""" - - request_type: Union[RequestType, str] = RequestType.Chat - visibility: Union[Visibility, str] = Visibility.Shared - db_name: Optional[str] = None - question: Optional[str] = None - datastore_uri: Optional[str] = None - # LLM Config - temperature: Optional[float] = None - top_p: Optional[float] = None - # DBExecutorConfig - selected_tables: List[str] = None - column_settings: Dict[str, Dict[str, str]] = None - # GroundingConfig - max_tables: Optional[int] = None - max_columns: Optional[int] = None - max_rows: Optional[int] = None - max_sampling_rows: Optional[int] = None - max_text_length: Optional[int] = None - max_knowledge_pieces: Optional[int] = None - is_stream: bool = False - # Context - tools: Optional[List[str]] = None - include_built_in: bool = True - sample_folder: Optional[str] = None - knowledge_pieces: Optional[str] = None - # index & context - grounding_embedding_uri: str = None - example_embedding_uri: str = None - db_context_uri: str = None - # history memory - history_memory: Optional[List[MemoryItem]] = None - include_memory: bool = False - include_sample_queries: bool = False - # for dbcopilot - extra_kwargs: Optional[Dict[str, str]] = None - - def __post_init__(self): - """Post init.""" - if isinstance(self.request_type, str): - self.request_type = RequestType(self.request_type) - if isinstance(self.visibility, str): - self.visibility = Visibility(self.visibility) - if self.history_memory and not isinstance(self.history_memory, list): - raise ValueError("history_memory must be a list") - if self.history_memory: - history_memory = [] - - for memory_item in self.history_memory: - if isinstance(memory_item, dict): - memory_item = MemoryItem.from_dict(memory_item) - history_memory.append(memory_item) - self.history_memory = history_memory - - def to_db_copilot_config(self, shared_config: dict): - """To db copilot config.""" - config_dict = asdict(self) - block_keys = ["request_type", "visibility", "db_name", "question"] - for key in block_keys: - config_dict.pop(key, None) - config_dict = {**shared_config, **config_dict} - return DBCopilotConfig(**config_dict) - - -def _get_db_provider(request_body: RequestBody, session_id: str): - db_copilot = None - if request_body.db_name or request_body.datastore_uri: - db_copilot: DBCopilotAdapter = db_copilots_shared.get( - request_body.db_name - if request_body.db_name - else request_body.datastore_uri, - None, - ) - return db_copilot - elif session_id: - db_copilot: DBCopilotAdapter = db_copilots.get(session_id, None) - if db_copilot: - return db_copilot - if len(db_copilots_shared.get_all()) == 1: - db_copilot: DBCopilotAdapter = list(db_copilots_shared.get_all().values())[0] - return db_copilot - else: - return AMLResponse( - "No db_copilot is available. Please specify Session id or datastore_uri or db_name is required", - 400, - ) - - -@rawhttp -def run(request: AMLRequest): - """run.""" - session_id = request.headers.get("session-id", None) - if not session_id: - session_id = request.headers.get("aml-session-id", None) - request_id = request.headers.get("x-request-id", None) - logging.info("Request session id: %s", session_id) - logging.info("Request id: %s", request_id) - cors_headers = { - "Allow": "OPTIONS, GET, POST", - "Access-Control-Allow-Origin": "*", - "Access-Control-Allow-Headers": "*", - "Access-Control-Allow-Methods": "OPTIONS, GET, POST", - } - try: - request_body = RequestBody(**request.json) - logging.info("Request body: %s", request_body) - if request_body.history_memory and not session_id: - session_id = str(uuid.uuid4()) - if request_body.history_memory: - logging.info("Request session id: %s", session_id) - logging.info("Request id: %s", request_id) - dialogue_session = DialogueSession(request_body.history_memory) - history_service.set_dialogue_session( - session_id, dialogue_session, expire_seconds=60 * 5 - ) - if request_body.request_type == RequestType.Summary: - db_copilot = _get_db_provider(request_body, session_id) - if isinstance(db_copilot, AMLResponse): # failed to get db_copilot - return db_copilot - summary, schema = db_copilot.summary - return AMLResponse( - { - "summary": summary, - "schema": schema, - }, - json_str=True, - status_code=200, - ) - if request_body.request_type == RequestType.Grounding: - logging.info("Grounding request") - if request_body.datastore_uri: - db_copilot_config = request_body.to_db_copilot_config(shared_config) - db_name = ( - ( - request_body.db_name - if request_body.db_name - else request_body.datastore_uri - ) - if request_body.visibility == Visibility.Shared - else session_id - ) - set_db_copilot_adapter( - db_name, db_copilot_config, request_body.visibility - ) - else: - raise Exception("datastore_uri is required") - if request_body.request_type == RequestType.Chat or ( - request_body.request_type == RequestType.Grounding and request_body.question - ): - logging.info("Chat request") - - if not request_body.question: - return AMLResponse("Question is required", 400) - db_copilot = _get_db_provider(request_body, session_id) - if isinstance(db_copilot, AMLResponse): # failed to get db_copilot - return db_copilot - if db_copilot is None: - response = AMLResponse( - f"No db_copilot is available for session {session_id}", 400 - ) - for key, value in cors_headers.items(): - response.headers[key] = value - return response - if request_body.is_stream: - return Response( - stream_with_context( - ( - json.dumps(item) - for item in db_copilot.stream_generate( - request_body.question, - session_id, - request_body.temperature, - request_body.top_p, - request_body.extra_kwargs, - ) - ) - ), - headers=cors_headers, - mimetype="application/json", - status=200, - ) - else: - if request_body.include_sample_queries or request_body.include_memory: - response = AMLResponse( - { - "response": list( - db_copilot.generate( - request_body.question, - session_id, - request_body.temperature, - request_body.top_p, - request_body.extra_kwargs, - ) - ), - "sample_queries": db_copilot.get_example_queries( - request_body.question, session_id - ) - if request_body.include_sample_queries - else [], - "history_memory": [ - asdict(memory) - for memory in history_service.get_dialogue_session( - session_id - ).messageHistory - ] - if request_body.include_memory - else None, - }, - json_str=True, - status_code=200, - ) - else: - response = AMLResponse( - list( - db_copilot.generate( - request_body.question, - session_id, - request_body.temperature, - request_body.top_p, - request_body.extra_kwargs, - ) - ), - json_str=True, - status_code=200, - ) - for key, value in cors_headers.items(): - response.headers[key] = value - return response - elif request_body.request_type == RequestType.GetSources: - logging.info("GetSources request") - sources = db_copilots_shared.get_all().keys() - logging.info("Sources: %s", sources) - response = AMLResponse(list(sources), json_str=True, status_code=200) - for key, value in cors_headers.items(): - response.headers[key] = value - return response - elif request_body.request_type == RequestType.SampleQueries: - logging.info("SampleQueries request") - if not request_body.db_name: - return AMLResponse("db_name is required", 400) - if not request_body.question: - return AMLResponse("Question is required", 400) - db_copilot = _get_db_provider(request_body, session_id) - return AMLResponse( - db_copilot.get_example_queries(request_body.question, session_id), - json_str=True, - status_code=200, - ) - - except Exception as e: - logging.exception("Exception: %s", e) - response = AMLResponse(str(e), 500) - for key, value in cors_headers.items(): - response.headers[key] = value - return response diff --git a/assets/large_language_models/dbcopilot/components/src/endpoint_deployment.py b/assets/large_language_models/dbcopilot/components/src/endpoint_deployment.py deleted file mode 100644 index ce2adbfb7a..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/endpoint_deployment.py +++ /dev/null @@ -1,121 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -"""The component deploys the endpoint for db copilot.""" -import json -import logging -import os -import shutil -import tempfile -from dataclasses import asdict -from typing import Dict - -from component_base import main_entry_point -from db_copilot_tool.contracts.db_copilot_config import DBCopilotConfig -from endpoint_deployment_base import EndpointDeploymentBase - - -@main_entry_point("deploy") -class EndpointDeployment(EndpointDeploymentBase): - """EndpointDeployment Class.""" - - def __init__(self) -> None: - """Initialize the class.""" - super().__init__() - - parameter_type_mapping: Dict[str, str] = { - "grounding_embedding_uri": "uri_folder", - "example_embedding_uri": "uri_folder", - "db_context_uri": "uri_folder", - } - - parameter_mode_mapping: Dict[str, str] = { - "db_context_uri": "direct", - "grounding_embedding_uri": "direct", - "example_embedding_uri": "direct", - } - - def deploy( - self, - deployment_name: str, - endpoint_name: str, - grounding_embedding_uri: str, - embedding_aoai_deployment_name: str, - chat_aoai_deployment_name: str, - db_context_uri: str, - asset_uri: str, - mir_environment: str, - example_embedding_uri: str = None, - selected_tables: str = None, - max_tables: int = None, - max_columns: int = None, - max_rows: int = None, - max_text_length: int = None, - max_knowledge_pieces: int = None, - tools: str = None, - temperature: float = 0.0, - top_p: float = 0.0, - knowledge_pieces: str = None, - sku: str = "Standard_DS3_v2", - include_views: bool = False, - instruct_template: str = None, - egress_public_network_access: str = "enabled" - ): - """deploy_endpoint.""" - from utils.asset_utils import get_datastore_uri - - workspace = self.workspace - # find datastore uri - - datastore_uri = get_datastore_uri(workspace, asset_uri) - logging.info(f"Datastore uri: {datastore_uri}") - secrets_dict = self.get_secrets() - - config = DBCopilotConfig( - grounding_embedding_uri=grounding_embedding_uri, - example_embedding_uri=example_embedding_uri, - db_context_uri=db_context_uri, - chat_aoai_deployment_name=chat_aoai_deployment_name, - datastore_uri=datastore_uri, - embedding_aoai_deployment_name=embedding_aoai_deployment_name, - history_cache_enabled=True, - selected_tables=selected_tables, - max_tables=max_tables, - max_columns=max_columns, - max_rows=max_rows, - max_text_length=max_text_length, - max_knowledge_pieces=max_knowledge_pieces, - tools=tools, - temperature=temperature, - top_p=top_p, - knowledge_pieces=knowledge_pieces, - include_views=include_views, - ) - logging.info(f"DBCopilotConfig: {config}") - # mir_environment = get_full_env_path(self.mlclient_credential, mir_environment) - with tempfile.TemporaryDirectory() as code_dir: - logging.info("code_dir: %s", code_dir) - current_dir = os.path.dirname(os.path.abspath(__file__)) - shutil.copytree( - os.path.join(current_dir, "db_copilot_mir/code"), - code_dir, - dirs_exist_ok=True, - ) - with open(os.path.join(code_dir, "secrets.json"), "w") as f: - json.dump(secrets_dict, f) - logging.info("dumped secrets to secrets.json") - with open(os.path.join(code_dir, "configs.json"), "w") as f: - json.dump([asdict(config)], f) - managed_identity_enabled = os.getenv("MANAGED_IDENTITY_ENABLED", None) - self._deploy_endpoint( - mir_environment, - endpoint_name, - deployment_name, - code_dir, - score_script="score_zero.py", - extra_environment_variables={ - "INSTRUCT_TEMPLATE": instruct_template, - "MANAGED_IDENTITY_ENABLED": managed_identity_enabled, - }, - sku=sku, - egress_public_network_access=egress_public_network_access, - ) diff --git a/assets/large_language_models/dbcopilot/components/src/endpoint_deployment_base.py b/assets/large_language_models/dbcopilot/components/src/endpoint_deployment_base.py deleted file mode 100644 index 5e107f85b8..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/endpoint_deployment_base.py +++ /dev/null @@ -1,164 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -"""The component deploys the endpoint for db copilot.""" -import logging -import os -from typing import Dict, Optional - -from azure.ai.ml.entities import ( - CodeConfiguration, - Environment, - IdentityConfiguration, - ManagedIdentityConfiguration, - ManagedOnlineDeployment, - ManagedOnlineEndpoint, - Model, - OnlineRequestSettings, -) -from azureml.rag.utils.connections import ( - connection_to_credential, - get_connection_by_id_v2, -) -from component_base import OBOComponentBase, main_entry_point - - -@main_entry_point("deploy") -class EndpointDeploymentBase(OBOComponentBase): - """EndpointDeployment Class.""" - - def __init__(self) -> None: - """Initialize the class.""" - super().__init__() - - def get_secrets(self): - """Get aoai secrets.""" - embedding_connection_id = os.environ.get( - "AZUREML_WORKSPACE_CONNECTION_ID_AOAI_EMBEDDING", None - ) - chat_connection_id = os.environ.get( - "AZUREML_WORKSPACE_CONNECTION_ID_AOAI_CHAT", None - ) - - secrets = {} - if ( - embedding_connection_id is not None - and embedding_connection_id != "" - and chat_connection_id is not None - and chat_connection_id != "" - ): - for connection_type, connection_id in { - "embedding": embedding_connection_id, - "chat": chat_connection_id, - }.items(): - connection = get_connection_by_id_v2( - connection_id, credential=self.mlclient_credential - ) - credential = connection_to_credential(connection) - if hasattr(credential, "key"): - secrets.update( - { - f"{connection_type}-aoai-api-key": credential.key, - f"{connection_type}-aoai-api-base": connection.target, - } - ) - logging.info("Using workspace connection key for OpenAI") - else: - logging.info("Using managed identity for OpenAI") - secrets.update( - { - f"{connection_type}-aoai-api-base": connection.target, - } - ) - else: - raise ValueError( - "Please specify the connection id (AZUREML_WORKSPACE_CONNECTION_ID_AOAI_EMBEDDING & AZUREML_WORKSPACE_CONNECTION_ID_AOAI_CHAT) for embedding and chat" # noqa: E501 - ) - - return secrets - - def _deploy_endpoint( - self, - mir_environment: str, - endpoint_name: str, - deployment_name: str, - code_dir: str, - score_script: str = "score.py", - extra_environment_variables: Dict[str, str] = None, - model: Optional[Model] = None, - sku: str = "Standard_DS3_v2", - egress_public_network_access: str = "enabled", - ): - from utils.asset_utils import get_full_env_path - - endpoint = ManagedOnlineEndpoint( - name=endpoint_name, - description="DB CoPilot MIR endpoint", - auth_mode="key", - identity=IdentityConfiguration( - type="UserAssigned", - user_assigned_identities=[ManagedIdentityConfiguration(client_id=None)], - ), - ) - mir_environment = get_full_env_path(self.mlclient_credential, mir_environment) - env = ( - mir_environment - if mir_environment.startswith("azureml://") - else Environment(image=mir_environment) - ) - logging.info("Environment: %s", env) - environment_variables = { - "EMBEDDING_STORE_LOCAL_CACHE_PATH": "/tmp/embedding_store_cache", - "WORKER_COUNT": "1", - "WORKER_TIMEOUT": "0", - "GUNICORN_CMD_ARGS": "--threads 20", - "AML_CORS_ORIGINS": "*", - "AZUREML_WORKSPACE_NAME": self.workspace.name, - "AZUREML_SUBSCRIPTION_ID": self.workspace.subscription_id, - "AZUREML_RESOURCE_GROUP": self.workspace.resource_group, - } - if extra_environment_variables: - environment_variables.update(extra_environment_variables) - deployment = ManagedOnlineDeployment( - name=deployment_name, - endpoint_name=endpoint_name, - environment=env, - environment_variables=environment_variables, - model=model, - code_configuration=CodeConfiguration( - code=code_dir, scoring_script=score_script - ), - instance_type=sku, - instance_count=1, - request_settings=OnlineRequestSettings( - request_timeout_ms=90000, - max_concurrent_requests_per_instance=1000, - max_queue_wait_ms=90000, - ), - egress_public_network_access=egress_public_network_access, - ) - logging.info("Deployment: %s", deployment) - ml_client = self.ml_client - try: - ml_client.online_endpoints.get(endpoint_name) - except Exception: - logging.info(f"Creating endpoint {endpoint_name}") - endpoint_poller = ml_client.online_endpoints.begin_create_or_update( - endpoint, local=False - ) - endpoint_poller.result() - logging.info(f"Created endpoint {endpoint_name}") - try: - deployment_poller = ml_client.online_deployments.begin_create_or_update( - deployment=deployment, local=False - ) - deployment_result = deployment_poller.result() - logging.info( - f"Created deployment {deployment_name}. Result: {deployment_result}" - ) - except Exception as e: - logging.error(f"Deployment failed: {e}") - logs = ml_client.online_deployments.get_logs( - name=deployment_name, endpoint_name=endpoint_name, lines=300 - ) - logging.error(f"Endpoint deployment logs: {logs}") - raise e diff --git a/assets/large_language_models/dbcopilot/components/src/example_grounding.py b/assets/large_language_models/dbcopilot/components/src/example_grounding.py deleted file mode 100644 index c74dbe67b9..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/example_grounding.py +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -"""The component generates the ground truth for the examples.""" -import json -import os -from typing import Dict - -from component_base import ComponentBase, main_entry_point -from db_copilot.contract.db_core import DatabaseType -from db_copilot_tool.contracts.embedding_config import EmbeddingConfig -from db_copilot_tool.tools.dummy_embedding_service import DummyEmbeddingService -from db_copilot_tool.tools.in_context_learning_agent import InContextLearningAgent - - -@main_entry_point("ground") -class ExampleGrounding(ComponentBase): - """ExampleGrounding Class.""" - - def __init__(self) -> None: - """Initialize the class.""" - super().__init__() - - parameter_type_mapping: Dict[str, str] = { - "sample_folder": "uri_folder", - "output_chunk_file": "uri_folder", - "grounding_context": "uri_folder", - } - - def ground( - self, - output_chunk_file: str, - grounding_context: str, - include_builtin: bool = True, - tools: str = None, - sample_folder: str = None, - ): - """Ground the examples.""" - if ( - grounding_context - and os.path.exists(grounding_context) - and os.path.exists(os.path.join(grounding_context, "db_type.json")) - ): - with open(os.path.join(grounding_context, "db_type.json"), "r") as f: - database_type = json.load(f) - db_type = DatabaseType(database_type) - tools = json.loads(tools) if tools else None - if tools: - assert isinstance(tools, list) or isinstance(tools, dict) - examples = InContextLearningAgent.get_examples( - example_uri=sample_folder, - db_type=db_type, - tools=tools, - include_built_in=include_builtin, - ) - agent = InContextLearningAgent( - embedding_config=EmbeddingConfig(), examples=examples - ) - - assert isinstance(agent.embedding_service, DummyEmbeddingService) - agent.embedding_service.dump(output_chunk_file) diff --git a/assets/large_language_models/dbcopilot/components/src/no_grounding_endpoint_deployment.py b/assets/large_language_models/dbcopilot/components/src/no_grounding_endpoint_deployment.py deleted file mode 100644 index 9d6ae1abd8..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/no_grounding_endpoint_deployment.py +++ /dev/null @@ -1,91 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -"""The component deploys the endpoint for db copilot.""" -import json -import logging -import os -import shutil -import tempfile -from typing import Dict - -from azure.ai.ml.constants import AssetTypes -from azure.ai.ml.entities import Model -from component_base import main_entry_point -from endpoint_deployment_base import EndpointDeploymentBase - - -@main_entry_point("deploy") -class NoGroundingEndpointDeployment(EndpointDeploymentBase): - """EndpointDeployment Class.""" - - parameter_type_mapping: Dict[str, str] = { - "cache_path": "uri_folder", - } - - parameter_mode_mapping: Dict[str, str] = { - "cache_path": "direct", - } - - def __init__(self) -> None: - """Initialize the class.""" - super().__init__() - - def deploy( - self, - deployment_name: str, - endpoint_name: str, - embedding_connection: str, - embedding_aoai_deployment_name: str, - chat_connection: str, - chat_aoai_deployment_name: str, - mir_environment: str, - configs_json: str = None, - cache_path: str = None, - ): - """deploy_endpoint.""" - from utils.asset_utils import get_full_env_path - - model = None - extra_environment = {} - - if cache_path: - model = Model( - name=f"endpoint-{endpoint_name}-{deployment_name}-cache", - path=cache_path, - type=AssetTypes.CUSTOM_MODEL, - description=f"cache for endpoint {endpoint_name} deployment: {deployment_name}", - ) - extra_environment["DBCOPILOT_CACHE_URI"] = cache_path - os.environ[ - "AZUREML_WORKSPACE_CONNECTION_ID_AOAI_EMBEDDING" - ] = embedding_connection - os.environ["AZUREML_WORKSPACE_CONNECTION_ID_AOAI_CHAT"] = chat_connection - secrets_dict = self.get_secrets() - secrets_dict["embedding-deploy-name"] = embedding_aoai_deployment_name - secrets_dict["chat-deploy-name"] = chat_aoai_deployment_name - mir_environment = get_full_env_path(self.mlclient_credential, mir_environment) - with tempfile.TemporaryDirectory() as code_dir: - logging.info("code_dir: %s", code_dir) - current_dir = os.path.dirname(os.path.abspath(__file__)) - shutil.copytree( - os.path.join(current_dir, "db_copilot_mir/code"), - code_dir, - dirs_exist_ok=True, - ) - with open(os.path.join(code_dir, "secrets.json"), "w") as f: - json.dump(secrets_dict, f) - logging.info("dumped secrets to secrets.json") - if configs_json is not None: - configs = json.loads(configs_json) - assert isinstance(configs, list), "configs_json must be a JSON list" - with open(os.path.join(code_dir, "configs.json"), "w") as f: - json.dump(configs, f) - self._deploy_endpoint( - mir_environment, - endpoint_name, - deployment_name, - code_dir, - "score_zero.py", - model=model, - extra_environment_variables=extra_environment, - ) diff --git a/assets/large_language_models/dbcopilot/components/src/prompt_flow_creation.py b/assets/large_language_models/dbcopilot/components/src/prompt_flow_creation.py deleted file mode 100644 index eb035939c2..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/prompt_flow_creation.py +++ /dev/null @@ -1,138 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -"""The component create the example promptflow for db copilot.""" -import logging -import os -from typing import Dict -import yaml - -from component_base import main_entry_point, OBOComponentBase -from promptflow.azure import PFClient - - -@main_entry_point("create") -class PromptFlowCreation(OBOComponentBase): - """PromptFlowCreation Class.""" - - FLOW_DIRECTORY = os.path.join(os.path.dirname(__file__), "prompt_flows") - - FLOW_DAG = os.path.join(os.path.dirname(__file__), "prompt_flows", "flow.dag.yaml") - - def __init__(self): - """Initialize the class.""" - super().__init__() - - parameter_type_mapping: Dict[str, str] = { - "grounding_embedding_uri": "uri_folder", - "example_embedding_uri": "uri_folder", - "db_context_uri": "uri_folder", - } - - parameter_mode_mapping: Dict[str, str] = { - "db_context_uri": "direct", - "grounding_embedding_uri": "direct", - "example_embedding_uri": "direct", - } - - def create( - self, - index_name: str, - grounding_embedding_uri: str, - embedding_aoai_deployment_name: str, - db_context_uri: str, - asset_uri: str, - chat_aoai_deployment_name: str = None, - example_embedding_uri: str = None, - llm_config: str = None, - runtime: str = None, - knowledge_pieces: str = None, - include_views: bool = False, - instruct_template: str = None, - ): - """Create the prompt flow.""" - from utils.asset_utils import get_datastore_uri, parse_connection - - logging.info("Creating PromptFlow for DBCopilot") - workspace = self.workspace - - # find datastore uri - datastore_uri = get_datastore_uri(workspace, asset_uri) - logging.info(f"Datastore uri: {datastore_uri}") - - managed_identity_enabled = os.environ.get("MANAGED_IDENTITY_ENABLED", None) - embedding_connection_id = os.environ.get( - "AZUREML_WORKSPACE_CONNECTION_ID_AOAI_EMBEDDING", None - ) - if embedding_connection_id is not None and embedding_connection_id != "": - connection_dict = parse_connection(embedding_connection_id) - if connection_dict: - embedding_aoai_connection = connection_dict["connection_name"] - logging.info(f"Embedding connection: {embedding_aoai_connection}") - else: - logging.warning( - f"Unable to parse connection string {embedding_connection_id}" - ) - else: - logging.error("Unable to find AOAI embedding connection") - raise ValueError("Unable to find AOAI embedding connection") - - chat_connection_id = os.environ.get( - "AZUREML_WORKSPACE_CONNECTION_ID_AOAI_CHAT", None - ) - if chat_connection_id is not None and chat_connection_id != "": - connection_dict = parse_connection(chat_connection_id) - if connection_dict: - chat_aoai_connection = connection_dict["connection_name"] - logging.info(f"Chat connection: {chat_aoai_connection}") - else: - logging.warning( - f"Unable to parse connection string {chat_connection_id}" - ) - else: - logging.error("Unable to find AOAI chat connection") - raise ValueError("Unable to find AOAI chat connection") - - if ( - chat_aoai_deployment_name is None - and llm_config is not None - and llm_config != "" - ): - chat_aoai_deployment_name = self.parse_llm_config(llm_config) - - # update flow - with open(self.FLOW_DAG, "r", encoding="utf-8") as file: - flow_data = yaml.safe_load(file) - flow_data['name'] = index_name + "_Flow" - flow_data['nodes'][0]['inputs']['embedding_aoai_config'] = embedding_aoai_connection - flow_data['nodes'][0]['inputs']['chat_aoai_config'] = chat_aoai_connection - flow_data['nodes'][0]['inputs']['db_context_uri'] = db_context_uri - flow_data['nodes'][0]['inputs']['grounding_embedding_uri'] = grounding_embedding_uri - flow_data['nodes'][0]['inputs']['datastore_uri'] = datastore_uri - flow_data['nodes'][0]['inputs']['embedding_aoai_deployment_name'] = embedding_aoai_deployment_name - flow_data['nodes'][0]['inputs'][ - 'chat_aoai_deployment_name'] = chat_aoai_deployment_name if chat_aoai_deployment_name else "" - flow_data['nodes'][0]['inputs']['example_embedding_uri'] = example_embedding_uri - flow_data['nodes'][0]['inputs']['knowledge_pieces'] = knowledge_pieces - flow_data["nodes"][0]["inputs"]["include_views"] = include_views - flow_data["nodes"][0]["inputs"]["instruct_template"] = instruct_template - - with open(self.FLOW_DAG, "w", encoding="utf-8") as file: - yaml.safe_dump(flow_data, file) - - # create flow - pf_client = PFClient(ml_client=self.ml_client) - flow = self.FLOW_DIRECTORY - data = os.path.join(self.FLOW_DIRECTORY, "data.jsonl") - environment_variables = { - "AZUREML_WORKSPACE_NAME": self.workspace.name, - "AZUREML_SUBSCRIPTION_ID": self.workspace.subscription_id, - "AZUREML_RESOURCE_GROUP": self.workspace.resource_group, - "MANAGED_IDENTITY_ENABLED": managed_identity_enabled, - } - base_run = pf_client.run( - flow=flow, - data=data, - runtime=runtime, - environment_variables=environment_variables, - ) - pf_client.stream(base_run) diff --git a/assets/large_language_models/dbcopilot/components/src/prompt_flows/.promptflow/flow.tools.json b/assets/large_language_models/dbcopilot/components/src/prompt_flows/.promptflow/flow.tools.json deleted file mode 100644 index a0e494b137..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/prompt_flows/.promptflow/flow.tools.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "code": { - "chat_session_tool.py": { - "type": "python", - "inputs": { - "chat_history": { - "type": [ - "list" - ] - } - }, - "source": "chat_session_tool.py", - "function": "session_python_tool" - } - }, - "package": {} -} \ No newline at end of file diff --git a/assets/large_language_models/dbcopilot/components/src/prompt_flows/chat_session_tool.py b/assets/large_language_models/dbcopilot/components/src/prompt_flows/chat_session_tool.py deleted file mode 100644 index 1fd0533dd1..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/prompt_flows/chat_session_tool.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -"""chat session tool.""" -from promptflow import tool -import uuid - - -# The inputs section will change based on the arguments of the tool function, after you save the code -# Adding type to arguments and return value will help the system show the types properly -# Please update the function name/signature per need -@tool -def session_python_tool(chat_history: list) -> str: - """Session Python Tool.""" - if chat_history: - if 'session_id' in chat_history[-1]['outputs']: - return chat_history[-1]['outputs']['session_id'] - sid = str(uuid.uuid4()) - return sid diff --git a/assets/large_language_models/dbcopilot/components/src/prompt_flows/data.jsonl b/assets/large_language_models/dbcopilot/components/src/prompt_flows/data.jsonl deleted file mode 100644 index bac2ed2964..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/prompt_flows/data.jsonl +++ /dev/null @@ -1 +0,0 @@ -{"question":"How many tables are there in the database?", "output": "59"} \ No newline at end of file diff --git a/assets/large_language_models/dbcopilot/components/src/prompt_flows/flow.dag.yaml b/assets/large_language_models/dbcopilot/components/src/prompt_flows/flow.dag.yaml deleted file mode 100644 index 3b07bd1040..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/prompt_flows/flow.dag.yaml +++ /dev/null @@ -1,57 +0,0 @@ -environment: - python_requirements_txt: requirements.txt -id: dbcopilot_flow -inputs: - chat_history: - default: [] - is_chat_history: true - is_chat_input: false - type: list - question: - default: Hi - is_chat_input: true - type: string -name: index_name_Flow -node_variants: {} -nodes: -- inputs: - chat_aoai_config: - chat_aoai_deployment_name: - datastore_uri: - db_context_uri: - embedding_aoai_config: - embedding_aoai_deployment_name: - example_embedding_uri: - grounding_embedding_uri: - history_cache_dir: /tmp/cache - history_cache_enabled: true - query: ${inputs.question} - session_id: ${chat_session_tool.output} - knowledge_pieces: - include_views: - instruct_template: - name: DBCopilot_generate - source: - tool: db_copilot_tool.db_copilot_tool.DBCopilot.generate - type: package - type: python - use_variants: false -- aggregation: false - inputs: - chat_history: ${inputs.chat_history} - name: chat_session_tool - source: - path: chat_session_tool.py - type: code - type: python - use_variants: false -outputs: - answer: - is_chat_output: true - reference: ${DBCopilot_generate.output} - type: string - session_id: - evaluation_only: false - is_chat_output: false - reference: ${chat_session_tool.output} - type: string diff --git a/assets/large_language_models/dbcopilot/components/src/prompt_flows/requirements.txt b/assets/large_language_models/dbcopilot/components/src/prompt_flows/requirements.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/assets/large_language_models/dbcopilot/components/src/raw_endpoint_deployment.py b/assets/large_language_models/dbcopilot/components/src/raw_endpoint_deployment.py deleted file mode 100644 index 43327e81bc..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/raw_endpoint_deployment.py +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -"""The component deploys the endpoint for db copilot.""" -import json -import logging -import os -import shutil -import tempfile -from typing import Dict - -from component_base import main_entry_point -from endpoint_deployment_base import EndpointDeploymentBase - - -@main_entry_point("deploy") -class RawEndpointDeployment(EndpointDeploymentBase): - """EndpointDeployment Class.""" - - def __init__(self) -> None: - """Initialize the class.""" - super().__init__() - - parameter_type_mapping: Dict[str, str] = {"code_uri": "uri_folder"} - - def deploy( - self, - deployment_name: str, - endpoint_name: str, - mir_environment: str, - code_folder: str, - app_module_name: str = "app", - app_name: str = "app", - ): - """deploy_endpoint.""" - from utils.asset_utils import get_full_env_path - - mir_environment = get_full_env_path(self.mlclient_credential, mir_environment) - with tempfile.TemporaryDirectory() as code_dir: - logging.info("code_dir: %s", code_dir) - current_dir = os.path.dirname(os.path.abspath(__file__)) - score_code_dir = os.path.join(current_dir, "db_copilot_mir/code") - logging.info("copying code from %s to %s", score_code_dir, code_dir) - shutil.copytree(score_code_dir, code_dir, dirs_exist_ok=True) - logging.info( - "copying code from %s to %s", - code_folder, - os.path.join(code_dir, "app_code"), - ) - shutil.copytree( - code_folder, os.path.join(code_dir, "app_code"), dirs_exist_ok=True - ) - with open(os.path.join(code_dir, "app_config.json"), "w") as f: - app_config = {"module_name": app_module_name, "app_name": app_name} - json.dump(app_config, f) - logging.info("Starting deploy endpoint") - extra_environment_variables = { - "RSLEX-MOUNT": f"azureml://subscriptions/{self.workspace.subscription_id}/resourcegroups/{self.workspace.resource_group}/workspaces/{self.workspace.name}/datastores/workspaceblobstore" # noqa: E501 - } - self._deploy_endpoint( - mir_environment, - endpoint_name, - deployment_name, - code_dir, - "general_score.py", - extra_environment_variables=extra_environment_variables, - ) diff --git a/assets/large_language_models/dbcopilot/components/src/utils/__init__.py b/assets/large_language_models/dbcopilot/components/src/utils/__init__.py deleted file mode 100644 index c59cddd4f8..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/utils/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -"""Utilities for dbcopilot embedding components.""" diff --git a/assets/large_language_models/dbcopilot/components/src/utils/asset_utils.py b/assets/large_language_models/dbcopilot/components/src/utils/asset_utils.py deleted file mode 100644 index f219f8b95c..0000000000 --- a/assets/large_language_models/dbcopilot/components/src/utils/asset_utils.py +++ /dev/null @@ -1,127 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -"""Asset utils.""" -import logging -import re -from typing import Tuple - -from azure.ai.ml import MLClient -from azure.ai.ml.entities import Environment -from azureml.core import Workspace - - -def parse_registry_asset_path(asset_type: str, path: str) -> Tuple[str, str, str]: - """parse_registry_asset_path.""" - pattern = r"\/registries\/(?P[^\/]+)\/{}\/(?P[^\/]+)\/versions\/(?P[^\/]+)" - pattern2 = r"\/registries\/(?P[^\/]+)\/{}\/(?P[^\/]+)\/?" - match = re.search(pattern.format(asset_type), path) - if match: - registry = match.group("registry") - asset_name = match.group("asset_name") - version = match.group("version") - return registry, asset_name, version - else: - match = re.search(pattern2.format(asset_type), path) - if match: - registry = match.group("registry") - asset_name = match.group("asset_name") - version = None - return registry, asset_name, version - else: - logging.info(f"failed to parse env path {path}") - return None, None, None - - -def parse_asset_path(asset_type: str, path: str) -> Tuple[str, str]: - """parse_asset_path.""" - pattern = r"\/{}\/(?P[^\/]+)\/versions\/(?P[^\/]+)".format( - asset_type - ) - match = re.search(pattern, path) - if match: - asset_name = match.group("asset_name") - version = match.group("version") - return asset_name, version - else: - logging.info(f"failed to parse asset path {path}") - raise ValueError(f"Invalid path: {path}") - - -def parse_data_path(path: str) -> Tuple[str, str]: - """parse_data_path.""" - pattern = ( - r"\/datastores\/(?P[^\/]+)\/paths\/(?P.+\/)" - ) - match = re.search(pattern, path) - if match: - datastore_name = match.group("datastore_name") - relative_path = match.group("relative_path") - return datastore_name, relative_path - else: - raise ValueError(f"Invalid path: {path}") - - -def parse_data_asset(asset_id: str) -> Tuple[str, str]: - """parse_data_asset.""" - return parse_asset_path("data", asset_id) - - -def parse_datastore_uri(uri: str): - """parse_datastore_uri.""" - regexes = [ - r"azureml://subscriptions/(?P[^/]+)/resourcegroups/(?P[^/]+)/workspaces/(?P[^/]+)/datastores/(?P[^/]+)/paths/(?P[^/]+)", # noqa: E501 - r"azureml://subscriptions/(?P[^/]+)/resourcegroups/(?P[^/]+)/workspaces/(?P[^/]+)/datastores/(?P[^/]+)", # noqa: E501 - r"azureml://datastores/(?P[^/]+)/paths/(?P[^/]+)", - r"azureml://datastores/(?P[^/]+)", - ] - for regex in regexes: - match = re.match(regex, uri) - if match: - return match.groupdict() - return None - - -def get_datastore_uri(workspace: Workspace, datastore_uri: str): - """get_datastore_uri.""" - if datastore_uri.startswith("azureml://"): - parsed_uri = parse_datastore_uri(datastore_uri) - if parsed_uri is None: - raise ValueError(f"Unable to parse datastore uri {datastore_uri}") - if "subscription_id" in parsed_uri: - datastore_uri = datastore_uri - else: - datastore_uri = f"azureml://subscriptions/{workspace.subscription_id}/resourcegroups/{workspace.resource_group}/workspaces/{workspace.name}/datastores/{parsed_uri['datastore_name']}" # noqa: E501 - if "relative_path" in parsed_uri: - datastore_uri = datastore_uri + f"/paths/{parsed_uri['relative_path']}" - else: - datastore_uri = f"azureml://subscriptions/{workspace.subscription_id}/resourcegroups/{workspace.resource_group}/workspaces/{workspace.name}/datastores/{datastore_uri}" # noqa: E501 - return datastore_uri - - -def get_full_env_path(credential, path: str) -> str: - """get_full_env_path.""" - if path.startswith("azureml://"): - registry, environment_name, version = parse_registry_asset_path( - "environments", path - ) - if registry and version is None: - ml_client = MLClient(credential, registry_name=registry) - envs = ml_client.environments.list(environment_name) - envs_sorted = sorted( - envs, key=lambda x: x.creation_context.created_at, reverse=True - ) - # Select the latest environment - latest_env: Environment = envs_sorted[0] - logging.info(f"Using latest environment {latest_env.id}") - return latest_env.id - return path - - -def parse_connection(connection_uri: str): - """parse_connection.""" - regex = r"/subscriptions/(?P[^/]+)/resourceGroups/(?P[^/]+)/providers/Microsoft.MachineLearningServices/workspaces/(?P[^/]+)/connections/(?P[^/]+)" # noqa: E501 - match = re.match(regex, connection_uri) - if match: - return match.groupdict() - else: - return None diff --git a/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/asset.yaml b/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/asset.yaml deleted file mode 100644 index 96f57ae057..0000000000 --- a/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/asset.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: llm-dbcopilot-embeddings -version: auto -type: environment -spec: spec.yaml -extra_config: environment.yaml -categories: -- Retrieval Augmented Generation diff --git a/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/context/Dockerfile b/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/context/Dockerfile deleted file mode 100644 index 7a9bd5b493..0000000000 --- a/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/context/Dockerfile +++ /dev/null @@ -1,69 +0,0 @@ -FROM mcr.microsoft.com/azureml/promptflow/promptflow-runtime-stable:latest -WORKDIR / - -USER root - -# Install necessary tools -RUN apt-get update && apt-get install -y \ - curl \ - gnupg \ - unixodbc-dev \ - git \ - git-man && \ - rm -rf /var/lib/apt/lists/* - -# Install MS SQL ODBC Driver -RUN apt-get update \ - && curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \ - && curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list \ - && apt-get update \ - && ACCEPT_EULA=Y apt-get install -y --no-install-recommends msodbcsql18=18.3.3.1-1 msodbcsql17=17.10.6.1-1 \ - && rm -rf /var/lib/apt/lists/* - -# Default to UTF-8 file.encoding -ENV LANG C.UTF-8 - -# Set the shared environment path -ENV AZUREML_CONDA_ENVIRONMENT_PATH /azureml-envs/prompt-flow/runtime -ENV PATH $AZUREML_CONDA_ENVIRONMENT_PATH/bin:$PATH - -# Copy the environment file -COPY ./requirements.txt ./ - -# dbcopilot environment -RUN /bin/bash -c "source /opt/miniconda/etc/profile.d/conda.sh && \ - conda activate $AZUREML_CONDA_ENVIRONMENT_PATH && \ - pip install --upgrade pip && \ - pip install -r requirements.txt && \ - pip install db-copilot-tool==0.0.8 &&\ - pip install cryptography==43.0.1 langchain==0.2.11 idna==3.7 sqlparse==0.5.0 gunicorn==22.0.0 Werkzeug==3.0.3 requests==2.32.0 azure-identity==1.16.1 langchain-community==0.2.9" - -# Fix vunerabilities -RUN /bin/bash -c "source /opt/miniconda/etc/profile.d/conda.sh && \ - conda activate /opt/miniconda && \ - pip install cryptography==43.0.1 idna==3.7 sqlparse==0.5.0 gunicorn==22.0.0 tqdm==4.66.3 requests==2.32.0 azure-identity==1.16.1 urllib3==2.2.2 certifi==2024.07.04&& \ - conda deactivate" - -# Install certificates and other utilities -RUN set -eux; \ - apt-get update; \ - apt-get install -y --no-install-recommends \ - # utilities for keeping Debian and OpenJDK CA certificates in sync - ca-certificates p11-kit wget \ - ; \ - rm -rf /var/lib/apt/lists/* - -ENV JAVA_HOME /usr/local/openjdk-21 -ENV PATH $JAVA_HOME/bin:$PATH - -# Default to UTF-8 file.encoding -ENV LANG C.UTF-8 - -# https://jdk.java.net/ -# > -# > Java Development Kit builds, from Oracle -# > -ENV JAVA_VERSION 21-ea+22 - -COPY setup.sh . -RUN bash setup.sh \ No newline at end of file diff --git a/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/context/requirements.txt b/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/context/requirements.txt deleted file mode 100644 index 196052e04c..0000000000 --- a/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/context/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -azureml-rag[cognitive_search,data_generation]==0.2.34 -azureml-contrib-services -azureml-core~=1.53.0 -azure-kusto-data==4.2.0 -plotly~=5.13.1 -recognizers-text-suite~=1.0.2a2 -applicationinsights~=0.11.10 -azure-cosmos~=4.4.0 -clickhouse_connect~=0.7.2 \ No newline at end of file diff --git a/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/context/setup.sh b/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/context/setup.sh deleted file mode 100644 index 314aa64f1c..0000000000 --- a/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/context/setup.sh +++ /dev/null @@ -1,56 +0,0 @@ -set -eux; -arch="$(dpkg --print-architecture)"; -case "$arch" in -'amd64') -downloadUrl='https://download.java.net/java/GA/jdk21/fd2272bbf8e04c3dbaee13770090416c/35/GPL/openjdk-21_linux-x64_bin.tar.gz'; -downloadSha256='a30c454a9bef8f46d5f1bf3122830014a8fbe7ac03b5f8729bc3add4b92a1d0a'; -;; -*) echo >&2 "error: unsupported architecture: '$arch'"; exit 1 ;; -esac; - -savedAptMark="$(apt-mark showmanual)"; - -wget --progress=dot:giga -O openjdk.tgz "$downloadUrl"; -echo "$downloadSha256 *openjdk.tgz" | sha256sum --strict --check -; - -mkdir -p "$JAVA_HOME"; -tar --extract \ ---file openjdk.tgz \ ---directory "$JAVA_HOME" \ ---strip-components 1 \ ---no-same-owner \ -; -rm openjdk.tgz*; - -apt-mark auto '.*' > /dev/null; -[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark > /dev/null; -apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true; - -# update "cacerts" bundle to use Debian's CA certificates (and make sure it stays up-to-date with changes to Debian's store) -# see https://github.com/docker-library/openjdk/issues/327 -# http://rabexc.org/posts/certificates-not-working-java#comment-4099504075 -# https://salsa.debian.org/java-team/ca-certificates-java/blob/3e51a84e9104823319abeb31f880580e46f45a98/debian/jks-keystore.hook.in -# https://git.alpinelinux.org/aports/tree/community/java-cacerts/APKBUILD?id=761af65f38b4570093461e6546dcf6b179d2b624#n29 -mkdir -p /etc/ca-certificates/update.d; -ls -al /etc/ca-certificates; -{ -echo '#!/usr/bin/env bash'; -echo 'set -Eeuo pipefail'; -echo 'trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$JAVA_HOME/lib/security/cacerts"'; -} > /etc/ca-certificates/update.d/docker-openjdk; -chmod +x /etc/ca-certificates/update.d/docker-openjdk; -/etc/ca-certificates/update.d/docker-openjdk; -update-ca-certificates; - -# https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 -find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; -ldconfig; - -# https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 -# https://openjdk.java.net/jeps/341 -java -Xshare:dump; - -# basic smoke test -fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; -javac --version; -java --version \ No newline at end of file diff --git a/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/environment.yaml b/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/environment.yaml deleted file mode 100644 index 4c86ffa87d..0000000000 --- a/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/environment.yaml +++ /dev/null @@ -1,12 +0,0 @@ -image: - name: azureml/curated/llm-dbcopilot-embeddings - os: linux - context: - dir: context - dockerfile: Dockerfile - template_files: - - Dockerfile - - conda_dependencies.yaml - publish: - location: mcr - visibility: public \ No newline at end of file diff --git a/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/spec.yaml b/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/spec.yaml deleted file mode 100644 index 42e6c5ccc2..0000000000 --- a/assets/large_language_models/dbcopilot/environments/dbcopilot_embeddings/spec.yaml +++ /dev/null @@ -1,15 +0,0 @@ -$schema: https://azuremlschemas.azureedge.net/latest/environment.schema.json - -description: >- - An environment for Large Language Model Retrieval Augmented Generation standard grounding database components. - -name: "{{asset.name}}" -version: "{{asset.version}}" -build: - path: "{{image.context.path}}" - dockerfile_path: "{{image.dockerfile.path}}" - -os_type: linux - -tags: - Preview: "" diff --git a/assets/large_language_models/dbcopilot/environments/dbcopilot_mir/asset.yaml b/assets/large_language_models/dbcopilot/environments/dbcopilot_mir/asset.yaml deleted file mode 100644 index 67be37ba08..0000000000 --- a/assets/large_language_models/dbcopilot/environments/dbcopilot_mir/asset.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: llm-dbcopilot-mir -version: auto -type: environment -spec: spec.yaml -extra_config: environment.yaml -categories: -- Retrieval Augmented Generation diff --git a/assets/large_language_models/dbcopilot/environments/dbcopilot_mir/context/Dockerfile b/assets/large_language_models/dbcopilot/environments/dbcopilot_mir/context/Dockerfile deleted file mode 100644 index bec604e234..0000000000 --- a/assets/large_language_models/dbcopilot/environments/dbcopilot_mir/context/Dockerfile +++ /dev/null @@ -1,51 +0,0 @@ -FROM mcr.microsoft.com/azureml/minimal-ubuntu22.04-py39-cpu-inference:{{latest-image-tag}} -WORKDIR / - -USER root - -RUN apt-get update \ - && apt-get install -y --no-install-recommends curl unixodbc gnupg2 python3.10 \ - && curl https://packages.microsoft.com/keys/microsoft.asc | tee /etc/apt/trusted.gpg.d/microsoft.asc \ - && curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | tee /etc/apt/sources.list.d/mssql-release.list \ - && apt-get update \ - && ACCEPT_EULA=Y apt-get install -y msodbcsql18=18.3.3.1-1 \ - python3.10-minimal \ - python3.10 \ - libpython3.10-minimal \ - libpython3.10-stdlib \ - curl \ - libcurl4 \ - libexpat1 \ - expat \ - libapparmor1 \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -# NGINX configuration -RUN NGINX_CONF=/etc/nginx/sites-enabled/app; \ - sed -i "$(grep "location /" $NGINX_CONF -n | cut -f1 -d:) a proxy_buffering off;" $NGINX_CONF - -# Set environment variables -ENV BUILD_INFO='{"build_number": "0.0.1"}' -# Copy the environment file -COPY ./requirements.txt ./ - -# dbcopilot environment -RUN python -m pip install --upgrade pip && \ - # Install necessary tools - pip install -r requirements.txt && \ - # Install promptflow environment - pip install promptflow-python-bundle[azure]==0.3.0 && \ - pip install promptflow-vectordb==0.2.13 langchain-community==0.2.16 && \ - ## Install dbcopilot - pip install db-copilot-tool==0.0.8 &&\ - pip install setuptools==70.0.0 grpcio==1.56.2 - -# Fix vunerabilities -RUN /bin/bash -c "source /opt/miniconda/etc/profile.d/conda.sh && \ - conda activate /opt/miniconda/envs/amlenv && \ - pip install sqlparse==0.5.0 gunicorn==22.0.0 Werkzeug==3.0.3 azure-identity==1.16.1 certifi==2024.07.04 --upgrade protobuf&& \ - conda deactivate" - -# For GUNICORN_CMD_ARGS, we need to set the timeout to be 0 so that the server will not timeout -# ENV AML_CORS_ORIGINS="*" \ No newline at end of file diff --git a/assets/large_language_models/dbcopilot/environments/dbcopilot_mir/context/requirements.txt b/assets/large_language_models/dbcopilot/environments/dbcopilot_mir/context/requirements.txt deleted file mode 100644 index 0aaf99a0a7..0000000000 --- a/assets/large_language_models/dbcopilot/environments/dbcopilot_mir/context/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -azureml-rag[cognitive_search,data_generation]==0.2.34 -plotly~=5.13.1 -azure-kusto-data==4.2.0 -recognizers-text-suite~=1.0.2a2 -azureml-contrib-services -azure-cosmos~=4.4.0 -clickhouse_connect~=0.7.2 \ No newline at end of file diff --git a/assets/large_language_models/dbcopilot/environments/dbcopilot_mir/environment.yaml b/assets/large_language_models/dbcopilot/environments/dbcopilot_mir/environment.yaml deleted file mode 100644 index 97faf3bbb6..0000000000 --- a/assets/large_language_models/dbcopilot/environments/dbcopilot_mir/environment.yaml +++ /dev/null @@ -1,11 +0,0 @@ -image: - name: azureml/curated/llm-dbcopilot-mir - os: linux - context: - dir: context - dockerfile: Dockerfile - template_files: - - Dockerfile - publish: - location: mcr - visibility: public \ No newline at end of file diff --git a/assets/large_language_models/dbcopilot/environments/dbcopilot_mir/spec.yaml b/assets/large_language_models/dbcopilot/environments/dbcopilot_mir/spec.yaml deleted file mode 100644 index 69a0e1e28a..0000000000 --- a/assets/large_language_models/dbcopilot/environments/dbcopilot_mir/spec.yaml +++ /dev/null @@ -1,15 +0,0 @@ -$schema: https://azuremlschemas.azureedge.net/latest/environment.schema.json - -description: >- - An environment for Large Language Model MIR endpoint components. - -name: "{{asset.name}}" -version: "{{asset.version}}" -build: - path: "{{image.context.path}}" - dockerfile_path: "{{image.dockerfile.path}}" - -os_type: linux - -tags: - Preview: ""