Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added LangChain_Chat module #650

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

isaacwasserman
Copy link

This module allows you to use any existing LangChain chat model integration with Vanna.

Using this integration requires no knowledge of the LangChain APIs beyond instantiating a BaseChatModel. Additionally, the existing LLM integrations (OpenAI, Anthropic, etc.) can be replaced by minimal subclasses of LangChain_Chat; an example of this is shown below for OpenAI_Chat.

The goal of this PR is to reduce the need for maintenance of multiple LLM integrations, especially integrations with small userbases.

import os
from ..langchain import LangChain_Chat
from langchain_openai import ChatOpenAI

class OpenAI_Chat(LangChain_Chat):
    def __init__(self, config=None):
        self.temperature = config.get("temperature", 0.7)
        self.model = config.get("model", "gpt-4o-mini")
        self.api_key = config.get("api_key", os.getenv("OPENAI_API_KEY"))
        chat_model = ChatOpenAI(api_key=self.api_key, model=self.model, temperature=self.temperature)
        LangChain_Chat.__init__(self, chat_model, config=config)

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