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

Utilize configurable_alternatives to provide alternate chat models #8

Open
carolinebridge opened this issue Nov 14, 2024 · 0 comments

Comments

@carolinebridge
Copy link
Collaborator

Discovered while poking around documentation -- the .configurable_alternatives() method may be useful to permit the user to leverage different LLM's based on preference/configuration. Would replace current method in the codebase / might be cleaner. Code example from weblangchain repo:

if has_google_creds:
    llm = ChatOpenAI(
        model="gpt-3.5-turbo-16k",
        # model="gpt-4",
        streaming=True,
        temperature=0.1,
    ).configurable_alternatives(
        # This gives this field an id
        # When configuring the end runnable, we can then use this id to configure this field
        ConfigurableField(id="llm"),
        default_key="openai",
        anthropic=ChatAnthropic(
            model="claude-2",
            max_tokens=16384,
            temperature=0.1,
            anthropic_api_key=os.environ.get("ANTHROPIC_API_KEY", "not_provided"),
        ),
        googlevertex=ChatVertexAI(
            model_name="chat-bison-32k",
            temperature=0.1,
            max_output_tokens=8192,
            stream=True,
        ),
    )
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

No branches or pull requests

1 participant