weaviate / Verba

Retrieval Augmented Generation (RAG) chatbot powered by Weaviate
BSD 3-Clause "New" or "Revised" License
4.84k stars 499 forks source link

Instruction: How to add Anthropic's Claude models #129

Open bakongi opened 3 months ago

bakongi commented 3 months ago

Hi everyone. As you know some latest Anthropic's Claude models is better and chaeper than OpenaAI models. So I create a new generator file to use Anthropic's models. and made changes to manager.py file in goldenverba/components/generation

generation.zip

Install Anthropic library: pip install anthropic

and you should add this variables to your environment (or .env file):

ANTHROPIC_API_KEY=sk-ant-api03-.....pAAA

ANTHROPIC_MODEL=claude-3-haiku-20240307

You will need API key from Anthropic at https://console.anthropic.com/

Available models:

Claude 3 Opus claude-3-opus-20240229
Claude 3 Sonnet claude-3-sonnet-20240229
Claude 3 Haiku claude-3-haiku-20240307

P.S. The generator's code made with help of Claude and GPT-3.5/4

thomashacker commented 2 months ago

Great work! Thanks 🚀 We'll implement it in the coming next update

bakongi commented 2 months ago

I'd forgotten...

in "verba_manager.py" add:

        # Check Anthropic ENV KEY
        try:
            import anthropic

            anthropic_key = os.environ.get("ANTHROPIC_API_KEY", "")

            if anthropic_key != "":
                self.environment_variables["ANTHROPIC_API_KEY"] = True
                anthropic.api_key = anthropic_key

        except Exception:
            self.environment_variables["ANTHROPIC_API_KEY"] = False

and

        try:
            import anthropic

            self.installed_libraries["anthropic"] = True
        except Exception:
            self.installed_libraries["anthropic"] = False