Compare commits

..

8 Commits

Author SHA1 Message Date
Eugene Yurtsev d66567dd1f x 2024-02-28 13:32:31 -05:00
Eugene Yurtsev 65d814aa51 x 2024-02-28 13:32:19 -05:00
Eugene Yurtsev c2bae658d2 chmod +x 2024-02-28 13:13:24 -05:00
jacoblee93 803c587131 Add CORS note 2024-02-28 01:17:09 -08:00
jacoblee93 5b21b056df Support string outputs as well as message chunks 2024-02-28 01:03:31 -08:00
jacoblee93 59f26055e0 Lint 2024-02-28 00:38:42 -08:00
jacoblee93 24d804c073 Merge branch 'main' of https://github.com/langchain-ai/langserve into jacob/chat_widget 2024-02-28 00:38:01 -08:00
jacoblee93 31ad97b9e0 Adds chat widget for message list inputs, additional global callback for chunks 2024-02-28 00:33:14 -08:00
11 changed files with 62 additions and 114 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
{
"contributors": ["eyurtsev", "hwchase17", "nfcampos", "efriis", "jacoblee93", "dqbd", "kreneskyp", "adarsh-jha-dev", "harris", "baskaryan", "hinthornw", "bracesproul", "jakerachleff", "craigsdennis", "anhi", "169", "LarchLiu", "PaulLockett", "RCMatthias", "jwynia", "majiayu000", "mpskex", "shivachittamuru", "sinashaloudegi", "sowsan", "akira", "lucianotonet", "JGalego", "nat-n", "dirien"],
"contributors": ["eyurtsev", "hwchase17", "nfcampos", "efriis", "jacoblee93", "dqbd", "kreneskyp", "adarsh-jha-dev", "harris", "baskaryan", "hinthornw", "bracesproul", "jakerachleff", "craigsdennis", "anhi", "169", "LarchLiu", "PaulLockett", "RCMatthias", "jwynia", "majiayu000", "mpskex", "shivachittamuru", "sinashaloudegi", "sowsan", "akira", "lucianotonet", "JGalego", "nat-n"],
"message": "Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the username {{usersWithoutCLA}} on file. In order for us to review and merge your code, please complete the Individual Contributor License Agreement here https://forms.gle/AQFbtkWRoHXUgipM6 .\n\nThis process is done manually on our side, so after signing the form one of the maintainers will add you to the contributors list.\n\nFor more details about why we have a CLA and other contribution guidelines please see: https://github.com/langchain-ai/langserve/blob/main/CONTRIBUTING.md."
}
-3
View File
@@ -160,6 +160,3 @@ cython_debug/
#.idea/
.envrc
# IntelliJ IDE's
.idea
-21
View File
@@ -372,27 +372,6 @@ You can deploy to GCP Cloud Run using the following command:
gcloud run deploy [your-service-name] --source . --port 8001 --allow-unauthenticated --region us-central1 --set-env-vars=OPENAI_API_KEY=your_key
```
### Deploy using Infrastructure as Code
#### Pulumi
You can deploy your LangServe server with [Pulumi](https://www.pulumi.com/) using your preferred general purpose language. Below are some quickstart
examples for deploying LangServe to different cloud providers.
These examples are a good starting point for your own infrastructure as code (IaC) projects. You can easily modify them to suit your needs.
| Cloud | Language | Repository | Quickstart |
|-------|------------|-----------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| AWS | dotnet | https://github.com/pulumi/examples/aws-cs-langserve | [![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new?template=https://github.com/pulumi/examples/aws-cs-langserve) |
| AWS | golang | https://github.com/pulumi/examples/aws-go-langserve | [![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new?template=https://github.com/pulumi/examples/aws-go-langserve) |
| AWS | python | https://github.com/pulumi/examples/aws-py-langserve | [![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new?template=https://github.com/pulumi/examples/aws-py-langserve) |
| AWS | typescript | https://github.com/pulumi/examples/aws-ts-langserve | [![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new?template=https://github.com/pulumi/examples/aws-ts-langserve) |
| AWS | javascript | https://github.com/pulumi/examples/aws-js-langserve | [![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new?template=https://github.com/pulumi/examples/aws-js-langserve) |
### Community Contributed
#### Deploy to Railway
+2 -6
View File
@@ -1366,9 +1366,7 @@ class APIHandler:
raise HTTPException(
400,
"The feedback endpoint is only accessible when LangSmith is "
+ "enabled on your LangServe server."
+ "Please set `enable_feedback_endpoint=True` on your route and "
+ "set the proper environment variables",
+ "enabled on your LangServe server.",
)
feedback_from_langsmith = self._langsmith_client.create_feedback(
@@ -1406,9 +1404,7 @@ class APIHandler:
raise HTTPException(
400,
"The feedback endpoint is only accessible when LangSmith is "
+ "enabled on your LangServe server."
+ "Please set `enable_feedback_endpoint=True` on your route and "
+ "set the proper environment variables",
+ "enabled on your LangServe server.",
)
async def check_feedback_enabled(self) -> bool:
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -5,7 +5,7 @@
<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-dbc96538.js"></script>
<script type="module" crossorigin src="/____LANGSERVE_BASE_URL/assets/index-a7c0cdaa.js"></script>
<link rel="stylesheet" href="/____LANGSERVE_BASE_URL/assets/index-52e8ab2f.css">
</head>
<body>
@@ -49,47 +49,32 @@ export const ChatMessageTuplesControlRenderer = withJsonFormsControlProps(
(props) => {
const data: Array<MessageTuple> = props.data ?? [];
useStreamCallback("onChunk", (_chunk, aggregatedState) => {
useStreamCallback("onSuccess", (ctx) => {
if (!isJsonSchemaExtra(props.schema)) return;
const widget = props.schema.extra.widget;
if (!("input" in widget) && !("output" in widget)) return;
const inputPath = getNormalizedJsonPath(widget.input ?? "");
const outputPath = getNormalizedJsonPath(widget.output ?? "");
const isSingleOutputKey =
aggregatedState?.final_output != null &&
Object.keys(aggregatedState?.final_output).length === 1 &&
Object.keys(aggregatedState?.final_output)[0] === "output";
ctx.output != null &&
Object.keys(ctx.output).length === 1 &&
Object.keys(ctx.output)[0] === "output";
let ai = traverseNaiveJsonPath(aggregatedState?.final_output, outputPath);
const human = traverseNaiveJsonPath(ctx.input, inputPath);
let ai = traverseNaiveJsonPath(ctx.output, outputPath);
if (isSingleOutputKey) {
ai = traverseNaiveJsonPath(ai, ["output", ...outputPath]) ?? ai;
}
ai = getMessageContent(ai);
if (typeof ai === "string") {
props.handleChange(props.path, [...data.slice(0, -1), [data[data.length - 1][0], ai]]);
if (typeof human === "string" && typeof ai === "string") {
props.handleChange(props.path, [...data, [human, ai]]);
}
});
useStreamCallback("onStart", (ctx) => {
if (!isJsonSchemaExtra(props.schema)) return;
const widget = props.schema.extra.widget;
if (!("input" in widget) && !("output" in widget)) return;
const inputPath = getNormalizedJsonPath(widget.input ?? "");
const human = traverseNaiveJsonPath(ctx.input, inputPath);
if (typeof human === "string") {
props.handleChange(props.path, [...data, [human, ""]]);
}
});
useStreamCallback("onError", () => {
props.handleChange(props.path, [...data.slice(0, -1)]);
});
return (
<div className="control">
<div className="flex items-center justify-between">
@@ -101,12 +101,6 @@ export const ChatMessagesControlRenderer = withJsonFormsControlProps(
props.handleChange(props.path, [...data, { content: "", type: "human" }]);
});
useStreamCallback("onError", () => {
if (data.length && data[data.length - 1].type === "ai") {
props.handleChange(props.path, [...data.slice(0, -1)]);
}
});
return (
<div className="control">
<div className="flex items-center justify-between">
View File
+1 -4
View File
@@ -668,16 +668,13 @@ def add_routes(
if endpoint_configuration.is_playground_enabled:
playground = app.get(
namespace + "/playground/{file_path:path}",
dependencies=dependencies,
include_in_schema=False,
namespace + "/playground/{file_path:path}", dependencies=dependencies
)(api_handler.playground)
if endpoint_configuration.is_config_hash_enabled:
app.get(
namespace + "/c/{config_hash}/playground/{file_path:path}",
dependencies=dependencies,
include_in_schema=False,
)(playground)
if enable_feedback_endpoint:
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langserve"
version = "0.0.47"
version = "0.0.43"
description = ""
readme = "README.md"
authors = ["LangChain"]