Skip to content

Commit

Permalink
✨llm override for chain
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Apr 11, 2024
1 parent 5e446b6 commit 062a182
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/funcchain/syntax/executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def chain(
context: list[BaseMessage] = [],
memory: BaseChatMessageHistory | None = None,
settings_override: SettingsOverride = {},
llm: UniversalChatModel | None = None,
**input_kwargs: Any,
) -> Any:
"""
Expand All @@ -40,6 +41,9 @@ def chain(
memory = memory or ChatMessageHistory()
input_kwargs.update(kwargs_from_parent())

if llm:
settings_override["llm"] = llm

# todo maybe this should be done in the prompt processor?
system = system or settings.system_prompt
if system:
Expand Down Expand Up @@ -77,6 +81,7 @@ async def achain(
context: list[BaseMessage] = [],
memory: BaseChatMessageHistory | None = None,
settings_override: SettingsOverride = {},
llm: UniversalChatModel | None = None,
**input_kwargs: Any,
) -> Any:
"""
Expand All @@ -90,6 +95,9 @@ async def achain(
memory = memory or ChatMessageHistory()
input_kwargs.update(kwargs_from_parent())

if llm:
settings_override["llm"] = llm

# todo maybe this should be done in the prompt processor?
system = system or settings.system_prompt
if system:
Expand Down Expand Up @@ -136,7 +144,7 @@ def compile_runnable(
"""
On the fly compilation of the funcchain syntax.
"""
if settings_override and llm:
if llm:
settings_override["llm"] = llm
instruction = "\n" + instruction
settings = create_local_settings(settings_override)
Expand Down

0 comments on commit 062a182

Please sign in to comment.