Skip to content

Commit

Permalink
release: 1.1.401C
Browse files Browse the repository at this point in the history
  • Loading branch information
willydouhard committed Aug 2, 2024
1 parent c20f579 commit 6435856
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

Nothing unreleased!

## [1.1.401] - 2024-08-02

### Changed

- Directly log step input args by name instead of wrapping them in "args" for readability.

### Fixed

- Langchain Callback handler ValueError('not enough values to unpack (expected 2, got 0)')

## [1.1.400] - 2024-07-29

### Changed
Expand Down
12 changes: 10 additions & 2 deletions backend/chainlit/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import time
import uuid
from copy import deepcopy
from functools import wraps
from typing import Callable, Dict, List, Optional, TypedDict, Union

Expand Down Expand Up @@ -64,6 +65,13 @@ class StepDict(TypedDict, total=False):
feedback: Optional[FeedbackDict]


def flatten_args_kwargs(func, *args, **kwargs):
signature = inspect.signature(func)
bound_arguments = signature.bind(*args, **kwargs)
bound_arguments.apply_defaults()
return {k: deepcopy(v) for k, v in bound_arguments.arguments.items()}


def step(
original_function: Optional[Callable] = None,
*,
Expand Down Expand Up @@ -98,7 +106,7 @@ async def async_wrapper(*args, **kwargs):
show_input=show_input,
) as step:
try:
step.input = {"args": args, "kwargs": kwargs}
step.input = flatten_args_kwargs(func, args, kwargs)
except:
pass
result = await func(*args, **kwargs)
Expand All @@ -125,7 +133,7 @@ def sync_wrapper(*args, **kwargs):
show_input=show_input,
) as step:
try:
step.input = {"args": args, "kwargs": kwargs}
step.input = flatten_args_kwargs(func, args, kwargs)
except:
pass
result = func(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "chainlit"
version = "1.1.400"
version = "1.1.401"
keywords = [
'LLM',
'Agents',
Expand Down

0 comments on commit 6435856

Please sign in to comment.