Skip to content

B Augment the ChainsAPI with Runnables functionality #20

@Siddharth-Khattar

Description

@Siddharth-Khattar

Chain Runnables

Triggered when the chain(s) is selected -> ChainsAPI

(See Context below before proceeding)

Note: A configuration must now represent the chain runnable-attribute pairs as well as their specific configurable_params

I. Create a Configuration extraction engine

When a Chain is selected:

  1. Identifies all the Runnables (and the attribute names for those runnables) in the chain that are using "configurable_fields" or "configurable_alternatives" or "ConfigurableField" functions.
  2. Identifies the specific Fields/Constants(can be defined seperately in the beginning) defined for each Runnable in the chain that is using the functions above.

II. Change the select-chains endpoint in ChainsAPI

  1. POST select-chains endpoint: The user selects a chain. This triggers the engine in the backend which extracts the configuration mentioned above.
  2. (POST) extracted configuration at the Configurations entity in the DB: The extracted config (with the default vals). See the new Configurations schema for the data to send.

Context

A chain can have multiple instances of the same Runnable type. For example:

# This model exposes only the temperature as configurable
model1 = ChatOpenAI(
    model="gpt-4o-mini", temperature=0.5
).configurable_alternatives(
    ConfigurableField(
        id="llm",
        name="LLM",
        description=(
            "Decide whether to use a high or a low temperature parameter for the LLM."
        ),
    ),
    high_temp=ChatOpenAI(temperature=0.9),
    low_temp=ChatOpenAI(temperature=0.1),
    default_key="medium_temp",
)

# Similarly these "model2", "retrieval" and "ranking" runnables also have some specific params that should be exposed.
model2 = ....
retrieval = ....
ranking = ....


chain = prompt | model1 | retrieval | ranking | model2 | StrOutputParser()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions