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

Issue: Function signature injection of config is causing issues. #1436

Open
victor-ab opened this issue Jan 20, 2025 · 0 comments
Open

Issue: Function signature injection of config is causing issues. #1436

victor-ab opened this issue Jan 20, 2025 · 0 comments

Comments

@victor-ab
Copy link

Issue you'd like to raise.

How to replicate it:

from typing import Dict
from langsmith import traceable

from fastapi import FastAPI
from langsmith.middleware import TracingMiddleware

app = FastAPI()

app.add_middleware(TracingMiddleware)


@app.post("/health")
@traceable()
async def ping(input_string: str) -> Dict[str, str]:
    return {"pong": input_string}

Logs:

INFO:     127.0.0.1:32942 - "GET /openapi.json HTTP/1.1" 200 OK
Failed to get inputs for (input_string: str) -> Dict[str, str]: got an unexpected keyword argument 'config'

The issue is here in python/langsmith/run_helpers.py#L762:

        if not sig.parameters.get("config"):
            sig = sig.replace(
                parameters=[
                    *(
                        param
                        for param in sig.parameters.values()
                        if param.kind != inspect.Parameter.VAR_KEYWORD
                    ),
                    inspect.Parameter(
                        "config", inspect.Parameter.KEYWORD_ONLY, default=None
                    ),
                    *(
                        param
                        for param in sig.parameters.values()
                        if param.kind == inspect.Parameter.VAR_KEYWORD
                    ),
                ]
            )
            selected_wrapper.__signature__ = sig  # type: ignore[attr-defined]
        return selected_wrapper

Not sure how this is being used, but looking at the traces, it seems to be passing a None to it.

Suggestion:

No response

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