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

Refactor create_input_runnable in io.py #32

Merged
merged 1 commit into from
Oct 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions langchain_werewolf/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,15 @@
def create_input_runnable(
input_func: Callable[[str], Any] | EInputOutputType = click.prompt,
styler: Callable[[str], str] | None = None,
**kwargs,
) -> Runnable[str, str]:
if isinstance(input_func, EInputOutputType):
try:
input_func = _input_map[input_func]
except KeyError:
raise ValueError(f'Invalid input_func: {input_func}')
kwargs = {k: v for k, v in kwargs.items() if k != 'styler'}
return (
(RunnableLambda(styler) if styler else RunnablePassthrough())
| RunnableLambda(partial(input_func, **kwargs))
| RunnableLambda(input_func)
| RunnableLambda(str)
).with_types(
input_type=str,
Expand Down
Loading