langchain-ai / langserve

LangServe 🦜️🏓
Other
1.75k stars 184 forks source link

Feedback token URL is always returned as None in invoke endpoint metadata #660

Closed mobiware closed 1 month ago

mobiware commented 1 month ago

We've been trying to use the Feedback Token feature but are consistently getting token_url equal to None in the metadata returned by the invoke endpoint:

'feedback_tokens': [{'key': 'feedback', 'token_url': None, 'expires_at': '2024-05-22T10:35:26.657572+00:00'}]

What is surprising is that expires_at is correctly set. Also calling directly langsmith_client.create_presigned_feedback_token() with a valid run_id does return a proper Token URL.

Upon review of the code, it looks like the problem comes from this line: https://github.com/langchain-ai/langserve/blob/bb74431183277e5a640e4c343f0a134525eb6eef/langserve/api_handler.py#L855

It creates a FeedbackToken object and sets the url on the url attribute, however when looking at that data structure definition it turns out that the URL is expected to be set on the token_url attribute:

class FeedbackToken(BaseModelV1):
    """Represents the feedback tokens for a given request."""

    key: str  # The key of the feedback token
    token_url: Optional[str] = None
    expires_at: Optional[datetime] = None
eyurtsev commented 1 month ago

addressed in 0.2.1 release