Skip to content

feat(wren-ai-service): multi-llm deployment and setting loading mechanism - #792

Merged
cyyeh merged 94 commits into
release/ai-service/0.11.xfrom
feat/multi-llm-config-deployment
Nov 15, 2024
Merged

cyyeh merged 94 commits into
release/ai-service/0.11.xfrom
feat/multi-llm-config-deployment

Conversation

@paopa

@paopa paopa commented Oct 22, 2024 •

Copy link
Copy Markdown

This PR introduces a new hierarchical configuration system for the Wren AI Service, significantly improving flexibility and maintainability. It also refactors various components to use this new system, enhancing overall code organization and clarity.

Key Changes

1. New Settings Loading Mechanism

Implemented a hierarchical settings loading mechanism in src/config.py:

  • Introduced a Settings class using pydantic_settings.BaseSettings
  • Settings are now loaded in the following order of precedence:
    1. Default values (defined as class attributes)
    2. Environment variables
    3. .env.dev file
    4. config.yaml file

This approach allows for flexible configuration across different environments while maintaining security for sensitive information.

2. Configuration File Processing

  • Added support for a config.yaml file to configure components, pipelines, and service settings
  • Implemented processors for different configuration types (LLM, Embedder, Document Store, Engine, Pipeline) in src/providers/__init__.py

3. Refactored Provider Initialization

  • Updated generate_components function to use the new configuration system
  • Marked init_providers and Wrapper class as deprecated

4. Environment Variable Consolidation

  • Consolidated OpenAI API keys into a single OPENAI_API_KEY environment variable
  • Similarly consolidated Azure OpenAI API keys into AZURE_OPENAI_API_KEY

5. Updated Service Initialization

  • Modified src/__main__.py to use the new Settings class for service configuration
  • Removed direct environment variable access in favor of the new settings system

6. Docker and Deployment Updates

  • Updated Docker-related files to reflect the new configuration approach
  • Modified Kubernetes deployment files to use the new configuration system
  • Modified wren launcher to use the new configuration system

Benefits

  1. Improved Flexibility: Easier to configure the service for different environments
  2. Enhanced Security: Better separation of sensitive information from code
  3. Cleaner Code: Reduced duplication and improved organization of configuration-related code
  4. Easier Maintenance: Centralized configuration management makes updates and troubleshooting easier

Testing

To ensure the functionality of these changes, please conduct testing in the following environments:

Kubernetes (K8s) Testing

Follow the instructions provided in the deployment README to set up and test in a Kubernetes environment.

Wren Launcher Testing

  1. Modify the following codebase to fetch the compose file and setting file in docker.go
     const (
     	// please change the version when the version is updated
     	WREN_PRODUCT_VERSION    string = "0.10.0"
     	DOCKER_COMPOSE_YAML_URL string = "https://raw.githubusercontent.com/Canner/WrenAI/c524a9695b66d909d718f02d4bdc694eb891174b/docker/docker-compose.yaml"
     	DOCKER_COMPOSE_ENV_URL  string = "https://raw.githubusercontent.com/Canner/WrenAI/c524a9695b66d909d718f02d4bdc694eb891174b/docker/.env.example"
     	AI_SERVICE_CONFIG_URL   string = "https://raw.githubusercontent.com/Canner/WrenAI/c524a9695b66d909d718f02d4bdc694eb891174b/docker/config.example.yaml"
     )
  2. Build and execute the launcher

Docker Compose Testing

  1. Build the updated bootstrap image locally:
    docker build -t bootstrap:local -f ./docker/bootstrap/Dockerfile ./docker/bootstrap/
    
  2. Update the docker-compose file to use the locally built bootstrap image.
  3. Follow the instructions provided in the docker README to start via Docker Compose
  4. Proceed with testing using Docker Compose.

Local Testing

  1. Refer to the project README for local setup instructions.
  2. Configure the necessary config files.
  3. Use the just command to start the service and run tests.

Ensure thorough testing across all environments to validate the changes in the relationship recommendation pipeline.

Documentation

  • Updated README.md with new setup instructions
  • Added configuration.md to explain the new configuration system in detail

This PR represents a significant improvement in how we manage configuration for the Wren AI Service, providing a more robust and flexible foundation for future development.

Next Step

we have to update to date the document, after this PR was be merged

@paopa paopa added module/ai-service ai-service related ci/ai-service ai-service related labels Oct 22, 2024
@paopa
paopa force-pushed the feat/multi-llm-config-deployment branch 4 times, most recently from 4de5c9e to dbc6abe Compare October 23, 2024 03:26
@paopa
paopa marked this pull request as ready for review October 23, 2024 04:08
@paopa
paopa requested a review from cyyeh October 23, 2024 04:08
Comment thread .github/workflows/ai-service-test.yaml
Comment thread docker/.env.example Outdated
Comment thread wren-ai-service/README.md Outdated

@cyyeh cyyeh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! There are some comments below for my first review

@paopa
paopa force-pushed the feat/multi-llm-config-deployment branch from e6fe323 to 8f644f7 Compare October 24, 2024 08:33
@paopa
paopa requested a review from cyyeh October 24, 2024 08:41
@paopa
paopa force-pushed the feat/multi-llm-config-deployment branch 4 times, most recently from 8d3eb52 to b915372 Compare October 30, 2024 06:13
@cyyeh
cyyeh force-pushed the feat/multi-llm-config-deployment branch from f483256 to 210b5e9 Compare October 31, 2024 23:42
@paopa
paopa force-pushed the feat/multi-llm-config-deployment branch from adbef51 to f916640 Compare November 4, 2024 03:25
@paopa
paopa force-pushed the feat/multi-llm-config-deployment branch from c524a96 to dada5a7 Compare November 12, 2024 10:37

@cyyeh cyyeh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added gpt-4o to config.yaml for kustomization. Also I am curious about the new launcher process if users choose "CUSTOM"

@paopa

paopa commented Nov 13, 2024

Copy link
Copy Markdown
Author

I've added gpt-4o to config.yaml for kustomization. Also I am curious about the new launcher process if users choose "CUSTOM"

the behavior will be the same as before, it check whether the config.yaml exist, if not, will print the message in console to guide user to follow the instruction to download and modify the config.

@paopa
paopa requested a review from cyyeh November 13, 2024 08:02
@cyyeh
cyyeh changed the base branch from main to release/ai-service/0.11.x November 13, 2024 11:36

@cyyeh cyyeh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@cyyeh
cyyeh merged commit db6f2a9 into release/ai-service/0.11.x Nov 15, 2024
@cyyeh
cyyeh deleted the feat/multi-llm-config-deployment branch November 15, 2024 03:02
paopa pushed a commit that referenced this pull request Nov 15, 2024
…nism (#792)

Co-authored-by: ChihYu Yeh <chihyu.jimmy.yeh@gmail.com>
Co-authored-by: Ted Yan <tedyyan@hotmail.com>
Co-authored-by: Teddy Yan <xuan.yan@nokia.com>
paopa pushed a commit that referenced this pull request Nov 15, 2024
…nism (#792)

Co-authored-by: ChihYu Yeh <chihyu.jimmy.yeh@gmail.com>
Co-authored-by: Ted Yan <tedyyan@hotmail.com>
Co-authored-by: Teddy Yan <xuan.yan@nokia.com>
paopa pushed a commit that referenced this pull request Nov 15, 2024
…ng mechanism (#792)"

This reverts commit 0f1d8d8.

# Conflicts:
#	wren-ai-service/config.example.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/ai-service ai-service related module/ai-service ai-service related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants