mirror of https://github.com/hwchase17/langchain
parent
e130680d74
commit
221134d239
@ -1,18 +0,0 @@
|
||||
# Contributing
|
||||
|
||||
To add a new project:
|
||||
|
||||
Make sure you have `langchain-cli` installed.
|
||||
|
||||
```shell
|
||||
pip install -U langchain-cli
|
||||
```
|
||||
|
||||
Create a new package
|
||||
|
||||
```shell
|
||||
langchain hub new $PROJECT_NAME
|
||||
```
|
||||
|
||||
This will set up the skeleton of a package.
|
||||
You can then edit the contents of the package as you desire.
|
@ -0,0 +1,43 @@
|
||||
# Contributing
|
||||
|
||||
Thanks for taking the time to contribute a new template!
|
||||
We've tried to make this process as simple and painless as possible.
|
||||
If you need any help at all, please reach out!
|
||||
|
||||
To contribute a new template, first fork this repository.
|
||||
Then clone that fork and pull it down locally.
|
||||
Set up an appropriate dev environment, and make sure you are in this `template` directory.
|
||||
|
||||
Make sure you have `langchain-cli` installed.
|
||||
|
||||
```shell
|
||||
pip install -U "langchain-cli[serve]"
|
||||
```
|
||||
|
||||
You can then run the following command to create a new skeleton of a package.
|
||||
By convention, package names should use `-` delimeters (not `_`).
|
||||
|
||||
```shell
|
||||
langchain hub new $PROJECT_NAME
|
||||
```
|
||||
|
||||
You can then edit the contents of the package as you desire.
|
||||
Note that by default we expect the main chain to be exposed as `chain` in the `__init__.py` file of the package.
|
||||
You can change this (either the name or the location), but if you do so it is important to update the `tool.langchain`
|
||||
part of `pyproject.toml`.
|
||||
For example, if you update the main chain exposed to be called `agent_executor`, then that section should look like:
|
||||
|
||||
```text
|
||||
[tool.langserve]
|
||||
export_module = "..."
|
||||
export_attr = "agent_executor"
|
||||
```
|
||||
|
||||
Make sure to add any requirements of the package to `pyproject.toml` (and to remove any that are not used).
|
||||
|
||||
Please update the `README.md` file to give some background on your package and how to set it up.
|
||||
|
||||
If you want to change the license of your template for whatever, you may! Note that by default it is MIT licensed.
|
||||
|
||||
If you want to test out your package at any point in time, you can spin up a LangServe instance directly from the package.
|
||||
See instructions [here](LAUNCHING_PACKAGE.md) on how to best do that.
|
@ -0,0 +1,41 @@
|
||||
# Launching LangServe from a Package
|
||||
|
||||
You can also launch LangServe directly from a package, without having to pull it into a project.
|
||||
This can be useful when you are developing a package and want to test it quickly.
|
||||
The downside of this is that it gives you a little less control over how the LangServe APIs are configured,
|
||||
which is why for proper projects we recommend creating a full project.
|
||||
|
||||
In order to do this, first change your working directory to the package itself.
|
||||
For example, if you are currently in this `templates` module, you can go into the `pirate-speak` package with:
|
||||
|
||||
```shell
|
||||
cd pirate-speak
|
||||
```
|
||||
|
||||
Inside this package there is a `pyproject.toml` file.
|
||||
This file contains a `tool.langchain` section that contains information on how this package should be used.
|
||||
For example, in `pirate-speak` we see:
|
||||
|
||||
```text
|
||||
[tool.langserve]
|
||||
export_module = "pirate_speak.chain"
|
||||
export_attr = "chain"
|
||||
```
|
||||
|
||||
This information can be used to launch a LangServe instance automatically.
|
||||
In order to do this, first make sure the CLI is installed:
|
||||
|
||||
```shell
|
||||
pip install -U "langchain-cli[serve]"
|
||||
```
|
||||
|
||||
You can then run:
|
||||
|
||||
```shell
|
||||
langchain hub start
|
||||
```
|
||||
|
||||
This will spin up endpoints, documentation, and playground for this chain.
|
||||
For example, you can access the playground at [http://127.0.0.1:8000/playground/](http://127.0.0.1:8000/playground/)
|
||||
|
||||
![playground.png](playground.png)
|
Binary file not shown.
After Width: | Height: | Size: 200 KiB |
Binary file not shown.
After Width: | Height: | Size: 130 KiB |
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 LangChain, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -0,0 +1,9 @@
|
||||
# pirate-speak
|
||||
|
||||
This simple application converts user input into pirate speak
|
||||
|
||||
## LLM
|
||||
|
||||
This template will use `OpenAI` by default.
|
||||
|
||||
Be sure that `OPENAI_API_KEY` is set in your environment.
|
@ -0,0 +1,17 @@
|
||||
from langchain.chat_models import ChatOpenAI
|
||||
from langchain.prompts import ChatPromptTemplate
|
||||
|
||||
_prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
(
|
||||
"system",
|
||||
"Translate user input into pirate speak",
|
||||
),
|
||||
("human", "{text}"),
|
||||
]
|
||||
)
|
||||
_model = ChatOpenAI()
|
||||
|
||||
# if you update this, you MUST also update ../pyproject.toml
|
||||
# with the new `tool.langserve.export_attr`
|
||||
chain = _prompt | _model
|
@ -0,0 +1,24 @@
|
||||
[tool.poetry]
|
||||
name = "pirate_speak"
|
||||
version = "0.0.1"
|
||||
description = ""
|
||||
authors = []
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.8.1,<4.0"
|
||||
langchain = ">=0.0.313, <0.1"
|
||||
openai = "^0.28.1"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
langchain-cli = ">=0.0.4"
|
||||
fastapi = "^0.104.0"
|
||||
sse-starlette = "^1.6.5"
|
||||
|
||||
[tool.langserve]
|
||||
export_module = "pirate_speak.chain"
|
||||
export_attr = "chain"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
Loading…
Reference in New Issue