Skip to content

Refactor/creating llm package#13

Open
luillyfe wants to merge 5 commits intomainfrom
refactor/creating-llm-package
Open

Refactor/creating llm package#13
luillyfe wants to merge 5 commits intomainfrom
refactor/creating-llm-package

Conversation

@luillyfe
Copy link
Copy Markdown
Owner

@luillyfe luillyfe commented Jul 12, 2024

LLM Package Refactoring: Modular and Extensible Language Model Integration

Overview
This PR introduces a significant refactoring of our Language Model integration, creating a modular and extensible package for easely swapping between different LLM providers.

Key Changes

  1. Introduced a LanguageModel interface in llm/main.go to standardize LLM interactions.
  2. Implemented Anthropic support in anthropic_client.go
  3. Added Mistral support in mistral_client.go
  4. Abstracted common LLM functionality to allow for easy addition of new providers.

Detailed Changes
1. LanguageModel Interface

  • Created a new interface in llm/main.go that defines a common GenerateText method for all LLM implementations.

2. Anthropic Implementation

  • Refactored existing anthropic integration into AnthropicLLM struct in anthropic_client.go
  • Implemented the LanguageModel interface for Anthropic.
  • Adding configurability for model selection.

3. Mistral Implementation

  • Added new MistralLLM struct in mistral_client.go to support Mistral's LLMs.
  • Implemented the LanguageModel interface for Mistral.
  • Included model selection and default configurations.

Benefits

  • Modularity: Each LLM provider is encapsulated in its own struct and file.
  • Flexibility: Easily swap between different LLM provider or add new ones.
  • Consistency: Standardized interface for all LLM interactions.
  • Extensibility: Simple process to add new functionality across LLMs.
var llm LanguageModel
llm = NewAnthropicLLM("") // or NewMistralLLM("")
response, err := llm.GenerateText(context.Background(), "Your prompt here")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant