-
Notifications
You must be signed in to change notification settings - Fork 231
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
Nc/playground #19
Merged
Merged
Nc/playground #19
Changes from 60 commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
e5dd755
Add /playground endpoint that serves an playground UI with support fo…
nfcampos b315ed7
Update lock file
nfcampos 8c3aba7
Lint
nfcampos 7d4bcdc
Lint
nfcampos a150be3
Try to fix reload on error
nfcampos e3d2c5f
Fix types for schema
dqbd ae51653
Force every input to be multiline
dqbd 30a0f70
Remove unused asset
dqbd 44e8d7b
Move playground to langserve folder
dqbd 8c91429
Add makefile command
dqbd 5f1b9c8
Use 8000 for every example, resolve playground from every path
dqbd fd8cfc3
Rough draft of styles
dqbd d2b9570
Fix dark mode
dqbd 2d9e756
Add share button
dqbd ce9161d
Copy to clipboard, parse the contents
dqbd 85320dc
hide from schema
nfcampos 4b2c893
Lock
nfcampos eb0e97f
Lint
nfcampos 786b7e3
Update path and api docs
nfcampos 5b2ee13
Merge branch 'main' into nc/playground
nfcampos dfab212
Temporary change
dqbd e47494c
Further style changes
dqbd c0ade47
Update url, fix defaults
nfcampos 9b5fe14
Add built files
nfcampos bd88473
apply config in schemas endpoints
nfcampos 43a0de0
Replace icon, use share button
dqbd 0a8538c
Cleanup styles
dqbd 1bf88e8
Cleanup share
dqbd cc6484d
Add code snippets
dqbd fd01b78
Pointer events, use correct color
dqbd 73ff692
Hack the overdrag
dqbd 9d4d56a
Fix serving of non-text files
nfcampos 4208e5d
Add new built files
nfcampos acef4d7
Add iframe handling
dqbd dc23a3c
Add initial version of embeddable SDK
dqbd ee451b1
Handle value sync
dqbd c4e1a31
New build
dqbd a211178
New build
nfcampos 7225efe
Use input type
nfcampos 20f2f01
oops
nfcampos cc8d69e
Now in playground too
nfcampos 6210639
Do not apply defaults for input schema
nfcampos d37fce3
Add separator
dqbd 3df9fe8
Add better validation error styles
dqbd ca06ab2
Refresh check icon
dqbd bd5d8cd
Fix dark theme for errors, move validation stuff to the top-right
dqbd 144eb07
Version 0.0.10 bump (#50)
eyurtsev 05f11af
Update default to match langchain (#51)
nfcampos 24d96b7
Add CONTRIBUTING.md guidelines (#54)
eyurtsev 4878d83
Minor fix in contribution guidelines (#55)
eyurtsev a54d7df
Adds custom array and text controls
jacoblee93 37f4f3c
Update test case
jacoblee93 001c924
Cleanup styles
dqbd 063e10f
Resolve maximum call stack size exceeded for schemas with root $ref
nfcampos d800c10
Copy changes
nfcampos 33cf1f3
Resolve all refs before passing to jsonforms
nfcampos 020f4e7
Add json cell
nfcampos 14b9c5f
Lint
nfcampos 5ee72a5
Initial work on cleaning up styles
dqbd 20f0458
Fix dark mode for icons
dqbd 6ef8a25
Update built files
nfcampos 174f47f
Update built files
nfcampos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Contributing | ||
|
||
## Contributor License Agreement | ||
|
||
We are grateful to the contributors who help evolve LangServe and dedicate their time to the project. As the primary sponsor of LangServe, LangChain, Inc. aims to build products in the open that benefit thousands of developers while allowing us to build a sustainable business. For all code contributions to LangServe, we ask that contributors complete and sign a Contributor License Agreement (“CLA”). The agreement between contributors and the project is explicit, so LangServe users can be confident in the legal status of the source code and their right to use it.The CLA does not change the terms of the underlying license, LangServe License, used by our software. | ||
|
||
Before you can contribute to LangServe, a bot will comment on the PR asking you to agree to the CLA if you haven't already. Agreeing to the CLA is required before code can be merged and only needs to happen on the first contribution to the project. All subsequent contributions will fall under the same CLA. | ||
|
||
## 🗺️ Guidelines | ||
|
||
### Dependency Management: Poetry and other env/dependency managers | ||
|
||
This project uses [Poetry](https://python-poetry.org/) v1.6.1+ as a dependency manager. | ||
|
||
### Local Development Dependencies | ||
|
||
Install langserve development requirements (for running langchain, running examples, linting, formatting, tests, and coverage): | ||
|
||
```sh | ||
poetry install --with test,dev | ||
``` | ||
|
||
Then verify that tests pass: | ||
|
||
```sh | ||
make test | ||
``` | ||
|
||
### Formatting and Linting | ||
|
||
Run these locally before submitting a PR; the CI system will check also. | ||
|
||
#### Code Formatting | ||
|
||
Formatting for this project is done via a combination of [Black](https://black.readthedocs.io/en/stable/) and [ruff](https://docs.astral.sh/ruff/rules/). | ||
|
||
To run formatting for this project: | ||
|
||
```sh | ||
make format | ||
``` | ||
|
||
#### Linting | ||
|
||
Linting for this project is done via a combination of [Black](https://black.readthedocs.io/en/stable/), [ruff](https://docs.astral.sh/ruff/rules/), and [mypy](http://mypy-lang.org/). | ||
|
||
To run linting for this project: | ||
|
||
```sh | ||
make lint | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import json | ||
import mimetypes | ||
import os | ||
from string import Template | ||
from typing import List, Type | ||
|
||
from fastapi.responses import Response | ||
from langchain.schema.runnable import Runnable | ||
|
||
try: | ||
from pydantic.v1 import BaseModel | ||
except ImportError: | ||
from pydantic import BaseModel | ||
|
||
|
||
class PlaygroundTemplate(Template): | ||
delimiter = "____" | ||
|
||
|
||
async def serve_playground( | ||
runnable: Runnable, | ||
input_schema: Type[BaseModel], | ||
config_keys: List[str], | ||
base_url: str, | ||
file_path: str, | ||
) -> Response: | ||
local_file_path = os.path.join( | ||
os.path.dirname(__file__), | ||
"./playground/dist", | ||
file_path or "index.html", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is file path configurable to prototype with different variations of the UX? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is file path an input? |
||
) | ||
with open(local_file_path) as f: | ||
mime_type = mimetypes.guess_type(local_file_path)[0] | ||
if mime_type in ("text/html", "text/css", "application/javascript"): | ||
res = PlaygroundTemplate(f.read()).substitute( | ||
LANGSERVE_BASE_URL=base_url[1:] | ||
if base_url.startswith("/") | ||
else base_url, | ||
LANGSERVE_CONFIG_SCHEMA=json.dumps( | ||
runnable.config_schema(include=config_keys).schema() | ||
), | ||
LANGSERVE_INPUT_SCHEMA=json.dumps(input_schema.schema()), | ||
) | ||
else: | ||
res = f.buffer.read() | ||
|
||
return Response(res, media_type=mime_type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:react-hooks/recommended', | ||
], | ||
ignorePatterns: ['dist', '.eslintrc.cjs'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['react-refresh'], | ||
rules: { | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
.yarn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# React + TypeScript + Vite | ||
|
||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
|
||
Currently, two official plugins are available: | ||
|
||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh | ||
|
||
## Expanding the ESLint configuration | ||
|
||
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: | ||
|
||
- Configure the top-level `parserOptions` property like this: | ||
|
||
```js | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
project: ['./tsconfig.json', './tsconfig.node.json'], | ||
tsconfigRootDir: __dirname, | ||
}, | ||
``` | ||
|
||
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` | ||
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` | ||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an issue atm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah it's fine didn't notice the custom input type