Skip to content

Commit

Permalink
Add feedback buttons to stream_log runs (#203)
Browse files Browse the repository at this point in the history
https://github.com/langchain-ai/langserve/assets/1443449/9e5f7dae-6759-4018-b0f6-1701912eb25e



TODO: 
- [x] We need to expose the ability to get and remove a specific run
based off an ID, otherwise multiple clicking will send multiple
feedbacks
- [x] Hide buttons if LangSmith not configured or feedback endpoint not
exposed

---------

Co-authored-by: Eugene Yurtsev <[email protected]>
  • Loading branch information
dqbd and eyurtsev authored Nov 28, 2023
1 parent 04a950e commit a51a6c0
Show file tree
Hide file tree
Showing 17 changed files with 251 additions and 78 deletions.
2 changes: 1 addition & 1 deletion examples/conversational_retrieval_chain/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class ChatHistory(BaseModel):
# /invoke
# /batch
# /stream
add_routes(app, chain)
add_routes(app, chain, enable_feedback_endpoint=True)

if __name__ == "__main__":
import uvicorn
Expand Down
4 changes: 4 additions & 0 deletions langserve/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ async def serve_playground(
config_keys: Sequence[str],
base_url: str,
file_path: str,
feedback_enabled: bool,
) -> Response:
"""Serve the playground."""
local_file_path = os.path.abspath(
Expand Down Expand Up @@ -82,6 +83,9 @@ async def serve_playground(
runnable.config_schema(include=config_keys).schema()
),
LANGSERVE_INPUT_SCHEMA=json.dumps(input_schema.schema()),
LANGSERVE_FEEDBACK_ENABLED=json.dumps(
"true" if feedback_enabled else "false"
),
)
else:
response = f.buffer.read()
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions langserve/playground/dist/assets/index-52e8ab2f.css

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion langserve/playground/dist/assets/index-8968db79.css

This file was deleted.

5 changes: 3 additions & 2 deletions langserve/playground/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
<link rel="icon" href="/____LANGSERVE_BASE_URL/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Playground</title>
<script type="module" crossorigin src="/____LANGSERVE_BASE_URL/assets/index-65de8f9b.js"></script>
<link rel="stylesheet" href="/____LANGSERVE_BASE_URL/assets/index-8968db79.css">
<script type="module" crossorigin src="/____LANGSERVE_BASE_URL/assets/index-1ccbfbf6.js"></script>
<link rel="stylesheet" href="/____LANGSERVE_BASE_URL/assets/index-52e8ab2f.css">
</head>
<body>
<div id="root"></div>
<script>
try {
window.CONFIG_SCHEMA = ____LANGSERVE_CONFIG_SCHEMA;
window.INPUT_SCHEMA = ____LANGSERVE_INPUT_SCHEMA;
window.FEEDBACK_ENABLED = ____LANGSERVE_FEEDBACK_ENABLED;
} catch (error) {
// pass
}
Expand Down
1 change: 1 addition & 0 deletions langserve/playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
try {
window.CONFIG_SCHEMA = ____LANGSERVE_CONFIG_SCHEMA;
window.INPUT_SCHEMA = ____LANGSERVE_INPUT_SCHEMA;
window.FEEDBACK_ENABLED = ____LANGSERVE_FEEDBACK_ENABLED;
} catch (error) {
// pass
}
Expand Down
Loading

0 comments on commit a51a6c0

Please sign in to comment.