mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-06 15:48:39 +00:00
templates,docs: leave templates in v0.2 (#27952)
all template installs will now have to declare `--branch v0.2` to make clear they aren't compatible with langchain 0.3 (most have a pydantic v1 setup). e.g. ``` langchain-cli app add pirate-speak --branch v0.2 ```
This commit is contained in:
parent
8807e6986c
commit
a073c4c498
.github
Makefiledocs
libs/cli
templates
.gitignoreMakefileREADME.md
anthropic-iterative-search
basic-critique-revise
bedrock-jcvd
cassandra-entomology-rag
cassandra-synonym-caching
chain-of-note-wiki
chat-bot-feedback
cohere-librarian
csv-agent
docs
elastic-query-generator
extraction-anthropic-functions
LICENSEREADME.mdextraction_anthropic_functions.ipynb
extraction_anthropic_functions
pyproject.tomltests
extraction-openai-functions
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,7 +1,7 @@
|
||||
Thank you for contributing to LangChain!
|
||||
|
||||
- [ ] **PR title**: "package: description"
|
||||
- Where "package" is whichever of langchain, community, core, etc. is being modified. Use "docs: ..." for purely docs changes, "templates: ..." for template changes, "infra: ..." for CI changes.
|
||||
- Where "package" is whichever of langchain, community, core, etc. is being modified. Use "docs: ..." for purely docs changes, "infra: ..." for CI changes.
|
||||
- Example: "community: add foobar LLM"
|
||||
|
||||
|
||||
|
2
.github/scripts/check_diff.py
vendored
2
.github/scripts/check_diff.py
vendored
@ -307,7 +307,7 @@ if __name__ == "__main__":
|
||||
f"Unknown lib: {file}. check_diff.py likely needs "
|
||||
"an update for this new library!"
|
||||
)
|
||||
elif any(file.startswith(p) for p in ["docs/", "templates/", "cookbook/"]):
|
||||
elif any(file.startswith(p) for p in ["docs/", "cookbook/"]):
|
||||
if file.startswith("docs/"):
|
||||
docs_edited = True
|
||||
dirs_to_run["lint"].add(".")
|
||||
|
12
Makefile
12
Makefile
@ -66,12 +66,12 @@ spell_fix:
|
||||
|
||||
## lint: Run linting on the project.
|
||||
lint lint_package lint_tests:
|
||||
poetry run ruff check docs templates cookbook
|
||||
poetry run ruff format docs templates cookbook --diff
|
||||
poetry run ruff check --select I docs templates cookbook
|
||||
git grep 'from langchain import' docs/docs templates cookbook | grep -vE 'from langchain import (hub)' && exit 1 || exit 0
|
||||
poetry run ruff check docs cookbook
|
||||
poetry run ruff format docs cookbook cookbook --diff
|
||||
poetry run ruff check --select I docs cookbook
|
||||
git grep 'from langchain import' docs/docs cookbook | grep -vE 'from langchain import (hub)' && exit 1 || exit 0
|
||||
|
||||
## format: Format the project files.
|
||||
format format_diff:
|
||||
poetry run ruff format docs templates cookbook
|
||||
poetry run ruff check --select I --fix docs templates cookbook
|
||||
poetry run ruff format docs cookbook
|
||||
poetry run ruff check --select I --fix docs cookbook
|
||||
|
@ -406,7 +406,9 @@ def _format_api_ref_url(doc_path: str, compact: bool = False) -> str:
|
||||
|
||||
|
||||
def _format_template_url(template_name: str) -> str:
|
||||
return f"https://{LANGCHAIN_PYTHON_URL}/docs/templates/{template_name}"
|
||||
return (
|
||||
f"https://github.com/langchain-ai/langchain/blob/v0.2/templates/{template_name}"
|
||||
)
|
||||
|
||||
|
||||
def _format_cookbook_url(cookbook_name: str) -> str:
|
||||
|
@ -76,7 +76,7 @@
|
||||
},
|
||||
{
|
||||
"source": "/v0.2/docs/templates/:path(.*/?)*",
|
||||
"destination": "https://github.com/langchain-ai/langchain/tree/master/templates/:path*"
|
||||
"destination": "https://github.com/langchain-ai/langchain/tree/v0.2/templates/:path*"
|
||||
},
|
||||
{
|
||||
"source": "/docs/integrations/providers/mlflow_ai_gateway(/?)",
|
||||
|
@ -4,5 +4,3 @@ This package implements the official CLI for LangChain. Right now, it is most us
|
||||
for getting started with LangChain Templates!
|
||||
|
||||
[CLI Docs](https://github.com/langchain-ai/langchain/blob/master/libs/cli/DOCS.md)
|
||||
|
||||
[LangServe Templates Quickstart](https://github.com/langchain-ai/langchain/blob/master/templates/README.md)
|
||||
|
2
templates/.gitignore
vendored
2
templates/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
__pycache__
|
||||
.ruff_cache
|
@ -1,8 +0,0 @@
|
||||
lint lint_diff lint_package lint_tests:
|
||||
poetry run poe lint
|
||||
|
||||
test:
|
||||
poetry run poe test
|
||||
|
||||
format:
|
||||
poetry run poe format
|
@ -1,137 +0,0 @@
|
||||
# LangChain Templates
|
||||
|
||||
LangChain Templates are the easiest and fastest way to build a production-ready LLM application.
|
||||
These templates serve as a set of reference architectures for a wide variety of popular LLM use cases.
|
||||
They are all in a standard format which make it easy to deploy them with [LangServe](https://github.com/langchain-ai/langserve).
|
||||
|
||||
🚩 We will be releasing a hosted version of LangServe for one-click deployments of LangChain applications. [Sign up here](https://airtable.com/app0hN6sd93QcKubv/shrAjst60xXa6quV2) to get on the waitlist.
|
||||
|
||||
## Quick Start
|
||||
|
||||
To use, first install the LangChain CLI.
|
||||
|
||||
```shell
|
||||
pip install -U langchain-cli
|
||||
```
|
||||
|
||||
Next, create a new LangChain project:
|
||||
|
||||
```shell
|
||||
langchain app new my-app
|
||||
```
|
||||
|
||||
This will create a new directory called `my-app` with two folders:
|
||||
|
||||
- `app`: This is where LangServe code will live
|
||||
- `packages`: This is where your chains or agents will live
|
||||
|
||||
To pull in an existing template as a package, you first need to go into your new project:
|
||||
|
||||
```shell
|
||||
cd my-app
|
||||
```
|
||||
|
||||
And you can the add a template as a project.
|
||||
In this getting started guide, we will add a simple `pirate-speak` project.
|
||||
All this project does is convert user input into pirate speak.
|
||||
|
||||
```shell
|
||||
langchain app add pirate-speak
|
||||
```
|
||||
|
||||
This will pull in the specified template into `packages/pirate-speak`
|
||||
|
||||
You will then be prompted if you want to install it.
|
||||
This is the equivalent of running `pip install -e packages/pirate-speak`.
|
||||
You should generally accept this (or run that same command afterwards).
|
||||
We install it with `-e` so that if you modify the template at all (which you likely will) the changes are updated.
|
||||
|
||||
After that, it will ask you if you want to generate route code for this project.
|
||||
This is code you need to add to your app to start using this chain.
|
||||
If we accept, we will see the following code generated:
|
||||
|
||||
```shell
|
||||
from pirate_speak.chain import chain as pirate_speak_chain
|
||||
|
||||
add_routes(app, pirate_speak_chain, path="/pirate-speak")
|
||||
```
|
||||
|
||||
You can now edit the template you pulled down.
|
||||
You can change the code files in `packages/pirate-speak` to use a different model, different prompt, different logic.
|
||||
Note that the above code snippet always expects the final chain to be importable as `from pirate_speak.chain import chain`,
|
||||
so you should either keep the structure of the package similar enough to respect that or be prepared to update that code snippet.
|
||||
|
||||
Once you have done as much of that as you want, it is
|
||||
In order to have LangServe use this project, you then need to modify `app/server.py`.
|
||||
Specifically, you should add the above code snippet to `app/server.py` so that file looks like:
|
||||
|
||||
```python
|
||||
from fastapi import FastAPI
|
||||
from langserve import add_routes
|
||||
from pirate_speak.chain import chain as pirate_speak_chain
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
add_routes(app, pirate_speak_chain, path="/pirate-speak")
|
||||
```
|
||||
|
||||
(Optional) Let's now configure LangSmith.
|
||||
LangSmith will help us trace, monitor and debug LangChain applications.
|
||||
You can sign up for LangSmith [here](https://smith.langchain.com/).
|
||||
If you don't have access, you can skip this section
|
||||
|
||||
|
||||
```shell
|
||||
export LANGCHAIN_TRACING_V2=true
|
||||
export LANGCHAIN_API_KEY=<your-api-key>
|
||||
export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
|
||||
```
|
||||
|
||||
For this particular application, we will use OpenAI as the LLM, so we need to export our OpenAI API key:
|
||||
|
||||
```shell
|
||||
export OPENAI_API_KEY=sk-...
|
||||
```
|
||||
|
||||
You can then spin up production-ready endpoints, along with a playground, by running:
|
||||
|
||||
```shell
|
||||
langchain serve
|
||||
```
|
||||
|
||||
This now gives a fully deployed LangServe application.
|
||||
For example, you get a playground out-of-the-box at [http://127.0.0.1:8000/pirate-speak/playground/](http://127.0.0.1:8000/pirate-speak/playground/):
|
||||
|
||||
 "LangServe Playground Interface"
|
||||
|
||||
Access API documentation at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
|
||||
|
||||
 "API Documentation Interface"
|
||||
|
||||
Use the LangServe python or js SDK to interact with the API as if it were a regular [Runnable](https://python.langchain.com/docs/expression_language/).
|
||||
|
||||
```python
|
||||
from langserve import RemoteRunnable
|
||||
|
||||
api = RemoteRunnable("http://127.0.0.1:8000/pirate-speak")
|
||||
api.invoke({"text": "hi"})
|
||||
```
|
||||
|
||||
That's it for the quick start!
|
||||
You have successfully downloaded your first template and deployed it with LangServe.
|
||||
|
||||
|
||||
## Additional Resources
|
||||
|
||||
### [Index of Templates](docs/INDEX.md)
|
||||
|
||||
Explore the many templates available to use - from advanced RAG to agents.
|
||||
|
||||
### [Contributing](docs/CONTRIBUTING.md)
|
||||
|
||||
Want to contribute your own template? It's pretty easy! These instructions walk through how to do that.
|
||||
|
||||
### [Launching LangServe from a Package](docs/LAUNCHING_PACKAGE.md)
|
||||
|
||||
You can also launch LangServe from a package directly (without having to create a new project).
|
||||
These instructions cover how to do that.
|
@ -1,68 +0,0 @@
|
||||
# Anthropic - iterative search
|
||||
|
||||
This template will create a virtual research assistant with the ability to search Wikipedia to find answers to your questions.
|
||||
|
||||
It is heavily inspired by [this notebook](https://github.com/anthropics/anthropic-cookbook/blob/main/long_context/wikipedia-search-cookbook.ipynb).
|
||||
|
||||
## Environment Setup
|
||||
|
||||
Set the `ANTHROPIC_API_KEY` environment variable to access the Anthropic models.
|
||||
|
||||
## Usage
|
||||
|
||||
To use this package, you should first have the LangChain CLI installed:
|
||||
|
||||
```shell
|
||||
pip install -U langchain-cli
|
||||
```
|
||||
|
||||
To create a new LangChain project and install this as the only package, you can do:
|
||||
|
||||
```shell
|
||||
langchain app new my-app --package anthropic-iterative-search
|
||||
```
|
||||
|
||||
If you want to add this to an existing project, you can just run:
|
||||
|
||||
```shell
|
||||
langchain app add anthropic-iterative-search
|
||||
```
|
||||
|
||||
And add the following code to your `server.py` file:
|
||||
```python
|
||||
from anthropic_iterative_search import chain as anthropic_iterative_search_chain
|
||||
|
||||
add_routes(app, anthropic_iterative_search_chain, path="/anthropic-iterative-search")
|
||||
```
|
||||
|
||||
(Optional) Let's now configure LangSmith.
|
||||
LangSmith will help us trace, monitor and debug LangChain applications.
|
||||
You can sign up for LangSmith [here](https://smith.langchain.com/).
|
||||
If you don't have access, you can skip this section
|
||||
|
||||
|
||||
```shell
|
||||
export LANGCHAIN_TRACING_V2=true
|
||||
export LANGCHAIN_API_KEY=<your-api-key>
|
||||
export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
|
||||
```
|
||||
|
||||
If you are inside this directory, then you can spin up a LangServe instance directly by:
|
||||
|
||||
```shell
|
||||
langchain serve
|
||||
```
|
||||
|
||||
This will start the FastAPI app with a server is running locally at
|
||||
[http://localhost:8000](http://localhost:8000)
|
||||
|
||||
We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
|
||||
We can access the playground at [http://127.0.0.1:8000/anthropic-iterative-search/playground](http://127.0.0.1:8000/anthropic-iterative-search/playground)
|
||||
|
||||
We can access the template from code with:
|
||||
|
||||
```python
|
||||
from langserve.client import RemoteRunnable
|
||||
|
||||
runnable = RemoteRunnable("http://localhost:8000/anthropic-iterative-search")
|
||||
```
|
@ -1,3 +0,0 @@
|
||||
from .chain import chain
|
||||
|
||||
__all__ = ["chain"]
|
@ -1,16 +0,0 @@
|
||||
def _format_docs(docs):
|
||||
result = "\n".join(
|
||||
[
|
||||
f'<item index="{i+1}">\n<page_content>\n{r}\n</page_content>\n</item>'
|
||||
for i, r in enumerate(docs)
|
||||
]
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
def format_agent_scratchpad(intermediate_steps):
|
||||
thoughts = ""
|
||||
for action, observation in intermediate_steps:
|
||||
thoughts += action.log
|
||||
thoughts += "</search_query>" + _format_docs(observation)
|
||||
return thoughts
|
@ -1,37 +0,0 @@
|
||||
from langchain_anthropic import ChatAnthropic
|
||||
from langchain_core.output_parsers import StrOutputParser
|
||||
from langchain_core.prompts import ChatPromptTemplate
|
||||
from langchain_core.pydantic_v1 import BaseModel
|
||||
from langchain_core.runnables import ConfigurableField
|
||||
|
||||
from .prompts import answer_prompt
|
||||
from .retriever_agent import executor
|
||||
|
||||
prompt = ChatPromptTemplate.from_template(answer_prompt)
|
||||
|
||||
model = ChatAnthropic(
|
||||
model="claude-3-sonnet-20240229", temperature=0, max_tokens_to_sample=1000
|
||||
)
|
||||
|
||||
chain = (
|
||||
{"query": lambda x: x["query"], "information": executor | (lambda x: x["output"])}
|
||||
| prompt
|
||||
| model
|
||||
| StrOutputParser()
|
||||
)
|
||||
|
||||
# Add typing for the inputs to be used in the playground
|
||||
|
||||
|
||||
class Inputs(BaseModel):
|
||||
query: str
|
||||
|
||||
|
||||
chain = chain.with_types(input_type=Inputs)
|
||||
|
||||
chain = chain.configurable_alternatives(
|
||||
ConfigurableField(id="chain"),
|
||||
default_key="response",
|
||||
# This adds a new option, with name `openai` that is equal to `ChatOpenAI()`
|
||||
retrieve=executor,
|
||||
)
|
@ -1,37 +0,0 @@
|
||||
import re
|
||||
|
||||
from langchain_core.agents import AgentAction, AgentFinish
|
||||
|
||||
from .agent_scratchpad import _format_docs
|
||||
|
||||
|
||||
def extract_between_tags(tag: str, string: str, strip: bool = True) -> str:
|
||||
ext_list = re.findall(f"<{tag}\s?>(.+?)</{tag}\s?>", string, re.DOTALL)
|
||||
if strip:
|
||||
ext_list = [e.strip() for e in ext_list]
|
||||
if ext_list:
|
||||
if len(ext_list) != 1:
|
||||
raise ValueError
|
||||
# Only return the first one
|
||||
return ext_list[0]
|
||||
|
||||
|
||||
def parse_output(outputs):
|
||||
partial_completion = outputs["partial_completion"]
|
||||
steps = outputs["intermediate_steps"]
|
||||
search_query = extract_between_tags(
|
||||
"search_query", partial_completion + "</search_query>"
|
||||
)
|
||||
if search_query is None:
|
||||
docs = []
|
||||
str_output = ""
|
||||
for action, observation in steps:
|
||||
docs.extend(observation)
|
||||
str_output += action.log
|
||||
str_output += "</search_query>" + _format_docs(observation)
|
||||
str_output += partial_completion
|
||||
return AgentFinish({"docs": docs, "output": str_output}, log=partial_completion)
|
||||
else:
|
||||
return AgentAction(
|
||||
tool="search", tool_input=search_query, log=partial_completion
|
||||
)
|
@ -1,7 +0,0 @@
|
||||
retrieval_prompt = """{retriever_description} Before beginning to research the user's question, first think for a moment inside <scratchpad> tags about what information is necessary for a well-informed answer. If the user's question is complex, you may need to decompose the query into multiple subqueries and execute them individually. Sometimes the search engine will return empty search results, or the search results may not contain the information you need. In such cases, feel free to try again with a different query.
|
||||
|
||||
After each call to the Search Engine Tool, reflect briefly inside <search_quality></search_quality> tags about whether you now have enough information to answer, or whether more information is needed. If you have all the relevant information, write it in <information></information> tags, WITHOUT actually answering the question. Otherwise, issue a new search.
|
||||
|
||||
Here is the user's question: <question>{query}</question> Remind yourself to make short queries in your scratchpad as you plan out your strategy.""" # noqa: E501
|
||||
|
||||
answer_prompt = "Here is a user query: <query>{query}</query>. Here is some relevant information: <information>{information}</information>. Please answer the question using the relevant information." # noqa: E501
|
@ -1,17 +0,0 @@
|
||||
from langchain.retrievers import WikipediaRetriever
|
||||
from langchain.tools import tool
|
||||
|
||||
# This is used to tell the model how to best use the retriever.
|
||||
|
||||
retriever_description = """You will be asked a question by a human user. You have access to the following tool to help answer the question. <tool_description> Search Engine Tool * The search engine will exclusively search over Wikipedia for pages similar to your query. It returns for each page its title and full page content. Use this tool if you want to get up-to-date and comprehensive information on a topic to help answer queries. Queries should be as atomic as possible -- they only need to address one part of the user's question. For example, if the user's query is "what is the color of a basketball?", your search query should be "basketball". Here's another example: if the user's question is "Who created the first neural network?", your first query should be "neural network". As you can see, these queries are quite short. Think keywords, not phrases. * At any time, you can make a call to the search engine using the following syntax: <search_query>query_word</search_query>. * You'll then get results back in <search_result> tags.</tool_description>""" # noqa: E501
|
||||
|
||||
retriever = WikipediaRetriever()
|
||||
|
||||
# This should be the same as the function name below
|
||||
RETRIEVER_TOOL_NAME = "search"
|
||||
|
||||
|
||||
@tool
|
||||
def search(query):
|
||||
"""Search with the retriever."""
|
||||
return retriever.invoke(query)
|
@ -1,43 +0,0 @@
|
||||
from langchain.agents import AgentExecutor
|
||||
from langchain_anthropic import ChatAnthropic
|
||||
from langchain_core.output_parsers import StrOutputParser
|
||||
from langchain_core.prompts import ChatPromptTemplate
|
||||
from langchain_core.runnables import RunnableParallel, RunnablePassthrough
|
||||
|
||||
from .agent_scratchpad import format_agent_scratchpad
|
||||
from .output_parser import parse_output
|
||||
from .prompts import retrieval_prompt
|
||||
from .retriever import retriever_description, search
|
||||
|
||||
prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
("user", retrieval_prompt),
|
||||
("ai", "{agent_scratchpad}"),
|
||||
]
|
||||
)
|
||||
prompt = prompt.partial(retriever_description=retriever_description)
|
||||
|
||||
model = ChatAnthropic(
|
||||
model="claude-3-sonnet-20240229", temperature=0, max_tokens_to_sample=1000
|
||||
)
|
||||
|
||||
chain = (
|
||||
RunnablePassthrough.assign(
|
||||
agent_scratchpad=lambda x: format_agent_scratchpad(x["intermediate_steps"])
|
||||
)
|
||||
| prompt
|
||||
| model.bind(stop_sequences=["</search_query>"])
|
||||
| StrOutputParser()
|
||||
)
|
||||
|
||||
agent_chain = (
|
||||
RunnableParallel(
|
||||
{
|
||||
"partial_completion": chain,
|
||||
"intermediate_steps": lambda x: x["intermediate_steps"],
|
||||
}
|
||||
)
|
||||
| parse_output
|
||||
)
|
||||
|
||||
executor = AgentExecutor(agent=agent_chain, tools=[search], verbose=True)
|
@ -1,12 +0,0 @@
|
||||
from anthropic_iterative_search import final_chain
|
||||
|
||||
if __name__ == "__main__":
|
||||
query = (
|
||||
"Which movie came out first: Oppenheimer, or "
|
||||
"Are You There God It's Me Margaret?"
|
||||
)
|
||||
print(
|
||||
final_chain.with_config(configurable={"chain": "retrieve"}).invoke(
|
||||
{"query": query}
|
||||
)
|
||||
)
|
@ -1,29 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "anthropic-iterative-search"
|
||||
version = "0.0.1"
|
||||
description = "A virtual research assistant with the ability to search Wikipedia and answer questions"
|
||||
authors = []
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.8.1,<4.0"
|
||||
langchain = "^0.1"
|
||||
wikipedia = "^1.4.0"
|
||||
langchain-anthropic = "^0.1.4"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
langchain-cli = ">=0.0.21"
|
||||
|
||||
[tool.langserve]
|
||||
export_module = "anthropic_iterative_search"
|
||||
export_attr = "chain"
|
||||
|
||||
[tool.templates-hub]
|
||||
use-case = "research"
|
||||
author = "LangChain"
|
||||
integrations = ["Anthropic", "Wikipedia"]
|
||||
tags = ["research", "agents"]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
@ -1,21 +0,0 @@
|
||||
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.
|
@ -1,66 +0,0 @@
|
||||
# Basic critique revise
|
||||
|
||||
Iteratively generate schema candidates and revise them based on errors.
|
||||
|
||||
## Environment Setup
|
||||
|
||||
This template uses `OpenAI function calling`, so you will need to set the `OPENAI_API_KEY` environment variable in order to use this template.
|
||||
|
||||
## Usage
|
||||
|
||||
To use this package, you should first have the LangChain CLI installed:
|
||||
|
||||
```shell
|
||||
pip install -U "langchain-cli[serve]"
|
||||
```
|
||||
|
||||
To create a new LangChain project and install this as the only package, you can do:
|
||||
|
||||
```shell
|
||||
langchain app new my-app --package basic-critique-revise
|
||||
```
|
||||
|
||||
If you want to add this to an existing project, you can just run:
|
||||
|
||||
```shell
|
||||
langchain app add basic-critique-revise
|
||||
```
|
||||
|
||||
And add the following code to your `server.py` file:
|
||||
```python
|
||||
from basic_critique_revise import chain as basic_critique_revise_chain
|
||||
|
||||
add_routes(app, basic_critique_revise_chain, path="/basic-critique-revise")
|
||||
```
|
||||
|
||||
(Optional) Let's now configure LangSmith.
|
||||
LangSmith will help us trace, monitor and debug LangChain applications.
|
||||
You can sign up for LangSmith [here](https://smith.langchain.com/).
|
||||
If you don't have access, you can skip this section
|
||||
|
||||
|
||||
```shell
|
||||
export LANGCHAIN_TRACING_V2=true
|
||||
export LANGCHAIN_API_KEY=<your-api-key>
|
||||
export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
|
||||
```
|
||||
|
||||
If you are inside this directory, then you can spin up a LangServe instance directly by:
|
||||
|
||||
```shell
|
||||
langchain serve
|
||||
```
|
||||
|
||||
This will start the FastAPI app with a server is running locally at
|
||||
[http://localhost:8000](http://localhost:8000)
|
||||
|
||||
We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
|
||||
We can access the playground at [http://127.0.0.1:8000/basic-critique-revise/playground](http://127.0.0.1:8000/basic-critique-revise/playground)
|
||||
|
||||
We can access the template from code with:
|
||||
|
||||
```python
|
||||
from langserve.client import RemoteRunnable
|
||||
|
||||
runnable = RemoteRunnable("http://localhost:8000/basic-critique-revise")
|
||||
```
|
@ -1,3 +0,0 @@
|
||||
from basic_critique_revise.chain import chain
|
||||
|
||||
__all__ = ["chain"]
|
@ -1,143 +0,0 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from operator import itemgetter
|
||||
from typing import Any, Dict, Sequence
|
||||
|
||||
from langchain.chains.openai_functions import convert_to_openai_function
|
||||
from langchain_community.chat_models import ChatOpenAI
|
||||
from langchain_core.prompts import ChatPromptTemplate
|
||||
from langchain_core.pydantic_v1 import BaseModel, Field, ValidationError, conint
|
||||
from langchain_core.runnables import (
|
||||
Runnable,
|
||||
RunnableBranch,
|
||||
RunnableLambda,
|
||||
RunnablePassthrough,
|
||||
)
|
||||
|
||||
|
||||
class TaskType(str, Enum):
|
||||
call = "Call"
|
||||
message = "Message"
|
||||
todo = "Todo"
|
||||
in_person_meeting = "In-Person Meeting"
|
||||
email = "Email"
|
||||
mail = "Mail"
|
||||
text = "Text"
|
||||
open_house = "Open House"
|
||||
|
||||
|
||||
class Task(BaseModel):
|
||||
title: str = Field(..., description="The title of the tasks, reminders and alerts")
|
||||
due_date: datetime = Field(
|
||||
..., description="Due date. Must be a valid ISO date string with timezone"
|
||||
)
|
||||
task_type: TaskType = Field(None, description="The type of task")
|
||||
|
||||
|
||||
class Tasks(BaseModel):
|
||||
"""JSON definition for creating tasks, reminders and alerts"""
|
||||
|
||||
tasks: Sequence[Task]
|
||||
|
||||
|
||||
template = """Respond to the following user query to the best of your ability:
|
||||
|
||||
{query}"""
|
||||
|
||||
generate_prompt = ChatPromptTemplate.from_template(template)
|
||||
|
||||
function_args = {"functions": [convert_to_openai_function(Tasks)]}
|
||||
|
||||
task_function_call_model = ChatOpenAI(model="gpt-3.5-turbo").bind(**function_args)
|
||||
|
||||
output_parser = RunnableLambda(
|
||||
lambda x: json.loads(
|
||||
x.additional_kwargs.get("function_call", {}).get("arguments", '""')
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
revise_template = """
|
||||
Based on the provided context, fix the incorrect result of the original prompt
|
||||
and the provided errors. Only respond with an answer that satisfies the
|
||||
constraints laid out in the original prompt and fixes the Pydantic errors.
|
||||
|
||||
Hint: Datetime fields must be valid ISO date strings.
|
||||
|
||||
<context>
|
||||
<original_prompt>
|
||||
{original_prompt}
|
||||
</original_prompt>
|
||||
<incorrect_result>
|
||||
{completion}
|
||||
</incorrect_result>
|
||||
<errors>
|
||||
{error}
|
||||
</errors>
|
||||
</context>"""
|
||||
|
||||
revise_prompt = ChatPromptTemplate.from_template(revise_template)
|
||||
|
||||
revise_chain = revise_prompt | task_function_call_model | output_parser
|
||||
|
||||
|
||||
def output_validator(output):
|
||||
try:
|
||||
Tasks.validate(output["completion"])
|
||||
except ValidationError as e:
|
||||
return str(e)
|
||||
|
||||
return None
|
||||
|
||||
|
||||
class IntermediateType(BaseModel):
|
||||
error: str
|
||||
completion: Dict
|
||||
original_prompt: str
|
||||
max_revisions: int
|
||||
|
||||
|
||||
validation_step = RunnablePassthrough().assign(error=RunnableLambda(output_validator))
|
||||
|
||||
|
||||
def revise_loop(input: IntermediateType) -> IntermediateType:
|
||||
revise_step = RunnablePassthrough().assign(completion=revise_chain)
|
||||
|
||||
else_step: Runnable[IntermediateType, IntermediateType] = RunnableBranch(
|
||||
(lambda x: x["error"] is None, RunnablePassthrough()),
|
||||
revise_step | validation_step,
|
||||
).with_types(input_type=IntermediateType)
|
||||
|
||||
for _ in range(max(0, input["max_revisions"] - 1)):
|
||||
else_step = RunnableBranch(
|
||||
(lambda x: x["error"] is None, RunnablePassthrough()),
|
||||
revise_step | validation_step | else_step,
|
||||
)
|
||||
return else_step
|
||||
|
||||
|
||||
revise_lambda = RunnableLambda(revise_loop)
|
||||
|
||||
|
||||
class InputType(BaseModel):
|
||||
query: str
|
||||
max_revisions: conint(ge=1, le=10) = 5
|
||||
|
||||
|
||||
chain: Runnable[Any, Any] = (
|
||||
{
|
||||
"original_prompt": generate_prompt,
|
||||
"max_revisions": itemgetter("max_revisions"),
|
||||
}
|
||||
| RunnablePassthrough().assign(
|
||||
completion=(
|
||||
RunnableLambda(itemgetter("original_prompt"))
|
||||
| task_function_call_model
|
||||
| output_parser
|
||||
)
|
||||
)
|
||||
| validation_step
|
||||
| revise_lambda
|
||||
| RunnableLambda(itemgetter("completion"))
|
||||
).with_types(input_type=InputType)
|
@ -1,30 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "basic_critique_revise"
|
||||
version = "0.0.1"
|
||||
description = "Iteratively generate schema candidates and revise based on errors"
|
||||
authors = []
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.8.1,<4.0"
|
||||
langchain = "^0.1"
|
||||
openai = "<2"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
langchain-cli = ">=0.0.21"
|
||||
fastapi = ">=0.104.0,<1"
|
||||
sse-starlette = "^1.6.5"
|
||||
|
||||
[tool.langserve]
|
||||
export_module = "basic_critique_revise"
|
||||
export_attr = "chain"
|
||||
|
||||
[tool.templates-hub]
|
||||
use-case = "research"
|
||||
author = "LangChain"
|
||||
integrations = ["OpenAI", "Function Calling", "Pydantic"]
|
||||
tags = ["research", "function-calling"]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
@ -1,82 +0,0 @@
|
||||
# Bedrock - JCVD 🕺🥋
|
||||
|
||||
## Overview
|
||||
|
||||
LangChain template that uses [Anthropic's Claude on Amazon Bedrock](https://aws.amazon.com/bedrock/claude/)
|
||||
to behave like `Jean-Claude Van Damme` (`JCVD`).
|
||||
|
||||
> I am the Fred Astaire of Chatbots! 🕺
|
||||
|
||||
 "Jean-Claude Van Damme Dancing"
|
||||
|
||||
## Environment Setup
|
||||
|
||||
### AWS Credentials
|
||||
|
||||
This template uses [Boto3](https://boto3.amazonaws.com/v1/documentation/api/latest/index.html), the AWS SDK for Python, to call [Amazon Bedrock](https://aws.amazon.com/bedrock/). You **must** configure both AWS credentials *and* an AWS Region in order to make requests.
|
||||
|
||||
> For information on how to do this, see [AWS Boto3 documentation](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html) (Developer Guide > Credentials).
|
||||
|
||||
### Foundation Models
|
||||
|
||||
By default, this template uses [Anthropic's Claude v2](https://aws.amazon.com/about-aws/whats-new/2023/08/claude-2-foundation-model-anthropic-amazon-bedrock/) (`anthropic.claude-v2`).
|
||||
|
||||
> To request access to a specific model, check out the [Amazon Bedrock User Guide](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html) (Model access)
|
||||
|
||||
To use a different model, set the environment variable `BEDROCK_JCVD_MODEL_ID`. A list of base models is available in the [Amazon Bedrock User Guide](https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids-arns.html) (Use the API > API operations > Run inference > Base Model IDs).
|
||||
|
||||
> The full list of available models (including base and [custom models](https://docs.aws.amazon.com/bedrock/latest/userguide/custom-models.html)) is available in the [Amazon Bedrock Console](https://docs.aws.amazon.com/bedrock/latest/userguide/using-console.html) under **Foundation Models** or by calling [`aws bedrock list-foundation-models`](https://docs.aws.amazon.com/cli/latest/reference/bedrock/list-foundation-models.html).
|
||||
|
||||
## Usage
|
||||
|
||||
To use this package, you should first have the LangChain CLI installed:
|
||||
|
||||
```shell
|
||||
pip install -U langchain-cli
|
||||
```
|
||||
|
||||
To create a new LangChain project and install this as the only package, you can do:
|
||||
|
||||
```shell
|
||||
langchain app new my-app --package bedrock-jcvd
|
||||
```
|
||||
|
||||
If you want to add this to an existing project, you can just run:
|
||||
|
||||
```shell
|
||||
langchain app add bedrock-jcvd
|
||||
```
|
||||
|
||||
And add the following code to your `server.py` file:
|
||||
```python
|
||||
from bedrock_jcvd import chain as bedrock_jcvd_chain
|
||||
|
||||
add_routes(app, bedrock_jcvd_chain, path="/bedrock-jcvd")
|
||||
```
|
||||
|
||||
(Optional) Let's now configure LangSmith.
|
||||
LangSmith will help us trace, monitor and debug LangChain applications.
|
||||
You can sign up for LangSmith [here](https://smith.langchain.com/).
|
||||
If you don't have access, you can skip this section
|
||||
|
||||
|
||||
```shell
|
||||
export LANGCHAIN_TRACING_V2=true
|
||||
export LANGCHAIN_API_KEY=<your-api-key>
|
||||
export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
|
||||
```
|
||||
|
||||
If you are inside this directory, then you can spin up a LangServe instance directly by:
|
||||
|
||||
```shell
|
||||
langchain serve
|
||||
```
|
||||
|
||||
This will start the FastAPI app with a server is running locally at
|
||||
[http://localhost:8000](http://localhost:8000)
|
||||
|
||||
We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs).
|
||||
|
||||
We can also access the playground at [http://127.0.0.1:8000/bedrock-jcvd/playground](http://127.0.0.1:8000/bedrock-jcvd/playground)
|
||||
|
||||
 "JCVD Playground"
|
@ -1,47 +0,0 @@
|
||||
import os
|
||||
|
||||
from langchain_aws import ChatBedrock
|
||||
from langchain_core.prompts import ChatPromptTemplate
|
||||
from langchain_core.runnables import ConfigurableField
|
||||
|
||||
# For a description of each inference parameter, see
|
||||
# https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-claude.html
|
||||
_model_kwargs = {
|
||||
"temperature": float(os.getenv("BEDROCK_JCVD_TEMPERATURE", "0.1")),
|
||||
"top_p": float(os.getenv("BEDROCK_JCVD_TOP_P", "1")),
|
||||
"top_k": int(os.getenv("BEDROCK_JCVD_TOP_K", "250")),
|
||||
"max_tokens_to_sample": int(os.getenv("BEDROCK_JCVD_MAX_TOKENS_TO_SAMPLE", "300")),
|
||||
}
|
||||
|
||||
# Full list of base model IDs is available at
|
||||
# https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids-arns.html
|
||||
_model_alts = {
|
||||
"claude_2_1": ChatBedrock(
|
||||
model_id="anthropic.claude-v2:1", model_kwargs=_model_kwargs
|
||||
),
|
||||
"claude_1": ChatBedrock(model_id="anthropic.claude-v1", model_kwargs=_model_kwargs),
|
||||
"claude_instant_1": ChatBedrock(
|
||||
model_id="anthropic.claude-instant-v1", model_kwargs=_model_kwargs
|
||||
),
|
||||
}
|
||||
|
||||
# For some tips on how to construct effective prompts for Claude,
|
||||
# check out Anthropic's Claude Prompt Engineering deck (Bedrock edition)
|
||||
# https://docs.google.com/presentation/d/1tjvAebcEyR8la3EmVwvjC7PHR8gfSrcsGKfTPAaManw
|
||||
_prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
("human", "You are JCVD. {input}"),
|
||||
]
|
||||
)
|
||||
|
||||
_model = ChatBedrock(
|
||||
model_id="anthropic.claude-v2", model_kwargs=_model_kwargs
|
||||
).configurable_alternatives(
|
||||
which=ConfigurableField(
|
||||
id="model", name="Model", description="The model that will be used"
|
||||
),
|
||||
default_key="claude_2",
|
||||
**_model_alts,
|
||||
)
|
||||
|
||||
chain = _prompt | _model
|
Binary file not shown.
Before ![]() (image error) Size: 31 KiB |
@ -1,31 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "bedrock-jcvd"
|
||||
version = "0.1.0"
|
||||
description = "LangChain template that behaves like JCVD using Anthropic's Claude on Amazon Bedrock"
|
||||
authors = ["JGalego <jgalego1990@gmail.com>"]
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.11"
|
||||
uvicorn = "^0.23.2"
|
||||
langserve = {extras = ["server"], version = ">=0.0.30"}
|
||||
pydantic = "<2"
|
||||
boto3 = "^1.33.10"
|
||||
langchain = "^0.1"
|
||||
|
||||
[tool.langserve]
|
||||
export_module = "bedrock_jcvd.chain"
|
||||
export_attr = "chain"
|
||||
|
||||
[tool.templates-hub]
|
||||
use-case = "chatbot"
|
||||
author = "LangChain"
|
||||
integrations = ["AWS"]
|
||||
tags = ["conversation"]
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
langchain-cli = ">=0.0.21"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
@ -1,13 +0,0 @@
|
||||
export OPENAI_API_KEY="..."
|
||||
|
||||
export ASTRA_DB_APPLICATION_TOKEN="AstraCS:..."
|
||||
export ASTRA_DB_KEYSPACE="..."
|
||||
export ASTRA_DB_ID="12345678-"
|
||||
|
||||
# UNCOMMENT THE FOLLOWING FOR A CASSANDRA CLUSTER ...
|
||||
# export USE_CASSANDRA_CLUSTER="1"
|
||||
# ... then provide these parameters as well:
|
||||
# export CASSANDRA_KEYSPACE="..."
|
||||
# export CASSANDRA_CONTACT_POINTS="127.0.0.1" # optional
|
||||
# export CASSANDRA_USERNAME="cassandra" # optional
|
||||
# export CASSANDRA_PASSWORD="cassandra" # optional
|
@ -1,78 +0,0 @@
|
||||
# Cassandra - Entomology RAG
|
||||
|
||||
This template will perform RAG using `Apache Cassandra®` or `Astra DB`
|
||||
through `CQL` (`Cassandra` vector store class)
|
||||
|
||||
## Environment Setup
|
||||
|
||||
For the setup, you will require:
|
||||
- an [Astra](https://astra.datastax.com) Vector Database. You must have a [Database Administrator token](https://awesome-astra.github.io/docs/pages/astra/create-token/#c-procedure), specifically the string starting with `AstraCS:...`.
|
||||
- [Database ID](https://awesome-astra.github.io/docs/pages/astra/faq/#where-should-i-find-a-database-identifier).
|
||||
- an **OpenAI API Key**. (More info [here](https://cassio.org/start_here/#llm-access))
|
||||
|
||||
You may also use a regular Cassandra cluster. In this case, provide the `USE_CASSANDRA_CLUSTER` entry as shown in `.env.template` and the subsequent environment variables to specify how to connect to it.
|
||||
|
||||
The connection parameters and secrets must be provided through environment variables. Refer to `.env.template` for the required variables.
|
||||
|
||||
## Usage
|
||||
|
||||
To use this package, you should first have the LangChain CLI installed:
|
||||
|
||||
```shell
|
||||
pip install -U langchain-cli
|
||||
```
|
||||
|
||||
To create a new LangChain project and install this as the only package, you can do:
|
||||
|
||||
```shell
|
||||
langchain app new my-app --package cassandra-entomology-rag
|
||||
```
|
||||
|
||||
If you want to add this to an existing project, you can just run:
|
||||
|
||||
```shell
|
||||
langchain app add cassandra-entomology-rag
|
||||
```
|
||||
|
||||
And add the following code to your `server.py` file:
|
||||
```python
|
||||
from cassandra_entomology_rag import chain as cassandra_entomology_rag_chain
|
||||
|
||||
add_routes(app, cassandra_entomology_rag_chain, path="/cassandra-entomology-rag")
|
||||
```
|
||||
|
||||
(Optional) Let's now configure LangSmith.
|
||||
LangSmith will help us trace, monitor and debug LangChain applications.
|
||||
You can sign up for LangSmith [here](https://smith.langchain.com/).
|
||||
If you don't have access, you can skip this section
|
||||
|
||||
|
||||
```shell
|
||||
export LANGCHAIN_TRACING_V2=true
|
||||
export LANGCHAIN_API_KEY=<your-api-key>
|
||||
export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
|
||||
```
|
||||
|
||||
If you are inside this directory, then you can spin up a LangServe instance directly by:
|
||||
|
||||
```shell
|
||||
langchain serve
|
||||
```
|
||||
|
||||
This will start the FastAPI app with a server is running locally at
|
||||
[http://localhost:8000](http://localhost:8000)
|
||||
|
||||
We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
|
||||
We can access the playground at [http://127.0.0.1:8000/cassandra-entomology-rag/playground](http://127.0.0.1:8000/cassandra-entomology-rag/playground)
|
||||
|
||||
We can access the template from code with:
|
||||
|
||||
```python
|
||||
from langserve.client import RemoteRunnable
|
||||
|
||||
runnable = RemoteRunnable("http://localhost:8000/cassandra-entomology-rag")
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
Stand-alone repo with LangServe chain: [here](https://github.com/hemidactylus/langserve_cassandra_entomology_rag).
|
@ -1,69 +0,0 @@
|
||||
import os
|
||||
|
||||
import cassio
|
||||
from langchain_community.chat_models import ChatOpenAI
|
||||
from langchain_community.embeddings import OpenAIEmbeddings
|
||||
from langchain_community.vectorstores import Cassandra
|
||||
from langchain_core.output_parsers import StrOutputParser
|
||||
from langchain_core.prompts import ChatPromptTemplate
|
||||
from langchain_core.runnables import RunnablePassthrough
|
||||
|
||||
from .populate_vector_store import populate
|
||||
|
||||
use_cassandra = int(os.environ.get("USE_CASSANDRA_CLUSTER", "0"))
|
||||
if use_cassandra:
|
||||
from .cassandra_cluster_init import get_cassandra_connection
|
||||
|
||||
session, keyspace = get_cassandra_connection()
|
||||
cassio.init(
|
||||
session=session,
|
||||
keyspace=keyspace,
|
||||
)
|
||||
else:
|
||||
cassio.init(
|
||||
token=os.environ["ASTRA_DB_APPLICATION_TOKEN"],
|
||||
database_id=os.environ["ASTRA_DB_ID"],
|
||||
keyspace=os.environ.get("ASTRA_DB_KEYSPACE"),
|
||||
)
|
||||
|
||||
|
||||
# inits
|
||||
llm = ChatOpenAI()
|
||||
embeddings = OpenAIEmbeddings()
|
||||
vector_store = Cassandra(
|
||||
session=None,
|
||||
keyspace=None,
|
||||
embedding=embeddings,
|
||||
table_name="langserve_rag_demo",
|
||||
)
|
||||
retriever = vector_store.as_retriever(search_kwargs={"k": 3})
|
||||
|
||||
# For demo reasons, let's ensure there are rows on the vector store.
|
||||
# Please remove this and/or adapt to your use case!
|
||||
inserted_lines = populate(vector_store)
|
||||
if inserted_lines:
|
||||
print(f"Done ({inserted_lines} lines inserted).")
|
||||
|
||||
entomology_template = """
|
||||
You are an expert entomologist, tasked with answering enthusiast biologists' questions.
|
||||
You must answer based only on the provided context, do not make up any fact.
|
||||
Your answers must be concise and to the point, but strive to provide scientific details
|
||||
(such as family, order, Latin names, and so on when appropriate).
|
||||
You MUST refuse to answer questions on other topics than entomology,
|
||||
as well as questions whose answer is not found in the provided context.
|
||||
|
||||
CONTEXT:
|
||||
{context}
|
||||
|
||||
QUESTION: {question}
|
||||
|
||||
YOUR ANSWER:"""
|
||||
|
||||
entomology_prompt = ChatPromptTemplate.from_template(entomology_template)
|
||||
|
||||
chain = (
|
||||
{"context": retriever, "question": RunnablePassthrough()}
|
||||
| entomology_prompt
|
||||
| llm
|
||||
| StrOutputParser()
|
||||
)
|
@ -1,29 +0,0 @@
|
||||
import os
|
||||
|
||||
from cassandra.auth import PlainTextAuthProvider
|
||||
from cassandra.cluster import Cluster
|
||||
|
||||
|
||||
def get_cassandra_connection():
|
||||
contact_points = [
|
||||
cp.strip()
|
||||
for cp in os.environ.get("CASSANDRA_CONTACT_POINTS", "").split(",")
|
||||
if cp.strip()
|
||||
]
|
||||
CASSANDRA_KEYSPACE = os.environ["CASSANDRA_KEYSPACE"]
|
||||
CASSANDRA_USERNAME = os.environ.get("CASSANDRA_USERNAME")
|
||||
CASSANDRA_PASSWORD = os.environ.get("CASSANDRA_PASSWORD")
|
||||
#
|
||||
if CASSANDRA_USERNAME and CASSANDRA_PASSWORD:
|
||||
auth_provider = PlainTextAuthProvider(
|
||||
CASSANDRA_USERNAME,
|
||||
CASSANDRA_PASSWORD,
|
||||
)
|
||||
else:
|
||||
auth_provider = None
|
||||
|
||||
c_cluster = Cluster(
|
||||
contact_points if contact_points else None, auth_provider=auth_provider
|
||||
)
|
||||
session = c_cluster.connect()
|
||||
return (session, CASSANDRA_KEYSPACE)
|
@ -1,29 +0,0 @@
|
||||
import os
|
||||
|
||||
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
|
||||
def populate(vector_store):
|
||||
# is the store empty? find out with a probe search
|
||||
hits = vector_store.similarity_search_by_vector(
|
||||
embedding=[0.001] * 1536,
|
||||
k=1,
|
||||
)
|
||||
#
|
||||
if len(hits) == 0:
|
||||
# this seems a first run:
|
||||
# must populate the vector store
|
||||
src_file_name = os.path.join(BASE_DIR, "..", "sources.txt")
|
||||
lines = [
|
||||
line.strip()
|
||||
for line in open(src_file_name).readlines()
|
||||
if line.strip()
|
||||
if line[0] != "#"
|
||||
]
|
||||
# deterministic IDs to prevent duplicates on multiple runs
|
||||
ids = ["_".join(line.split(" ")[:2]).lower().replace(":", "") for line in lines]
|
||||
#
|
||||
vector_store.add_texts(texts=lines, ids=ids)
|
||||
return len(lines)
|
||||
else:
|
||||
return 0
|
@ -1,34 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "cassandra-entomology-rag"
|
||||
version = "0.0.1"
|
||||
description = "RAG using Apache Cassandra® or Astra DB"
|
||||
authors = [
|
||||
"Stefano Lottini <stefano.lottini@datastax.com>",
|
||||
]
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.8.1,<4.0"
|
||||
langchain = "^0.1"
|
||||
openai = "<2"
|
||||
tiktoken = "^0.5.1"
|
||||
cassio = "^0.1.3"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
langchain-cli = ">=0.0.21"
|
||||
|
||||
[tool.langserve]
|
||||
export_module = "cassandra_entomology_rag"
|
||||
export_attr = "chain"
|
||||
|
||||
[tool.templates-hub]
|
||||
use-case = "rag"
|
||||
author = "DataStax"
|
||||
integrations = ["OpenAI", "Cassandra"]
|
||||
tags = ["vectordbs"]
|
||||
|
||||
[build-system]
|
||||
requires = [
|
||||
"poetry-core",
|
||||
]
|
||||
build-backend = "poetry.core.masonry.api"
|
@ -1,31 +0,0 @@
|
||||
# source: https://www.thoughtco.com/a-guide-to-the-twenty-nine-insect-orders-1968419
|
||||
|
||||
Order Thysanura: The silverfish and firebrats are found in the order Thysanura. They are wingless insects often found in people's attics, and have a lifespan of several years. There are about 600 species worldwide.
|
||||
Order Diplura: Diplurans are the most primitive insect species, with no eyes or wings. They have the unusual ability among insects to regenerate body parts. There are over 400 members of the order Diplura in the world.
|
||||
Order Protura: Another very primitive group, the proturans have no eyes, no antennae, and no wings. They are uncommon, with perhaps less than 100 species known.
|
||||
Order Collembola: The order Collembola includes the springtails, primitive insects without wings. There are approximately 2,000 species of Collembola worldwide.
|
||||
Order Ephemeroptera: The mayflies of order Ephemeroptera are short-lived, and undergo incomplete metamorphosis. The larvae are aquatic, feeding on algae and other plant life. Entomologists have described about 2,100 species worldwide.
|
||||
Order Odonata: The order Odonata includes dragonflies and damselflies, which undergo incomplete metamorphosis. They are predators of other insects, even in their immature stage. There are about 5,000 species in the order Odonata.
|
||||
Order Plecoptera: The stoneflies of order Plecoptera are aquatic and undergo incomplete metamorphosis. The nymphs live under rocks in well flowing streams. Adults are usually seen on the ground along stream and river banks. There are roughly 3,000 species in this group.
|
||||
Order Grylloblatodea: Sometimes referred to as "living fossils," the insects of the order Grylloblatodea have changed little from their ancient ancestors. This order is the smallest of all the insect orders, with perhaps only 25 known species living today. Grylloblatodea live at elevations above 1500 ft., and are commonly named ice bugs or rock crawlers.
|
||||
Order Orthoptera: These are familiar insects (grasshoppers, locusts, katydids, and crickets) and one of the largest orders of herbivorous insects. Many species in the order Orthoptera can produce and detect sounds. Approximately 20,000 species exist in this group.
|
||||
Order Phasmida: The order Phasmida are masters of camouflage, the stick and leaf insects. They undergo incomplete metamorphosis and feed on leaves. There are some 3,000 insects in this group, but only a small fraction of this number is leaf insects. Stick insects are the longest insects in the world.
|
||||
Order Dermaptera: This order contains the earwigs, an easily recognized insect that often has pincers at the end of the abdomen. Many earwigs are scavengers, eating both plant and animal matter. The order Dermaptera includes less than 2,000 species.
|
||||
Order Embiidina: The order Embioptera is another ancient order with few species, perhaps only 200 worldwide. The web spinners have silk glands in their front legs and weave nests under leaf litter and in tunnels where they live. Webspinners live in tropical or subtropical climates.
|
||||
Order Dictyoptera: The order Dictyoptera includes roaches and mantids. Both groups have long, segmented antennae and leathery forewings held tightly against their backs. They undergo incomplete metamorphosis. Worldwide, there approximately 6,000 species in this order, most living in tropical regions.
|
||||
Order Isoptera: Termites feed on wood and are important decomposers in forest ecosystems. They also feed on wood products and are thought of as pests for the destruction they cause to man-made structures. There are between 2,000 and 3,000 species in this order.
|
||||
Order Zoraptera: Little is know about the angel insects, which belong to the order Zoraptera. Though they are grouped with winged insects, many are actually wingless. Members of this group are blind, small, and often found in decaying wood. There are only about 30 described species worldwide.
|
||||
Order Psocoptera: Bark lice forage on algae, lichen, and fungus in moist, dark places. Booklice frequent human dwellings, where they feed on book paste and grains. They undergo incomplete metamorphosis. Entomologists have named about 3,200 species in the order Psocoptera.
|
||||
Order Mallophaga: Biting lice are ectoparasites that feed on birds and some mammals. There are an estimated 3,000 species in the order Mallophaga, all of which undergo incomplete metamorphosis.
|
||||
Order Siphunculata: The order Siphunculata are the sucking lice, which feed on the fresh blood of mammals. Their mouthparts are adapted for sucking or siphoning blood. There are only about 500 species of sucking lice.
|
||||
Order Hemiptera: Most people use the term "bugs" to mean insects; an entomologist uses the term to refer to the order Hemiptera. The Hemiptera are the true bugs, and include cicadas, aphids, and spittlebugs, and others. This is a large group of over 70,000 species worldwide.
|
||||
Order Thysanoptera: The thrips of order Thysanoptera are small insects that feed on plant tissue. Many are considered agricultural pests for this reason. Some thrips prey on other small insects as well. This order contains about 5,000 species.
|
||||
Order Neuroptera: Commonly called the order of lacewings, this group actually includes a variety of other insects, too: dobsonflies, owlflies, mantidflies, antlions, snakeflies, and alderflies. Insects in the order Neuroptera undergo complete metamorphosis. Worldwide, there are over 5,500 species in this group.
|
||||
Order Mecoptera: This order includes the scorpionflies, which live in moist, wooded habitats. Scorpionflies are omnivorous in both their larval and adult forms. The larva are caterpillar-like. There are less than 500 described species in the order Mecoptera.
|
||||
Order Siphonaptera: Pet lovers fear insects in the order Siphonaptera - the fleas. Fleas are blood-sucking ectoparasites that feed on mammals, and rarely, birds. There are well over 2,000 species of fleas in the world.
|
||||
Order Coleoptera: This group, the beetles and weevils, is the largest order in the insect world, with over 300,000 distinct species known. The order Coleoptera includes well-known families: june beetles, lady beetles, click beetles, and fireflies. All have hardened forewings that fold over the abdomen to protect the delicate hindwings used for flight.
|
||||
Order Strepsiptera: Insects in this group are parasites of other insects, particularly bees, grasshoppers, and the true bugs. The immature Strepsiptera lies in wait on a flower and quickly burrows into any host insect that comes along. Strepsiptera undergo complete metamorphosis and pupate within the host insect's body.
|
||||
Order Diptera: Diptera is one of the largest orders, with nearly 100,000 insects named to the order. These are the true flies, mosquitoes, and gnats. Insects in this group have modified hindwings which are used for balance during flight. The forewings function as the propellers for flying.
|
||||
Order Lepidoptera: The butterflies and moths of the order Lepidoptera comprise the second largest group in the class Insecta. These well-known insects have scaly wings with interesting colors and patterns. You can often identify an insect in this order just by the wing shape and color.
|
||||
Order Trichoptera: Caddisflies are nocturnal as adults and aquatic when immature. The caddisfly adults have silky hairs on their wings and body, which is key to identifying a Trichoptera member. The larvae spin traps for prey with silk. They also make cases from the silk and other materials that they carry and use for protection.
|
||||
Order Hymenoptera: The order Hymenoptera includes many of the most common insects - ants, bees, and wasps. The larvae of some wasps cause trees to form galls, which then provides food for the immature wasps. Other wasps are parasitic, living in caterpillars, beetles, or even aphids. This is the third-largest insect order with just over 100,000 species.
|
@ -1,13 +0,0 @@
|
||||
export OPENAI_API_KEY="..."
|
||||
|
||||
export ASTRA_DB_APPLICATION_TOKEN="AstraCS:..."
|
||||
export ASTRA_DB_KEYSPACE="..."
|
||||
export ASTRA_DB_ID="12345678-"
|
||||
|
||||
# UNCOMMENT THE FOLLOWING FOR A CASSANDRA CLUSTER ...
|
||||
# export USE_CASSANDRA_CLUSTER="1"
|
||||
# ... then provide these parameters as well:
|
||||
# export CASSANDRA_KEYSPACE="..."
|
||||
# export CASSANDRA_CONTACT_POINTS="127.0.0.1" # optional
|
||||
# export CASSANDRA_USERNAME="cassandra" # optional
|
||||
# export CASSANDRA_PASSWORD="cassandra" # optional
|
@ -1,77 +0,0 @@
|
||||
# Cassandra - synonym caching
|
||||
|
||||
This template provides a simple chain template showcasing the usage
|
||||
of LLM Caching backed by `Apache Cassandra®` or `Astra DB` through `CQL`.
|
||||
|
||||
## Environment Setup
|
||||
|
||||
To set up your environment, you will need the following:
|
||||
|
||||
- an [Astra](https://astra.datastax.com) Vector Database (free tier is fine!). **You need a [Database Administrator token](https://awesome-astra.github.io/docs/pages/astra/create-token/#c-procedure)**, in particular the string starting with `AstraCS:...`;
|
||||
- likewise, get your [Database ID](https://awesome-astra.github.io/docs/pages/astra/faq/#where-should-i-find-a-database-identifier) ready, you will have to enter it below;
|
||||
- an **OpenAI API Key**. (More info [here](https://cassio.org/start_here/#llm-access), note that out-of-the-box this demo supports OpenAI unless you tinker with the code.)
|
||||
|
||||
_Note:_ you can alternatively use a regular Cassandra cluster: to do so, make sure you provide the `USE_CASSANDRA_CLUSTER` entry as shown in `.env.template` and the subsequent environment variables to specify how to connect to it.
|
||||
|
||||
## Usage
|
||||
|
||||
To use this package, you should first have the LangChain CLI installed:
|
||||
|
||||
```shell
|
||||
pip install -U langchain-cli
|
||||
```
|
||||
|
||||
To create a new LangChain project and install this as the only package, you can do:
|
||||
|
||||
```shell
|
||||
langchain app new my-app --package cassandra-synonym-caching
|
||||
```
|
||||
|
||||
If you want to add this to an existing project, you can just run:
|
||||
|
||||
```shell
|
||||
langchain app add cassandra-synonym-caching
|
||||
```
|
||||
|
||||
And add the following code to your `server.py` file:
|
||||
```python
|
||||
from cassandra_synonym_caching import chain as cassandra_synonym_caching_chain
|
||||
|
||||
add_routes(app, cassandra_synonym_caching_chain, path="/cassandra-synonym-caching")
|
||||
```
|
||||
|
||||
(Optional) Let's now configure LangSmith.
|
||||
LangSmith will help us trace, monitor and debug LangChain applications.
|
||||
You can sign up for LangSmith [here](https://smith.langchain.com/).
|
||||
If you don't have access, you can skip this section
|
||||
|
||||
|
||||
```shell
|
||||
export LANGCHAIN_TRACING_V2=true
|
||||
export LANGCHAIN_API_KEY=<your-api-key>
|
||||
export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
|
||||
```
|
||||
|
||||
If you are inside this directory, then you can spin up a LangServe instance directly by:
|
||||
|
||||
```shell
|
||||
langchain serve
|
||||
```
|
||||
|
||||
This will start the FastAPI app with a server is running locally at
|
||||
[http://localhost:8000](http://localhost:8000)
|
||||
|
||||
We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
|
||||
We can access the playground at [http://127.0.0.1:8000/cassandra-synonym-caching/playground](http://127.0.0.1:8000/cassandra-synonym-caching/playground)
|
||||
|
||||
We can access the template from code with:
|
||||
|
||||
```python
|
||||
from langserve.client import RemoteRunnable
|
||||
|
||||
runnable = RemoteRunnable("http://localhost:8000/cassandra-synonym-caching")
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
Stand-alone LangServe template repo: [here](https://github.com/hemidactylus/langserve_cassandra_synonym_caching).
|
@ -1,42 +0,0 @@
|
||||
import os
|
||||
|
||||
import cassio
|
||||
import langchain
|
||||
from langchain_community.cache import CassandraCache
|
||||
from langchain_community.chat_models import ChatOpenAI
|
||||
from langchain_core.messages import BaseMessage
|
||||
from langchain_core.prompts import ChatPromptTemplate
|
||||
from langchain_core.runnables import RunnableLambda
|
||||
|
||||
use_cassandra = int(os.environ.get("USE_CASSANDRA_CLUSTER", "0"))
|
||||
if use_cassandra:
|
||||
from .cassandra_cluster_init import get_cassandra_connection
|
||||
|
||||
session, keyspace = get_cassandra_connection()
|
||||
cassio.init(
|
||||
session=session,
|
||||
keyspace=keyspace,
|
||||
)
|
||||
else:
|
||||
cassio.init(
|
||||
token=os.environ["ASTRA_DB_APPLICATION_TOKEN"],
|
||||
database_id=os.environ["ASTRA_DB_ID"],
|
||||
keyspace=os.environ.get("ASTRA_DB_KEYSPACE"),
|
||||
)
|
||||
|
||||
# inits
|
||||
langchain.llm_cache = CassandraCache(session=None, keyspace=None)
|
||||
llm = ChatOpenAI()
|
||||
|
||||
|
||||
# custom runnables
|
||||
def msg_splitter(msg: BaseMessage):
|
||||
return [w.strip() for w in msg.content.split(",") if w.strip()]
|
||||
|
||||
|
||||
# synonym-route preparation
|
||||
synonym_prompt = ChatPromptTemplate.from_template(
|
||||
"List up to five comma-separated synonyms of this word: {word}"
|
||||
)
|
||||
|
||||
chain = synonym_prompt | llm | RunnableLambda(msg_splitter)
|
@ -1,29 +0,0 @@
|
||||
import os
|
||||
|
||||
from cassandra.auth import PlainTextAuthProvider
|
||||
from cassandra.cluster import Cluster
|
||||
|
||||
|
||||
def get_cassandra_connection():
|
||||
contact_points = [
|
||||
cp.strip()
|
||||
for cp in os.environ.get("CASSANDRA_CONTACT_POINTS", "").split(",")
|
||||
if cp.strip()
|
||||
]
|
||||
CASSANDRA_KEYSPACE = os.environ["CASSANDRA_KEYSPACE"]
|
||||
CASSANDRA_USERNAME = os.environ.get("CASSANDRA_USERNAME")
|
||||
CASSANDRA_PASSWORD = os.environ.get("CASSANDRA_PASSWORD")
|
||||
#
|
||||
if CASSANDRA_USERNAME and CASSANDRA_PASSWORD:
|
||||
auth_provider = PlainTextAuthProvider(
|
||||
CASSANDRA_USERNAME,
|
||||
CASSANDRA_PASSWORD,
|
||||
)
|
||||
else:
|
||||
auth_provider = None
|
||||
|
||||
c_cluster = Cluster(
|
||||
contact_points if contact_points else None, auth_provider=auth_provider
|
||||
)
|
||||
session = c_cluster.connect()
|
||||
return (session, CASSANDRA_KEYSPACE)
|
@ -1,34 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "cassandra-synonym-caching"
|
||||
version = "0.0.1"
|
||||
description = "LLM caching backed by Apache Cassandra® or Astra DB"
|
||||
authors = [
|
||||
"Stefano Lottini <stefano.lottini@datastax.com>",
|
||||
]
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.8.1,<4.0"
|
||||
langchain = "^0.1"
|
||||
openai = "<2"
|
||||
tiktoken = "^0.5.1"
|
||||
cassio = "^0.1.3"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
langchain-cli = ">=0.0.21"
|
||||
|
||||
[tool.langserve]
|
||||
export_module = "cassandra_synonym_caching"
|
||||
export_attr = "chain"
|
||||
|
||||
[tool.templates-hub]
|
||||
use-case = "rag"
|
||||
author = "DataStax"
|
||||
integrations = ["OpenAI", "Cassandra"]
|
||||
tags = ["vectordbs"]
|
||||
|
||||
[build-system]
|
||||
requires = [
|
||||
"poetry-core",
|
||||
]
|
||||
build-backend = "poetry.core.masonry.api"
|
@ -1,21 +0,0 @@
|
||||
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.
|
@ -1,73 +0,0 @@
|
||||
# Chain-of-Note - Wikipedia
|
||||
|
||||
Implements `Chain-of-Note` as described in [CHAIN-OF-NOTE: ENHANCING ROBUSTNESS IN
|
||||
RETRIEVAL-AUGMENTED LANGUAGE MODELS](https://arxiv.org/pdf/2311.09210.pdf) paper
|
||||
by Yu, et al. Uses `Wikipedia` for retrieval.
|
||||
|
||||
Check out the prompt being used here https://smith.langchain.com/hub/bagatur/chain-of-note-wiki.
|
||||
|
||||
## Environment Setup
|
||||
|
||||
Uses Anthropic claude-3-sonnet-20240229 chat model. Set Anthropic API key:
|
||||
```bash
|
||||
export ANTHROPIC_API_KEY="..."
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
To use this package, you should first have the LangChain CLI installed:
|
||||
|
||||
```shell
|
||||
pip install -U "langchain-cli[serve]"
|
||||
```
|
||||
|
||||
To create a new LangChain project and install this as the only package, you can do:
|
||||
|
||||
```shell
|
||||
langchain app new my-app --package chain-of-note-wiki
|
||||
```
|
||||
|
||||
If you want to add this to an existing project, you can just run:
|
||||
|
||||
```shell
|
||||
langchain app add chain-of-note-wiki
|
||||
```
|
||||
|
||||
And add the following code to your `server.py` file:
|
||||
```python
|
||||
from chain_of_note_wiki import chain as chain_of_note_wiki_chain
|
||||
|
||||
add_routes(app, chain_of_note_wiki_chain, path="/chain-of-note-wiki")
|
||||
```
|
||||
|
||||
(Optional) Let's now configure LangSmith.
|
||||
LangSmith will help us trace, monitor and debug LangChain applications.
|
||||
You can sign up for LangSmith [here](https://smith.langchain.com/).
|
||||
If you don't have access, you can skip this section
|
||||
|
||||
|
||||
```shell
|
||||
export LANGCHAIN_TRACING_V2=true
|
||||
export LANGCHAIN_API_KEY=<your-api-key>
|
||||
export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
|
||||
```
|
||||
|
||||
If you are inside this directory, then you can spin up a LangServe instance directly by:
|
||||
|
||||
```shell
|
||||
langchain serve
|
||||
```
|
||||
|
||||
This will start the FastAPI app with a server is running locally at
|
||||
[http://localhost:8000](http://localhost:8000)
|
||||
|
||||
We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
|
||||
We can access the playground at [http://127.0.0.1:8000/chain-of-note-wiki/playground](http://127.0.0.1:8000/chain-of-note-wiki/playground)
|
||||
|
||||
We can access the template from code with:
|
||||
|
||||
```python
|
||||
from langserve.client import RemoteRunnable
|
||||
|
||||
runnable = RemoteRunnable("http://localhost:8000/chain-of-note-wiki")
|
||||
```
|
@ -1,3 +0,0 @@
|
||||
from chain_of_note_wiki.chain import chain
|
||||
|
||||
__all__ = ["chain"]
|
@ -1,33 +0,0 @@
|
||||
from langchain import hub
|
||||
from langchain_anthropic import ChatAnthropic
|
||||
from langchain_community.utilities import WikipediaAPIWrapper
|
||||
from langchain_core.output_parsers import StrOutputParser
|
||||
from langchain_core.pydantic_v1 import BaseModel
|
||||
from langchain_core.runnables import RunnableLambda, RunnablePassthrough
|
||||
|
||||
|
||||
class Question(BaseModel):
|
||||
__root__: str
|
||||
|
||||
|
||||
wiki = WikipediaAPIWrapper(top_k_results=5)
|
||||
prompt = hub.pull("bagatur/chain-of-note-wiki")
|
||||
|
||||
llm = ChatAnthropic(model="claude-3-sonnet-20240229")
|
||||
|
||||
|
||||
def format_docs(docs):
|
||||
return "\n\n".join(
|
||||
f"Wikipedia {i+1}:\n{doc.page_content}" for i, doc in enumerate(docs)
|
||||
)
|
||||
|
||||
|
||||
chain = (
|
||||
{
|
||||
"passages": RunnableLambda(wiki.load) | format_docs,
|
||||
"question": RunnablePassthrough(),
|
||||
}
|
||||
| prompt
|
||||
| llm
|
||||
| StrOutputParser()
|
||||
).with_types(input_type=Question)
|
@ -1,32 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "chain-of-note-wiki"
|
||||
version = "0.0.1"
|
||||
description = "Implementation of Chain of Note prompting for Wikipedia."
|
||||
authors = []
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.8.1,<4.0"
|
||||
langchain = "^0.1"
|
||||
wikipedia = "^1.4.0"
|
||||
langchainhub = "^0.1.14"
|
||||
langchain-anthropic = "^0.1.4"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
langchain-cli = ">=0.0.21"
|
||||
fastapi = ">=0.104.0,<1"
|
||||
sse-starlette = "^1.6.5"
|
||||
|
||||
[tool.langserve]
|
||||
export_module = "chain_of_note_wiki"
|
||||
export_attr = "chain"
|
||||
|
||||
[tool.templates-hub]
|
||||
use-case = "rag"
|
||||
author = "LangChain"
|
||||
integrations = ["Anthropic", "Wikipedia", "LangChain Hub"]
|
||||
tags = ["paper", "prompt-hub"]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
@ -1,21 +0,0 @@
|
||||
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.
|
@ -1,116 +0,0 @@
|
||||
# Chatbot feedback
|
||||
|
||||
This template shows how to evaluate your chatbot without explicit user feedback.
|
||||
It defines a simple chatbot in [chain.py](https://github.com/langchain-ai/langchain/blob/master/templates/chat-bot-feedback/chat_bot_feedback/chain.py) and custom evaluator that scores bot response effectiveness based on the subsequent user response. You can apply this run evaluator to your own chat bot by calling `with_config` on the chat bot before serving. You can also directly deploy your chat app using this template.
|
||||
|
||||
[Chatbots](https://python.langchain.com/docs/use_cases/chatbots) are one of the most common interfaces for deploying LLMs. The quality of chat bots varies, making continuous development important. But users are wont to leave explicit feedback through mechanisms like thumbs-up or thumbs-down buttons. Furthermore, traditional analytics such as "session length" or "conversation length" often lack clarity. However, multi-turn conversations with a chat bot can provide a wealth of information, which we can transform into metrics for fine-tuning, evaluation, and product analytics.
|
||||
|
||||
Taking [Chat Langchain](https://chat.langchain.com/) as a case study, only about 0.04% of all queries receive explicit feedback. Yet, approximately 70% of the queries are follow-ups to previous questions. A significant portion of these follow-up queries continue useful information we can use to infer the quality of the previous AI response.
|
||||
|
||||
|
||||
This template helps solve this "feedback scarcity" problem. Below is an example invocation of this chat bot:
|
||||
|
||||
["Chat Bot Interaction Example"](https://smith.langchain.com/public/3378daea-133c-4fe8-b4da-0a3044c5dbe8/r?runtab=1)
|
||||
|
||||
When the user responds to this ([link](https://smith.langchain.com/public/a7e2df54-4194-455d-9978-cecd8be0df1e/r)), the response evaluator is invoked, resulting in the following evaluation run:
|
||||
|
||||
 ["Chat Bot Evaluator Run"](https://smith.langchain.com/public/534184ee-db8f-4831-a386-3f578145114c/r)
|
||||
|
||||
As shown, the evaluator sees that the user is increasingly frustrated, indicating that the prior response was not effective
|
||||
|
||||
## LangSmith Feedback
|
||||
|
||||
[LangSmith](https://smith.langchain.com/) is a platform for building production-grade LLM applications. Beyond its debugging and offline evaluation features, LangSmith helps you capture both user and model-assisted feedback to refine your LLM application. This template uses an LLM to generate feedback for your application, which you can use to continuously improve your service. For more examples on collecting feedback using LangSmith, consult the [documentation](https://docs.smith.langchain.com/cookbook/feedback-examples).
|
||||
|
||||
## Evaluator Implementation
|
||||
|
||||
The user feedback is inferred by custom `RunEvaluator`. This evaluator is called using the `EvaluatorCallbackHandler`, which run it in a separate thread to avoid interfering with the chat bot's runtime. You can use this custom evaluator on any compatible chat bot by calling the following function on your LangChain object:
|
||||
|
||||
```python
|
||||
my_chain.with_config(
|
||||
callbacks=[
|
||||
EvaluatorCallbackHandler(
|
||||
evaluators=[
|
||||
ResponseEffectivenessEvaluator(evaluate_response_effectiveness)
|
||||
]
|
||||
)
|
||||
],
|
||||
)
|
||||
```
|
||||
|
||||
The evaluator instructs an LLM, specifically `gpt-3.5-turbo`, to evaluate the AI's most recent chat message based on the user's followup response. It generates a score and accompanying reasoning that is converted to feedback in LangSmith, applied to the value provided as the `last_run_id`.
|
||||
|
||||
The prompt used within the LLM [is available on the hub](https://smith.langchain.com/hub/wfh/response-effectiveness). Feel free to customize it with things like additional app context (such as the goal of the app or the types of questions it should respond to) or "symptoms" you'd like the LLM to focus on. This evaluator also utilizes OpenAI's function-calling API to ensure a more consistent, structured output for the grade.
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Ensure that `OPENAI_API_KEY` is set to use OpenAI models. Also, configure LangSmith by setting your `LANGSMITH_API_KEY`.
|
||||
|
||||
```bash
|
||||
export OPENAI_API_KEY=sk-...
|
||||
export LANGSMITH_API_KEY=...
|
||||
export LANGCHAIN_TRACING_V2=true
|
||||
export LANGCHAIN_PROJECT=my-project # Set to the project you want to save to
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
If deploying via `LangServe`, we recommend configuring the server to return callback events as well. This will ensure the backend traces are included in whatever traces you generate using the `RemoteRunnable`.
|
||||
|
||||
```python
|
||||
from chat_bot_feedback.chain import chain
|
||||
|
||||
add_routes(app, chain, path="/chat-bot-feedback", include_callback_events=True)
|
||||
```
|
||||
|
||||
With the server running, you can use the following code snippet to stream the chat bot responses for a 2 turn conversation.
|
||||
|
||||
```python
|
||||
from functools import partial
|
||||
from typing import Dict, Optional, Callable, List
|
||||
from langserve import RemoteRunnable
|
||||
from langchain.callbacks.manager import tracing_v2_enabled
|
||||
from langchain_core.messages import BaseMessage, AIMessage, HumanMessage
|
||||
|
||||
# Update with the URL provided by your LangServe server
|
||||
chain = RemoteRunnable("http://127.0.0.1:8031/chat-bot-feedback")
|
||||
|
||||
def stream_content(
|
||||
text: str,
|
||||
chat_history: Optional[List[BaseMessage]] = None,
|
||||
last_run_id: Optional[str] = None,
|
||||
on_chunk: Callable = None,
|
||||
):
|
||||
results = []
|
||||
with tracing_v2_enabled() as cb:
|
||||
for chunk in chain.stream(
|
||||
{"text": text, "chat_history": chat_history, "last_run_id": last_run_id},
|
||||
):
|
||||
on_chunk(chunk)
|
||||
results.append(chunk)
|
||||
last_run_id = cb.latest_run.id if cb.latest_run else None
|
||||
return last_run_id, "".join(results)
|
||||
|
||||
chat_history = []
|
||||
text = "Where are my keys?"
|
||||
last_run_id, response_message = stream_content(text, on_chunk=partial(print, end=""))
|
||||
print()
|
||||
chat_history.extend([HumanMessage(content=text), AIMessage(content=response_message)])
|
||||
text = "I CAN'T FIND THEM ANYWHERE" # The previous response will likely receive a low score,
|
||||
# as the user's frustration appears to be escalating.
|
||||
last_run_id, response_message = stream_content(
|
||||
text,
|
||||
chat_history=chat_history,
|
||||
last_run_id=str(last_run_id),
|
||||
on_chunk=partial(print, end=""),
|
||||
)
|
||||
print()
|
||||
chat_history.extend([HumanMessage(content=text), AIMessage(content=response_message)])
|
||||
```
|
||||
|
||||
This uses the `tracing_v2_enabled` callback manager to get the run ID of the call, which we provide in subsequent calls in the same chat thread, so the evaluator can assign feedback to the appropriate trace.
|
||||
|
||||
|
||||
## Conclusion
|
||||
|
||||
This template provides a simple chat bot definition you can directly deploy using LangServe. It defines a custom evaluator to log evaluation feedback for the bot without any explicit user ratings. This is an effective way to augment your analytics and to better select data points for fine-tuning and evaluation.
|
@ -1,3 +0,0 @@
|
||||
from chat_bot_feedback.chain import chain
|
||||
|
||||
__all__ = ["chain"]
|
@ -1,183 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import List, Optional
|
||||
|
||||
from langchain import hub
|
||||
from langchain.callbacks.tracers.evaluation import EvaluatorCallbackHandler
|
||||
from langchain.callbacks.tracers.schemas import Run
|
||||
from langchain.schema import (
|
||||
AIMessage,
|
||||
BaseMessage,
|
||||
HumanMessage,
|
||||
StrOutputParser,
|
||||
get_buffer_string,
|
||||
)
|
||||
from langchain_community.chat_models import ChatOpenAI
|
||||
from langchain_core.output_parsers.openai_functions import JsonOutputFunctionsParser
|
||||
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
||||
from langchain_core.pydantic_v1 import BaseModel, Field
|
||||
from langchain_core.runnables import Runnable
|
||||
from langsmith.evaluation import EvaluationResult, RunEvaluator
|
||||
from langsmith.schemas import Example
|
||||
|
||||
###############################################################################
|
||||
# | Chat Bot Evaluator Definition
|
||||
# | This section defines an evaluator that evaluates any chat bot
|
||||
# | without explicit user feedback. It formats the dialog up to
|
||||
# | the current message and then instructs an LLM to grade the last AI response
|
||||
# | based on the subsequent user response. If no chat history is present,
|
||||
# V the evaluator is not called.
|
||||
###############################################################################
|
||||
|
||||
|
||||
class ResponseEffectiveness(BaseModel):
|
||||
"""Score the effectiveness of the AI chat bot response."""
|
||||
|
||||
reasoning: str = Field(
|
||||
...,
|
||||
description="Explanation for the score.",
|
||||
)
|
||||
score: int = Field(
|
||||
...,
|
||||
min=0,
|
||||
max=5,
|
||||
description="Effectiveness of AI's final response.",
|
||||
)
|
||||
|
||||
|
||||
def format_messages(input: dict) -> List[BaseMessage]:
|
||||
"""Format the messages for the evaluator."""
|
||||
chat_history = input.get("chat_history") or []
|
||||
results = []
|
||||
for message in chat_history:
|
||||
if message["type"] == "human":
|
||||
results.append(HumanMessage.parse_obj(message))
|
||||
else:
|
||||
results.append(AIMessage.parse_obj(message))
|
||||
return results
|
||||
|
||||
|
||||
def format_dialog(input: dict) -> dict:
|
||||
"""Format messages and convert to a single string."""
|
||||
chat_history = format_messages(input)
|
||||
formatted_dialog = get_buffer_string(chat_history) + f"\nhuman: {input['text']}"
|
||||
return {"dialog": formatted_dialog}
|
||||
|
||||
|
||||
def normalize_score(response: dict) -> dict:
|
||||
"""Normalize the score to be between 0 and 1."""
|
||||
response["score"] = int(response["score"]) / 5
|
||||
return response
|
||||
|
||||
|
||||
# To view the prompt in the playground: https://smith.langchain.com/hub/wfh/response-effectiveness
|
||||
evaluation_prompt = hub.pull("wfh/response-effectiveness")
|
||||
evaluate_response_effectiveness = (
|
||||
format_dialog
|
||||
| evaluation_prompt
|
||||
# bind_functions formats the schema for the OpenAI function
|
||||
# calling endpoint, which returns more reliable structured data.
|
||||
| ChatOpenAI(model="gpt-3.5-turbo").bind_functions(
|
||||
functions=[ResponseEffectiveness],
|
||||
function_call="ResponseEffectiveness",
|
||||
)
|
||||
# Convert the model's output to a dict
|
||||
| JsonOutputFunctionsParser(args_only=True)
|
||||
| normalize_score
|
||||
)
|
||||
|
||||
|
||||
class ResponseEffectivenessEvaluator(RunEvaluator):
|
||||
"""Evaluate the chat bot based the subsequent user responses."""
|
||||
|
||||
def __init__(self, evaluator_runnable: Runnable) -> None:
|
||||
super().__init__()
|
||||
self.runnable = evaluator_runnable
|
||||
|
||||
def evaluate_run(
|
||||
self, run: Run, example: Optional[Example] = None
|
||||
) -> EvaluationResult:
|
||||
# This evaluator grades the AI's PREVIOUS response.
|
||||
# If no chat history is present, there isn't anything to evaluate
|
||||
# (it's the user's first message)
|
||||
if not run.inputs.get("chat_history"):
|
||||
return EvaluationResult(
|
||||
key="response_effectiveness", comment="No chat history present."
|
||||
)
|
||||
# This only occurs if the client isn't correctly sending the run IDs
|
||||
# of the previous calls.
|
||||
elif "last_run_id" not in run.inputs:
|
||||
return EvaluationResult(
|
||||
key="response_effectiveness", comment="No last run ID present."
|
||||
)
|
||||
# Call the LLM to evaluate the response
|
||||
eval_grade: Optional[dict] = self.runnable.invoke(run.inputs)
|
||||
target_run_id = run.inputs["last_run_id"]
|
||||
return EvaluationResult(
|
||||
**eval_grade,
|
||||
key="response_effectiveness",
|
||||
target_run_id=target_run_id, # Requires langsmith >= 0.0.54
|
||||
)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# | The chat bot definition
|
||||
# | This is what is actually exposed by LangServe in the API
|
||||
# | It can be any chain that accepts the ChainInput schema and returns a str
|
||||
# | all that is required is the with_config() call at the end to add the
|
||||
# V evaluators as "listeners" to the chain.
|
||||
# ############################################################################
|
||||
|
||||
|
||||
class ChainInput(BaseModel):
|
||||
"""Input for the chat bot."""
|
||||
|
||||
chat_history: Optional[List[BaseMessage]] = Field(
|
||||
description="Previous chat messages."
|
||||
)
|
||||
text: str = Field(..., description="User's latest query.")
|
||||
last_run_id: Optional[str] = Field("", description="Run ID of the last run.")
|
||||
|
||||
|
||||
_prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
(
|
||||
"system",
|
||||
"You are a helpful assistant who speaks like a pirate",
|
||||
),
|
||||
MessagesPlaceholder(variable_name="chat_history"),
|
||||
("user", "{text}"),
|
||||
]
|
||||
)
|
||||
_model = ChatOpenAI()
|
||||
|
||||
|
||||
def format_chat_history(chain_input: dict) -> dict:
|
||||
messages = format_messages(chain_input)
|
||||
|
||||
return {
|
||||
"chat_history": messages,
|
||||
"text": chain_input.get("text"),
|
||||
}
|
||||
|
||||
|
||||
# if you update the name of this, you MUST also update ../pyproject.toml
|
||||
# with the new `tool.langserve.export_attr`
|
||||
chain = (
|
||||
(format_chat_history | _prompt | _model | StrOutputParser())
|
||||
# This is to add the evaluators as "listeners"
|
||||
# and to customize the name of the chain.
|
||||
# Any chain that accepts a compatible input type works here.
|
||||
.with_config(
|
||||
run_name="ChatBot",
|
||||
callbacks=[
|
||||
EvaluatorCallbackHandler(
|
||||
evaluators=[
|
||||
ResponseEffectivenessEvaluator(evaluate_response_effectiveness)
|
||||
]
|
||||
)
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
chain = chain.with_types(input_type=ChainInput)
|
@ -1,32 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "chat-bot-feedback"
|
||||
version = "0.0.1"
|
||||
description = "Evaluate your chatbot without human feedback"
|
||||
authors = []
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.8.1,<4.0"
|
||||
langchain = "^0.1"
|
||||
openai = "<2"
|
||||
langsmith = ">=0.0.54"
|
||||
langchainhub = ">=0.1.13"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
langchain-cli = ">=0.0.21"
|
||||
fastapi = ">=0.104.0,<1"
|
||||
sse-starlette = "^1.6.5"
|
||||
|
||||
[tool.langserve]
|
||||
export_module = "chat_bot_feedback.chain"
|
||||
export_attr = "chain"
|
||||
|
||||
[tool.templates-hub]
|
||||
use-case = "evaluation"
|
||||
author = "LangChain"
|
||||
integrations = ["OpenAI", "LangSmith"]
|
||||
tags = ["langsmith"]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
Binary file not shown.
Before ![]() (image error) Size: 131 KiB |
Binary file not shown.
Before ![]() (image error) Size: 810 KiB |
@ -1,74 +0,0 @@
|
||||
# Cohere - Librarian
|
||||
|
||||
This template turns `Cohere` into a librarian.
|
||||
|
||||
It demonstrates the use of:
|
||||
- a router to switch between chains that handle different things
|
||||
- a vector database with Cohere embeddings
|
||||
- a chat bot that has a prompt with some information about the library
|
||||
- a RAG chatbot that has access to the internet.
|
||||
|
||||
For a fuller demo of the book recommendation, consider replacing `books_with_blurbs.csv` with a larger sample from the following dataset: https://www.kaggle.com/datasets/jdobrow/57000-books-with-metadata-and-blurbs/ .
|
||||
|
||||
## Environment Setup
|
||||
|
||||
Set the `COHERE_API_KEY` environment variable to access the Cohere models.
|
||||
|
||||
## Usage
|
||||
|
||||
To use this package, you should first have the LangChain CLI installed:
|
||||
|
||||
```shell
|
||||
pip install -U langchain-cli
|
||||
```
|
||||
|
||||
To create a new LangChain project and install this as the only package, you can do:
|
||||
|
||||
```shell
|
||||
langchain app new my-app --package cohere-librarian
|
||||
```
|
||||
|
||||
If you want to add this to an existing project, you can just run:
|
||||
|
||||
```shell
|
||||
langchain app add cohere-librarian
|
||||
```
|
||||
|
||||
And add the following code to your `server.py` file:
|
||||
```python
|
||||
from cohere_librarian.chain import chain as cohere_librarian_chain
|
||||
|
||||
add_routes(app, cohere_librarian_chain, path="/cohere-librarian")
|
||||
```
|
||||
|
||||
(Optional) Let's now configure LangSmith.
|
||||
LangSmith will help us trace, monitor and debug LangChain applications.
|
||||
You can sign up for LangSmith [here](https://smith.langchain.com/).
|
||||
If you don't have access, you can skip this section
|
||||
|
||||
|
||||
```shell
|
||||
export LANGCHAIN_TRACING_V2=true
|
||||
export LANGCHAIN_API_KEY=<your-api-key>
|
||||
export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
|
||||
```
|
||||
|
||||
If you are inside this directory, then you can spin up a LangServe instance directly by:
|
||||
|
||||
```shell
|
||||
langchain serve
|
||||
```
|
||||
|
||||
This will start the FastAPI app with a server is running locally at
|
||||
[http://localhost:8000](http://localhost:8000)
|
||||
|
||||
We can see all templates at [http://localhost:8000/docs](http://localhost:8000/docs)
|
||||
We can access the playground at [http://localhost:8000/cohere-librarian/playground](http://localhost:8000/cohere-librarian/playground)
|
||||
|
||||
We can access the template from code with:
|
||||
|
||||
```python
|
||||
from langserve.client import RemoteRunnable
|
||||
|
||||
runnable = RemoteRunnable("http://localhost:8000/cohere-librarian")
|
||||
```
|
@ -1,3 +0,0 @@
|
||||
from .chain import chain
|
||||
|
||||
__all__ = ["chain"]
|
@ -1,49 +0,0 @@
|
||||
import csv
|
||||
|
||||
from langchain.chains.question_answering import load_qa_chain
|
||||
from langchain_chroma import Chroma
|
||||
from langchain_community.embeddings import CohereEmbeddings
|
||||
from langchain_core.prompts import PromptTemplate
|
||||
|
||||
from .chat import chat
|
||||
|
||||
csv_file = open("data/books_with_blurbs.csv", "r")
|
||||
csv_reader = csv.reader(csv_file)
|
||||
csv_data = list(csv_reader)
|
||||
parsed_data = [
|
||||
{
|
||||
"id": x[0],
|
||||
"title": x[1],
|
||||
"author": x[2],
|
||||
"year": x[3],
|
||||
"publisher": x[4],
|
||||
"blurb": x[5],
|
||||
}
|
||||
for x in csv_data
|
||||
]
|
||||
parsed_data[1]
|
||||
|
||||
embeddings = CohereEmbeddings(model="embed-english-v3.0")
|
||||
|
||||
docsearch = Chroma.from_texts(
|
||||
[x["title"] for x in parsed_data], embeddings, metadatas=parsed_data
|
||||
).as_retriever()
|
||||
|
||||
|
||||
prompt_template = """
|
||||
{context}
|
||||
|
||||
Use the book reccommendations to suggest books for the user to read.
|
||||
Only use the titles of the books, do not make up titles. Format the response as
|
||||
a bulleted list prefixed by a relevant message.
|
||||
|
||||
User: {message}"""
|
||||
|
||||
PROMPT = PromptTemplate(
|
||||
template=prompt_template, input_variables=["context", "message"]
|
||||
)
|
||||
|
||||
book_rec_chain = {
|
||||
"input_documents": lambda x: docsearch.invoke(x["message"]),
|
||||
"message": lambda x: x["message"],
|
||||
} | load_qa_chain(chat, chain_type="stuff", prompt=PROMPT)
|
@ -1,10 +0,0 @@
|
||||
from langchain.pydantic_v1 import BaseModel
|
||||
|
||||
from .router import branched_chain
|
||||
|
||||
|
||||
class ChainInput(BaseModel):
|
||||
message: str
|
||||
|
||||
|
||||
chain = branched_chain.with_types(input_type=ChainInput)
|
@ -1,3 +0,0 @@
|
||||
from langchain_community.llms import Cohere
|
||||
|
||||
chat = Cohere()
|
@ -1,27 +0,0 @@
|
||||
from langchain_core.prompts import (
|
||||
ChatPromptTemplate,
|
||||
HumanMessagePromptTemplate,
|
||||
SystemMessagePromptTemplate,
|
||||
)
|
||||
|
||||
from .chat import chat
|
||||
|
||||
librarian_prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
SystemMessagePromptTemplate.from_template(
|
||||
"""
|
||||
You are a librarian at cohere community library. Your job is to
|
||||
help recommend people books to read based on their interests and
|
||||
preferences. You also give information about the library.
|
||||
|
||||
The library opens at 8am and closes at 9pm daily. It is closed on
|
||||
Sundays.
|
||||
|
||||
Please answer the following message:
|
||||
"""
|
||||
),
|
||||
HumanMessagePromptTemplate.from_template("{message}"),
|
||||
]
|
||||
)
|
||||
|
||||
library_info = librarian_prompt | chat
|
@ -1,16 +0,0 @@
|
||||
from langchain.retrievers import CohereRagRetriever
|
||||
from langchain_community.chat_models import ChatCohere
|
||||
|
||||
rag = CohereRagRetriever(llm=ChatCohere())
|
||||
|
||||
|
||||
def get_docs_message(message):
|
||||
docs = rag.invoke(message)
|
||||
message_doc = next(
|
||||
(x for x in docs if x.metadata.get("type") == "model_response"), None
|
||||
)
|
||||
return message_doc.page_content
|
||||
|
||||
|
||||
def librarian_rag(x):
|
||||
return get_docs_message(x["message"])
|
@ -1,43 +0,0 @@
|
||||
from langchain_core.output_parsers import StrOutputParser
|
||||
from langchain_core.prompts import ChatPromptTemplate
|
||||
from langchain_core.runnables import RunnableBranch
|
||||
|
||||
from .blurb_matcher import book_rec_chain
|
||||
from .chat import chat
|
||||
from .library_info import library_info
|
||||
from .rag import librarian_rag
|
||||
|
||||
chain = (
|
||||
ChatPromptTemplate.from_template(
|
||||
"""Given the user message below,
|
||||
classify it as either being about `recommendation`, `library` or `other`.
|
||||
|
||||
'{message}'
|
||||
|
||||
Respond with just one word.
|
||||
For example, if the message is about a book recommendation,respond with
|
||||
`recommendation`.
|
||||
"""
|
||||
)
|
||||
| chat
|
||||
| StrOutputParser()
|
||||
)
|
||||
|
||||
|
||||
def extract_op_field(x):
|
||||
return x["output_text"]
|
||||
|
||||
|
||||
branch = RunnableBranch(
|
||||
(
|
||||
lambda x: "recommendation" in x["topic"].lower(),
|
||||
book_rec_chain | extract_op_field,
|
||||
),
|
||||
(
|
||||
lambda x: "library" in x["topic"].lower(),
|
||||
{"message": lambda x: x["message"]} | library_info,
|
||||
),
|
||||
librarian_rag,
|
||||
)
|
||||
|
||||
branched_chain = {"topic": chain, "message": lambda x: x["message"]} | branch
|
@ -1,21 +0,0 @@
|
||||
ISBN,Title,Author,Year,Publisher,Blurb, ** grab this file from https://www.kaggle.com/datasets/jdobrow/57000-books-with-metadata-and-blurbs/ **
|
||||
0060973129,Decision in Normandy,Carlo D'Este,1991,HarperPerennial,"Here, for the first time in paperback, is an outstanding military history that offers a dramatic new perspective on the Allied campaign that began with the invasion of the D-Day beaches of Normandy. Nationa advertising in Military History."
|
||||
0374157065,Flu: The Story of the Great Influenza Pandemic of 1918 and the Search for the Virus That Caused It,Gina Bari Kolata,1999,Farrar Straus Giroux,"The fascinating, true story of the world's deadliest disease. ,In 1918, the Great Flu Epidemic felled the young and healthy virtually overnight. An estimated forty million people died as the epidemic raged. Children were left orphaned and families were devastated. As many American soldiers were killed by the 1918 flu as were killed in battle during World War I. And no area of the globe was safe. Eskimos living in remote outposts in the frozen tundra were sickened and killed by the flu in such numbers that entire villages were wiped out. ,Scientists have recently rediscovered shards of the flu virus frozen in Alaska and preserved in scraps of tissue in a government warehouse. Gina Kolata, an acclaimed reporter for ""The New York Times,"" unravels the mystery of this lethal virus with the high drama of a great adventure story. Delving into the history of the flu and previous epidemics, detailing the science and the latest understanding of this mortal disease, Kolata addresses the prospects for a great epidemic recurring, and, most important, what can be done to prevent it."
|
||||
0399135782,The Kitchen God's Wife,Amy Tan,1991,Putnam Pub Group,"Winnie and Helen have kept each others worst secrets for more than fifty years. Now, because she believes she is dying, Helen wants to expose everything. And Winnie angrily determines that she must be the one to tell her daughter, Pearl, about the past—including the terrible truth even Helen does not know. And so begins Winnie's story of her life on a small island outside Shanghai in the 1920s, and other places in China during World War II, and traces the happy and desperate events that led to Winnie's coming to America in 1949."
|
||||
0425176428,What If?: The World's Foremost Military Historians Imagine What Might Have Been,Robert Cowley,2000,Berkley Publishing Group,"Historians and inquisitive laymen alike love to ponder the dramatic what-its of history. In these twenty never-before-published essays, some of the keenest minds of our time ask the big, tantalizing questions:, Where might we be if history had not unfolded the way it did? , Why, how, and when was our fortune made real? ,The answers are surprising, sometimes frightening, and always entertaining.."
|
||||
1881320189,Goodbye to the Buttermilk Sky,Julia Oliver,1994,River City Pub,"This highly praised first novel by fiction writer Julia Oliver is the story of one young woman's struggle with fidelity and identity in depression-era rural Alabama. A beautifully narrated novel of time and place, Goodbye to the Buttermilk Sky re-creates a southern summer when the depression and the boll weevil turned hopes to dust. With the extraordinary talent to make the reader see the Ball canning jars on the kitchen table, hear the clicks on the party line, and feel the bittersweet moments of 20-year-old Callie Tatum's first experiences with adult desire, Oliver portrays a young wife’s increasingly dangerous infidelity with cinematic precision and palpable suspense. Soon, with only her housekeeper as a confidant, Callie breaks society’s rules about race and class as well as her marriage vows. The result is a chain of events that will lead to tragedy and a woman’s stunning decision about love, passion, and the future of her life.Originally published in cloth in 1994, Goodbye to the Buttermilk Sky received considerable attention nationally and became a featured selection of the Quality Paperback Book Club. Its inclusion in the Deep South Books series from The University of Alabama Press will extend the book’s reach and its life, while offering new readers access to the enthralling story.The richly drawn, fully developed characters of Buttermilk Sky live on in the reader’s mind long after the book has been finished. Against the emotional and physical isolation of rural Alabama in 1938, the threads of family ties, whispered gossip, old secrets, and unfulfilled dreams weave a powerful, evocative story that captivates its reader until the very last word."
|
||||
0440234743,The Testament,John Grisham,1999,Dell,"In a plush Virginia office, a rich, angry old man is furiously rewriting his will. With his death just hours away, Troy Phelan wants to send a message to his children, his ex-wives, and his minions, a message that will touch off a vicious legal battle and transform dozens of lives.,Because Troy Phelan's new will names a sole surprise heir to his eleven-billion-dollar fortune: a mysterious woman named Rachel Lane, a missionary living deep in the jungles of Brazil.,Enter the lawyers. Nate O'Riley is fresh out of rehab, a disgraced corporate attorney handpicked for his last job: to find Rachel Lane at any cost. As Phelan's family circles like vultures in D.C., Nate is crashing through the Brazilian jungle, entering a world where money means nothing, where death is just one misstep away, and where a woman - pursued by enemies and friends alike - holds a stunning surprise of her own."
|
||||
0452264464,Beloved (Plume Contemporary Fiction),Toni Morrison,1994,Plume,"In the troubled years following the Civil War, the spirit of a murdered child haunts the Ohio home of a former slave. This angry, destructive ghost breaks mirrors, leaves its fingerprints in cake icing, and generally makes life difficult for Sethe and her family; nevertheless, the woman finds the haunting oddly comforting for the spirit is that of her own dead baby, never named, thought of only as Beloved. A dead child, a runaway slave, a terrible secret--these are the central concerns of Toni Morrison's Pulitzer Prize-winning Beloved. Morrison, a Nobel laureate, has written many fine novels, including Song of Solomon, The Bluest Eye, and Paradise--but Beloved is arguably her best. To modern readers, antebellum slavery is a subject so familiar that it is almost impossible to render its horrors in a way that seems neither clichéd nor melodramatic. Rapes, beatings, murders, and mutilations are recounted here, but they belong to characters so precisely drawn that the tragedy remains individual, terrifying to us because it is terrifying to the sufferer. And Morrison is master of the telling detail: in the bit, for example, a punishing piece of headgear used to discipline recalcitrant slaves, she manages to encapsulate all of slavery's many cruelties into one apt symbol--a device that deprives its wearer of speech. ""Days after it was taken out, goose fat was rubbed on the corners of the mouth but nothing to soothe the tongue or take the wildness out of the eye."" Most importantly, the language here, while often lyrical, is never overheated. Even as she recalls the cruelties visited upon her while a slave, Sethe is evocative without being overemotional: ""Add my husband to it, watching, above me in the loft--hiding close by--the one place he thought no one would look for him, looking down on what I couldn't look at at all. And not stopping them--looking and letting it happen.... And if he was that broken then, then he is also and certainly dead now."" Even the supernatural is treated as an ordinary fact of life: ""Not a house in the country ain't packed to its rafters with some dead Negro's grief. We lucky this ghost is a baby,"" comments Sethe's mother-in-law. Beloved is a dense, complex novel that yields up its secrets one by one. As Morrison takes us deeper into Sethe's history and her memories, the horrifying circumstances of her baby's death start to make terrible sense. And as past meets present in the shape of a mysterious young woman about the same age as Sethe's daughter would have been, the narrative builds inexorably to its powerful, painful conclusion. Beloved may well be the defining novel of slavery in America, the one that all others will be measured by. --Alix Wilber"
|
||||
0609804618,Our Dumb Century: The Onion Presents 100 Years of Headlines from America's Finest News Source,The Onion,1999,Three Rivers Press," has quickly become the world's most popular humor publication, misinforming half a million readers a week with one-of-a-kind social satire both in print (on newsstands nationwide) and online from its remote office in Madison, Wisconsin.,Witness the march of history as Editor-in-Chief Scott Dikkers and , award-winning writing staff present the twentieth century like you've never seen it before."
|
||||
1841721522,New Vegetarian: Bold and Beautiful Recipes for Every Occasion,Celia Brooks Brown,2001,Ryland Peters & Small Ltd,"Filled with fresh and eclectic recipes by Celia Brooks Brown -- one of the talented team of chefs at Books for Cooks, the world-famous bookshop-restaurant in London's Notting Hill -- New Vegetarian presents an innovative approach to vegetarian cooking. No longer the exclusive domain of vegetarians, meat-free food is now appreciated by all for its bright and assertive flavors, its marvelous colors, and its easy-to-make convenience. Celia gives sensible advice on choosing and preparing the major vegetarian ingredients, then presents 50 original and stylish recipes -- ranging from quick breakfasts to party foods, from salads to sweet treats -- all photographed by Philip Webb. Whether it is burritos bursting with flavor or Thai Glazed Vegetable Skewers fresh from the barbecue, Celia's enthusiasm and imagination will tempt even the most confirmed carnivore."
|
||||
0439095026,Tell Me This Isn't Happening,Robynn Clairday,1999,Scholastic,"Robynn Clairday interviewed kids throughout America to collect these real tales of awkward situations. From hilarious to poignant to painful, these stories are accompanied by advice about dealing with embarrassment and finding grace under pressure."
|
||||
0971880107,Wild Animus,Rich Shapero,2004,Too Far,"Newly graduated from college, Sam Altman is gripped by an inexplicable urge to lose himself in the wilderness and teams up with an enigmatic young woman who seems bent on helping him realize his dreams."
|
||||
0345402871,Airframe,Michael Crichton,1997,Ballantine Books,"Three passengers are dead. Fifty-six are injured. The interior cabin virtually destroyed. But the pilot manages to land the plane. . . .,At a moment when the issue of safety and death in the skies is paramount in the public mind, a lethal midair disaster aboard a commercial twin-jet airliner bound from Hong Kong to Denver triggers a pressured and frantic investigation.,AIRFRAME is nonstop reading: the extraordinary mixture of super suspense and authentic information on a subject of compelling interest that has been a Crichton landmark since The Andromeda Strain.,(back cover)"
|
||||
0345417623,Timeline,MICHAEL CRICHTON,2000,Ballantine Books,"In an Arizona desert, a man wanders in a daze, speaking words that make no sense. Within twenty-four hours he is dead, his body swiftly cremated by his only known associates. Halfway around the world, archaeologists make a shocking discovery at a medieval site. Suddenly they are swept off to the headquarters of a secretive multinational corporation that has developed an astounding technology. Now this group is about to get a chance not to study the past but to enter it. And with history opened up to the present, the dead awakened to the living, these men and women will soon find themselves fighting for their very survival – six hundred years ago."
|
||||
0684823802,OUT OF THE SILENT PLANET,C.S. Lewis,1996,Scribner,"Dr. Ransom is abducted by a megalomaniacal physicist and taken via space ship to the planet Malacandra (Mars). There, Dr. Ransom finds Malacandra similar to, and yet distinct from, Earth."
|
||||
0375759778,Prague : A Novel,ARTHUR PHILLIPS,2003,Random House Trade Paperbacks,"A novel of startling scope and ambition, , depicts an intentionally lost Lost Generation as it follows five American expats who come to Budapest in the early 1990s to seek their fortune. They harbor the vague suspicion that their counterparts in Prague have it better, but still they hope to find adventure, inspiration, a gold rush, or history in the making."
|
||||
0425163091,Chocolate Jesus,Stephan Jaramillo,1998,Berkley Publishing Group,"The deliciously funny new novel from the acclaimed author of Going Postal.Now, in Chocolate Jesus, Jaramillo introduces Sydney Corbet, a self-proclaimed JFK assassination scholar who has just come up with the idea of a lifetime -- Chocolate Jesus. This semisweet chocolate Messiah offers salvation for many, especially the nearly extinct Bea's Candies, whose Easter promotion just might turn things around for the company. Everyone knows that the Easter Bunny can't compete with the King of Kings. But no one counted on the Reverend Willy Domingo and his vegetarian fitness zealots, who gather on a crusade against a graven image of Christ that consists of nothing more than empty calories...,""Capture(s) the mood and voice of a certain distinctive type of apprentice grown-up"". -- New York Times Book Review,""Enormously entertaining moments, reverberating with a cynical wit underscored...with heartbreaking poignancy and disillusion...haunting, honest"". -- St. Petersburg Times,""A very funny book... Jaramillo deserves credit for a crisp and funny style, a dead-on ear for dialogue, but more impressive, an emotional honesty that's rare and wonderful"". -- Rocky Mountain News"
|
||||
0375406328,Lying Awake,Mark Salzman,2000,Alfred A. Knopf,"In a Carmelite monastery outside present-day Los Angeles, life goes on in a manner virtually un-changed for centuries. Sister John of the Cross has spent years there in the service of God. And there, she alone experiences visions of such dazzling power and insight that she is looked upon as a spiritual master. ,But Sister John's visions are accompanied by powerful headaches, and when a doctor reveals that they may be dangerous, she faces a devastating choice. For if her spiritual gifts are symptoms of illness rather than grace, will a ""cure"" mean the end of her visions and a soul once again dry and searching?,This is the dilemma at the heart of Mark Salzman's spare, astonishing new novel. With extraordinary dexterity, the author of the best-selling , and , brings to life the mysterious world of the cloister, giving us a brilliantly realized portrait of women today drawn to the rigors of an ancient religious life, and of one woman's trial at the perilous intersection of faith and reason. , is a novel of remarkable empathy and imagination, and Mark Salzman's most provocative work to date."
|
||||
0446310786,To Kill a Mockingbird,Harper Lee,1988,Little Brown & Company,"The unforgettable novel of a childhood in a sleepy Southern town and the crisis of conscience that rocked it, To Kill A Mockingbird became both an instant bestseller and a critical success when it was first published in 1960. It went on to win the Pulitzer Prize in 1961 and was later made into an Academy Award-winning film, also a classic.,Compassionate, dramatic, and deeply moving, To Kill A Mockingbird takes readers to the roots of human behavior - to innocence and experience, kindness and cruelty, love and hatred, humor and pathos. Now with over 18 million copies in print and translated into forty languages, this regional story by a young Alabama woman claims universal appeal. Harper Lee always considered her book to be a simple love story. Today it is regarded as a masterpiece of American literature."
|
||||
0449005615,Seabiscuit: An American Legend,LAURA HILLENBRAND,2002,Ballantine Books,"Seabiscuit was one of the most electrifying and popular attractions in sports history and the single biggest newsmaker in the world in 1938, receiving more coverage than FDR, Hitler, or Mussolini. But his success was a surprise to the racing establishment, which had written off the crooked-legged racehorse with the sad tail. Three men changed Seabiscuit’s fortunes:,Charles Howard was a onetime bicycle repairman who introduced the automobile to the western United States and became an overnight millionaire. When he needed a trainer for his new racehorses, he hired Tom Smith, a mysterious mustang breaker from the Colorado plains. Smith urged Howard to buy Seabiscuit for a bargain-basement price, then hired as his jockey Red Pollard, a failed boxer who was blind in one eye, half-crippled, and prone to quoting passages from Ralph Waldo Emerson. Over four years, these unlikely partners survived a phenomenal run of bad fortune, conspiracy, and severe injury to transform Seabiscuit from a neurotic, pathologically indolent also-ran into an American sports icon. ,Author Laura Hillenbrand brilliantly re-creates a universal underdog story, one that proves life is a horse race."
|
||||
0060168013,Pigs in Heaven,Barbara Kingsolver,1993,Harpercollins,"Brings together Taylor, Turtle and Alice from The Bean Trees together with a new cast - Jax, Barbie Sugar Boss, Oklahoma and Annawake Fourkiller. When six-year-old Turtle witnesses a freak accident at the Hoover Dam, her insistence, and her mother's belief in her, leads to a man's rescue."
|
Can't render this file because it has a wrong number of fields in line 2.
|
@ -1,31 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "cohere-librarian"
|
||||
version = "0.0.1"
|
||||
description = "Get started with a simple template that acts as a librarian"
|
||||
authors = []
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.8.1,<4.0"
|
||||
langchain = "^0.1"
|
||||
cohere = "^4.37"
|
||||
langchain-chroma = "^0.1.2"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
langchain-cli = ">=0.0.21"
|
||||
fastapi = ">=0.104.0,<1"
|
||||
sse-starlette = "^1.6.5"
|
||||
|
||||
[tool.langserve]
|
||||
export_module = "cohere_librarian"
|
||||
export_attr = "chain"
|
||||
|
||||
[tool.templates-hub]
|
||||
use-case = "chatbot"
|
||||
author = "Cohere"
|
||||
integrations = ["Cohere"]
|
||||
tags = ["getting-started"]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
@ -1,68 +0,0 @@
|
||||
# CSV agent
|
||||
|
||||
This template uses a [CSV agent](https://python.langchain.com/docs/integrations/toolkits/csv) with tools (Python REPL) and memory (vectorstore) for interaction (question-answering) with text data.
|
||||
|
||||
## Environment Setup
|
||||
|
||||
Set the `OPENAI_API_KEY` environment variable to access the OpenAI models.
|
||||
|
||||
To set up the environment, the `ingest.py` script should be run to handle the ingestion into a vectorstore.
|
||||
|
||||
## Usage
|
||||
|
||||
To use this package, you should first have the LangChain CLI installed:
|
||||
|
||||
```shell
|
||||
pip install -U langchain-cli
|
||||
```
|
||||
|
||||
To create a new LangChain project and install this as the only package, you can do:
|
||||
|
||||
```shell
|
||||
langchain app new my-app --package csv-agent
|
||||
```
|
||||
|
||||
If you want to add this to an existing project, you can just run:
|
||||
|
||||
```shell
|
||||
langchain app add csv-agent
|
||||
```
|
||||
|
||||
And add the following code to your `server.py` file:
|
||||
```python
|
||||
from csv_agent.agent import agent_executor as csv_agent_chain
|
||||
|
||||
add_routes(app, csv_agent_chain, path="/csv-agent")
|
||||
```
|
||||
|
||||
(Optional) Let's now configure LangSmith.
|
||||
LangSmith will help us trace, monitor and debug LangChain applications.
|
||||
You can sign up for LangSmith [here](https://smith.langchain.com/).
|
||||
If you don't have access, you can skip this section
|
||||
|
||||
|
||||
```shell
|
||||
export LANGCHAIN_TRACING_V2=true
|
||||
export LANGCHAIN_API_KEY=<your-api-key>
|
||||
export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
|
||||
```
|
||||
|
||||
If you are inside this directory, then you can spin up a LangServe instance directly by:
|
||||
|
||||
```shell
|
||||
langchain serve
|
||||
```
|
||||
|
||||
This will start the FastAPI app with a server is running locally at
|
||||
[http://localhost:8000](http://localhost:8000)
|
||||
|
||||
We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
|
||||
We can access the playground at [http://127.0.0.1:8000/csv-agent/playground](http://127.0.0.1:8000/csv-agent/playground)
|
||||
|
||||
We can access the template from code with:
|
||||
|
||||
```python
|
||||
from langserve.client import RemoteRunnable
|
||||
|
||||
runnable = RemoteRunnable("http://localhost:8000/csv-agent")
|
||||
```
|
@ -1,3 +0,0 @@
|
||||
from csv_agent.agent import agent_executor
|
||||
|
||||
__all__ = ["agent_executor"]
|
@ -1,84 +0,0 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pandas as pd
|
||||
from langchain.agents import AgentExecutor, OpenAIFunctionsAgent
|
||||
from langchain_community.chat_models import ChatOpenAI
|
||||
from langchain_community.embeddings import OpenAIEmbeddings
|
||||
from langchain_community.vectorstores import FAISS
|
||||
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
||||
from langchain_core.pydantic_v1 import BaseModel, Field
|
||||
from langchain_core.tools.retriever import create_retriever_tool
|
||||
from langchain_experimental.tools import PythonAstREPLTool
|
||||
|
||||
MAIN_DIR = Path(__file__).parents[1]
|
||||
|
||||
pd.set_option("display.max_rows", 20)
|
||||
pd.set_option("display.max_columns", 20)
|
||||
|
||||
embedding_model = OpenAIEmbeddings()
|
||||
vectorstore = FAISS.load_local(MAIN_DIR / "titanic_data", embedding_model)
|
||||
retriever_tool = create_retriever_tool(
|
||||
vectorstore.as_retriever(), "person_name_search", "Search for a person by name"
|
||||
)
|
||||
|
||||
|
||||
TEMPLATE = """You are working with a pandas dataframe in Python. The name of the dataframe is `df`.
|
||||
It is important to understand the attributes of the dataframe before working with it. This is the result of running `df.head().to_markdown()`
|
||||
|
||||
<df>
|
||||
{dhead}
|
||||
</df>
|
||||
|
||||
You are not meant to use only these rows to answer questions - they are meant as a way of telling you about the shape and schema of the dataframe.
|
||||
You also do not have use only the information here to answer questions - you can run intermediate queries to do exporatory data analysis to give you more information as needed.
|
||||
|
||||
You have a tool called `person_name_search` through which you can lookup a person by name and find the records corresponding to people with similar name as the query.
|
||||
You should only really use this if your search term contains a persons name. Otherwise, try to solve it with code.
|
||||
|
||||
For example:
|
||||
|
||||
<question>How old is Jane?</question>
|
||||
<logic>Use `person_name_search` since you can use the query `Jane`</logic>
|
||||
|
||||
<question>Who has id 320</question>
|
||||
<logic>Use `python_repl` since even though the question is about a person, you don't know their name so you can't include it.</logic>
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
class PythonInputs(BaseModel):
|
||||
query: str = Field(description="code snippet to run")
|
||||
|
||||
|
||||
df = pd.read_csv(MAIN_DIR / "titanic.csv")
|
||||
template = TEMPLATE.format(dhead=df.head().to_markdown())
|
||||
|
||||
prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
("system", template),
|
||||
MessagesPlaceholder(variable_name="agent_scratchpad"),
|
||||
("human", "{input}"),
|
||||
]
|
||||
)
|
||||
|
||||
repl = PythonAstREPLTool(
|
||||
locals={"df": df},
|
||||
name="python_repl",
|
||||
description="Runs code and returns the output of the final line",
|
||||
args_schema=PythonInputs,
|
||||
)
|
||||
tools = [repl, retriever_tool]
|
||||
agent = OpenAIFunctionsAgent(
|
||||
llm=ChatOpenAI(temperature=0, model="gpt-4"), prompt=prompt, tools=tools
|
||||
)
|
||||
agent_executor = AgentExecutor(
|
||||
agent=agent, tools=tools, max_iterations=5, early_stopping_method="generate"
|
||||
) | (lambda x: x["output"])
|
||||
|
||||
# Typing for playground inputs
|
||||
|
||||
|
||||
class AgentInputs(BaseModel):
|
||||
input: str
|
||||
|
||||
|
||||
agent_executor = agent_executor.with_types(input_type=AgentInputs)
|
@ -1,12 +0,0 @@
|
||||
from langchain.indexes import VectorstoreIndexCreator
|
||||
from langchain_community.document_loaders import CSVLoader
|
||||
from langchain_community.vectorstores import FAISS
|
||||
|
||||
loader = CSVLoader("/Users/harrisonchase/Downloads/titanic.csv")
|
||||
|
||||
docs = loader.load()
|
||||
index_creator = VectorstoreIndexCreator(vectorstore_cls=FAISS)
|
||||
|
||||
index = index_creator.from_documents(docs)
|
||||
|
||||
index.vectorstore.save_local("titanic_data")
|
@ -1,5 +0,0 @@
|
||||
from csv_agent.agent import agent_executor
|
||||
|
||||
if __name__ == "__main__":
|
||||
question = "who was in cabin c28?"
|
||||
print(agent_executor.invoke({"input": question}))
|
@ -1,37 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "csv-agent"
|
||||
version = "0.0.1"
|
||||
description = "Analyze csv data with Pandas and OpenAI"
|
||||
authors = []
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.9,<3.13"
|
||||
langchain = "^0.1"
|
||||
openai = "<2"
|
||||
tiktoken = "^0.5.1"
|
||||
faiss-cpu = "^1.7.4"
|
||||
pandas = "^2.1.1"
|
||||
setuptools = "^68.2.2"
|
||||
tabulate = "^0.9.0"
|
||||
pydantic = "<2"
|
||||
langchain-experimental = ">=0.0.54"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
langchain-cli = ">=0.0.21"
|
||||
|
||||
[tool.langserve]
|
||||
export_module = "csv_agent"
|
||||
export_attr = "agent_executor"
|
||||
|
||||
[tool.templates-hub]
|
||||
use-case = "question-answering"
|
||||
author = "LangChain"
|
||||
integrations = ["OpenAI", "Pandas"]
|
||||
tags = ["data", "agents"]
|
||||
|
||||
[build-system]
|
||||
requires = [
|
||||
"poetry-core",
|
||||
]
|
||||
build-backend = "poetry.core.masonry.api"
|
@ -1,892 +0,0 @@
|
||||
PassengerId,Survived,Pclass,Name,Sex,Age,SibSp,Parch,Ticket,Fare,Cabin,Embarked
|
||||
1,0,3,"Braund, Mr. Owen Harris",male,22,1,0,A/5 21171,7.25,,S
|
||||
2,1,1,"Cumings, Mrs. John Bradley (Florence Briggs Thayer)",female,38,1,0,PC 17599,71.2833,C85,C
|
||||
3,1,3,"Heikkinen, Miss. Laina",female,26,0,0,STON/O2. 3101282,7.925,,S
|
||||
4,1,1,"Futrelle, Mrs. Jacques Heath (Lily May Peel)",female,35,1,0,113803,53.1,C123,S
|
||||
5,0,3,"Allen, Mr. William Henry",male,35,0,0,373450,8.05,,S
|
||||
6,0,3,"Moran, Mr. James",male,,0,0,330877,8.4583,,Q
|
||||
7,0,1,"McCarthy, Mr. Timothy J",male,54,0,0,17463,51.8625,E46,S
|
||||
8,0,3,"Palsson, Master. Gosta Leonard",male,2,3,1,349909,21.075,,S
|
||||
9,1,3,"Johnson, Mrs. Oscar W (Elisabeth Vilhelmina Berg)",female,27,0,2,347742,11.1333,,S
|
||||
10,1,2,"Nasser, Mrs. Nicholas (Adele Achem)",female,14,1,0,237736,30.0708,,C
|
||||
11,1,3,"Sandstrom, Miss. Marguerite Rut",female,4,1,1,PP 9549,16.7,G6,S
|
||||
12,1,1,"Bonnell, Miss. Elizabeth",female,58,0,0,113783,26.55,C103,S
|
||||
13,0,3,"Saundercock, Mr. William Henry",male,20,0,0,A/5. 2151,8.05,,S
|
||||
14,0,3,"Andersson, Mr. Anders Johan",male,39,1,5,347082,31.275,,S
|
||||
15,0,3,"Vestrom, Miss. Hulda Amanda Adolfina",female,14,0,0,350406,7.8542,,S
|
||||
16,1,2,"Hewlett, Mrs. (Mary D Kingcome) ",female,55,0,0,248706,16,,S
|
||||
17,0,3,"Rice, Master. Eugene",male,2,4,1,382652,29.125,,Q
|
||||
18,1,2,"Williams, Mr. Charles Eugene",male,,0,0,244373,13,,S
|
||||
19,0,3,"Vander Planke, Mrs. Julius (Emelia Maria Vandemoortele)",female,31,1,0,345763,18,,S
|
||||
20,1,3,"Masselmani, Mrs. Fatima",female,,0,0,2649,7.225,,C
|
||||
21,0,2,"Fynney, Mr. Joseph J",male,35,0,0,239865,26,,S
|
||||
22,1,2,"Beesley, Mr. Lawrence",male,34,0,0,248698,13,D56,S
|
||||
23,1,3,"McGowan, Miss. Anna ""Annie""",female,15,0,0,330923,8.0292,,Q
|
||||
24,1,1,"Sloper, Mr. William Thompson",male,28,0,0,113788,35.5,A6,S
|
||||
25,0,3,"Palsson, Miss. Torborg Danira",female,8,3,1,349909,21.075,,S
|
||||
26,1,3,"Asplund, Mrs. Carl Oscar (Selma Augusta Emilia Johansson)",female,38,1,5,347077,31.3875,,S
|
||||
27,0,3,"Emir, Mr. Farred Chehab",male,,0,0,2631,7.225,,C
|
||||
28,0,1,"Fortune, Mr. Charles Alexander",male,19,3,2,19950,263,C23 C25 C27,S
|
||||
29,1,3,"O'Dwyer, Miss. Ellen ""Nellie""",female,,0,0,330959,7.8792,,Q
|
||||
30,0,3,"Todoroff, Mr. Lalio",male,,0,0,349216,7.8958,,S
|
||||
31,0,1,"Uruchurtu, Don. Manuel E",male,40,0,0,PC 17601,27.7208,,C
|
||||
32,1,1,"Spencer, Mrs. William Augustus (Marie Eugenie)",female,,1,0,PC 17569,146.5208,B78,C
|
||||
33,1,3,"Glynn, Miss. Mary Agatha",female,,0,0,335677,7.75,,Q
|
||||
34,0,2,"Wheadon, Mr. Edward H",male,66,0,0,C.A. 24579,10.5,,S
|
||||
35,0,1,"Meyer, Mr. Edgar Joseph",male,28,1,0,PC 17604,82.1708,,C
|
||||
36,0,1,"Holverson, Mr. Alexander Oskar",male,42,1,0,113789,52,,S
|
||||
37,1,3,"Mamee, Mr. Hanna",male,,0,0,2677,7.2292,,C
|
||||
38,0,3,"Cann, Mr. Ernest Charles",male,21,0,0,A./5. 2152,8.05,,S
|
||||
39,0,3,"Vander Planke, Miss. Augusta Maria",female,18,2,0,345764,18,,S
|
||||
40,1,3,"Nicola-Yarred, Miss. Jamila",female,14,1,0,2651,11.2417,,C
|
||||
41,0,3,"Ahlin, Mrs. Johan (Johanna Persdotter Larsson)",female,40,1,0,7546,9.475,,S
|
||||
42,0,2,"Turpin, Mrs. William John Robert (Dorothy Ann Wonnacott)",female,27,1,0,11668,21,,S
|
||||
43,0,3,"Kraeff, Mr. Theodor",male,,0,0,349253,7.8958,,C
|
||||
44,1,2,"Laroche, Miss. Simonne Marie Anne Andree",female,3,1,2,SC/Paris 2123,41.5792,,C
|
||||
45,1,3,"Devaney, Miss. Margaret Delia",female,19,0,0,330958,7.8792,,Q
|
||||
46,0,3,"Rogers, Mr. William John",male,,0,0,S.C./A.4. 23567,8.05,,S
|
||||
47,0,3,"Lennon, Mr. Denis",male,,1,0,370371,15.5,,Q
|
||||
48,1,3,"O'Driscoll, Miss. Bridget",female,,0,0,14311,7.75,,Q
|
||||
49,0,3,"Samaan, Mr. Youssef",male,,2,0,2662,21.6792,,C
|
||||
50,0,3,"Arnold-Franchi, Mrs. Josef (Josefine Franchi)",female,18,1,0,349237,17.8,,S
|
||||
51,0,3,"Panula, Master. Juha Niilo",male,7,4,1,3101295,39.6875,,S
|
||||
52,0,3,"Nosworthy, Mr. Richard Cater",male,21,0,0,A/4. 39886,7.8,,S
|
||||
53,1,1,"Harper, Mrs. Henry Sleeper (Myna Haxtun)",female,49,1,0,PC 17572,76.7292,D33,C
|
||||
54,1,2,"Faunthorpe, Mrs. Lizzie (Elizabeth Anne Wilkinson)",female,29,1,0,2926,26,,S
|
||||
55,0,1,"Ostby, Mr. Engelhart Cornelius",male,65,0,1,113509,61.9792,B30,C
|
||||
56,1,1,"Woolner, Mr. Hugh",male,,0,0,19947,35.5,C52,S
|
||||
57,1,2,"Rugg, Miss. Emily",female,21,0,0,C.A. 31026,10.5,,S
|
||||
58,0,3,"Novel, Mr. Mansouer",male,28.5,0,0,2697,7.2292,,C
|
||||
59,1,2,"West, Miss. Constance Mirium",female,5,1,2,C.A. 34651,27.75,,S
|
||||
60,0,3,"Goodwin, Master. William Frederick",male,11,5,2,CA 2144,46.9,,S
|
||||
61,0,3,"Sirayanian, Mr. Orsen",male,22,0,0,2669,7.2292,,C
|
||||
62,1,1,"Icard, Miss. Amelie",female,38,0,0,113572,80,B28,
|
||||
63,0,1,"Harris, Mr. Henry Birkhardt",male,45,1,0,36973,83.475,C83,S
|
||||
64,0,3,"Skoog, Master. Harald",male,4,3,2,347088,27.9,,S
|
||||
65,0,1,"Stewart, Mr. Albert A",male,,0,0,PC 17605,27.7208,,C
|
||||
66,1,3,"Moubarek, Master. Gerios",male,,1,1,2661,15.2458,,C
|
||||
67,1,2,"Nye, Mrs. (Elizabeth Ramell)",female,29,0,0,C.A. 29395,10.5,F33,S
|
||||
68,0,3,"Crease, Mr. Ernest James",male,19,0,0,S.P. 3464,8.1583,,S
|
||||
69,1,3,"Andersson, Miss. Erna Alexandra",female,17,4,2,3101281,7.925,,S
|
||||
70,0,3,"Kink, Mr. Vincenz",male,26,2,0,315151,8.6625,,S
|
||||
71,0,2,"Jenkin, Mr. Stephen Curnow",male,32,0,0,C.A. 33111,10.5,,S
|
||||
72,0,3,"Goodwin, Miss. Lillian Amy",female,16,5,2,CA 2144,46.9,,S
|
||||
73,0,2,"Hood, Mr. Ambrose Jr",male,21,0,0,S.O.C. 14879,73.5,,S
|
||||
74,0,3,"Chronopoulos, Mr. Apostolos",male,26,1,0,2680,14.4542,,C
|
||||
75,1,3,"Bing, Mr. Lee",male,32,0,0,1601,56.4958,,S
|
||||
76,0,3,"Moen, Mr. Sigurd Hansen",male,25,0,0,348123,7.65,F G73,S
|
||||
77,0,3,"Staneff, Mr. Ivan",male,,0,0,349208,7.8958,,S
|
||||
78,0,3,"Moutal, Mr. Rahamin Haim",male,,0,0,374746,8.05,,S
|
||||
79,1,2,"Caldwell, Master. Alden Gates",male,0.83,0,2,248738,29,,S
|
||||
80,1,3,"Dowdell, Miss. Elizabeth",female,30,0,0,364516,12.475,,S
|
||||
81,0,3,"Waelens, Mr. Achille",male,22,0,0,345767,9,,S
|
||||
82,1,3,"Sheerlinck, Mr. Jan Baptist",male,29,0,0,345779,9.5,,S
|
||||
83,1,3,"McDermott, Miss. Brigdet Delia",female,,0,0,330932,7.7875,,Q
|
||||
84,0,1,"Carrau, Mr. Francisco M",male,28,0,0,113059,47.1,,S
|
||||
85,1,2,"Ilett, Miss. Bertha",female,17,0,0,SO/C 14885,10.5,,S
|
||||
86,1,3,"Backstrom, Mrs. Karl Alfred (Maria Mathilda Gustafsson)",female,33,3,0,3101278,15.85,,S
|
||||
87,0,3,"Ford, Mr. William Neal",male,16,1,3,W./C. 6608,34.375,,S
|
||||
88,0,3,"Slocovski, Mr. Selman Francis",male,,0,0,SOTON/OQ 392086,8.05,,S
|
||||
89,1,1,"Fortune, Miss. Mabel Helen",female,23,3,2,19950,263,C23 C25 C27,S
|
||||
90,0,3,"Celotti, Mr. Francesco",male,24,0,0,343275,8.05,,S
|
||||
91,0,3,"Christmann, Mr. Emil",male,29,0,0,343276,8.05,,S
|
||||
92,0,3,"Andreasson, Mr. Paul Edvin",male,20,0,0,347466,7.8542,,S
|
||||
93,0,1,"Chaffee, Mr. Herbert Fuller",male,46,1,0,W.E.P. 5734,61.175,E31,S
|
||||
94,0,3,"Dean, Mr. Bertram Frank",male,26,1,2,C.A. 2315,20.575,,S
|
||||
95,0,3,"Coxon, Mr. Daniel",male,59,0,0,364500,7.25,,S
|
||||
96,0,3,"Shorney, Mr. Charles Joseph",male,,0,0,374910,8.05,,S
|
||||
97,0,1,"Goldschmidt, Mr. George B",male,71,0,0,PC 17754,34.6542,A5,C
|
||||
98,1,1,"Greenfield, Mr. William Bertram",male,23,0,1,PC 17759,63.3583,D10 D12,C
|
||||
99,1,2,"Doling, Mrs. John T (Ada Julia Bone)",female,34,0,1,231919,23,,S
|
||||
100,0,2,"Kantor, Mr. Sinai",male,34,1,0,244367,26,,S
|
||||
101,0,3,"Petranec, Miss. Matilda",female,28,0,0,349245,7.8958,,S
|
||||
102,0,3,"Petroff, Mr. Pastcho (""Pentcho"")",male,,0,0,349215,7.8958,,S
|
||||
103,0,1,"White, Mr. Richard Frasar",male,21,0,1,35281,77.2875,D26,S
|
||||
104,0,3,"Johansson, Mr. Gustaf Joel",male,33,0,0,7540,8.6542,,S
|
||||
105,0,3,"Gustafsson, Mr. Anders Vilhelm",male,37,2,0,3101276,7.925,,S
|
||||
106,0,3,"Mionoff, Mr. Stoytcho",male,28,0,0,349207,7.8958,,S
|
||||
107,1,3,"Salkjelsvik, Miss. Anna Kristine",female,21,0,0,343120,7.65,,S
|
||||
108,1,3,"Moss, Mr. Albert Johan",male,,0,0,312991,7.775,,S
|
||||
109,0,3,"Rekic, Mr. Tido",male,38,0,0,349249,7.8958,,S
|
||||
110,1,3,"Moran, Miss. Bertha",female,,1,0,371110,24.15,,Q
|
||||
111,0,1,"Porter, Mr. Walter Chamberlain",male,47,0,0,110465,52,C110,S
|
||||
112,0,3,"Zabour, Miss. Hileni",female,14.5,1,0,2665,14.4542,,C
|
||||
113,0,3,"Barton, Mr. David John",male,22,0,0,324669,8.05,,S
|
||||
114,0,3,"Jussila, Miss. Katriina",female,20,1,0,4136,9.825,,S
|
||||
115,0,3,"Attalah, Miss. Malake",female,17,0,0,2627,14.4583,,C
|
||||
116,0,3,"Pekoniemi, Mr. Edvard",male,21,0,0,STON/O 2. 3101294,7.925,,S
|
||||
117,0,3,"Connors, Mr. Patrick",male,70.5,0,0,370369,7.75,,Q
|
||||
118,0,2,"Turpin, Mr. William John Robert",male,29,1,0,11668,21,,S
|
||||
119,0,1,"Baxter, Mr. Quigg Edmond",male,24,0,1,PC 17558,247.5208,B58 B60,C
|
||||
120,0,3,"Andersson, Miss. Ellis Anna Maria",female,2,4,2,347082,31.275,,S
|
||||
121,0,2,"Hickman, Mr. Stanley George",male,21,2,0,S.O.C. 14879,73.5,,S
|
||||
122,0,3,"Moore, Mr. Leonard Charles",male,,0,0,A4. 54510,8.05,,S
|
||||
123,0,2,"Nasser, Mr. Nicholas",male,32.5,1,0,237736,30.0708,,C
|
||||
124,1,2,"Webber, Miss. Susan",female,32.5,0,0,27267,13,E101,S
|
||||
125,0,1,"White, Mr. Percival Wayland",male,54,0,1,35281,77.2875,D26,S
|
||||
126,1,3,"Nicola-Yarred, Master. Elias",male,12,1,0,2651,11.2417,,C
|
||||
127,0,3,"McMahon, Mr. Martin",male,,0,0,370372,7.75,,Q
|
||||
128,1,3,"Madsen, Mr. Fridtjof Arne",male,24,0,0,C 17369,7.1417,,S
|
||||
129,1,3,"Peter, Miss. Anna",female,,1,1,2668,22.3583,F E69,C
|
||||
130,0,3,"Ekstrom, Mr. Johan",male,45,0,0,347061,6.975,,S
|
||||
131,0,3,"Drazenoic, Mr. Jozef",male,33,0,0,349241,7.8958,,C
|
||||
132,0,3,"Coelho, Mr. Domingos Fernandeo",male,20,0,0,SOTON/O.Q. 3101307,7.05,,S
|
||||
133,0,3,"Robins, Mrs. Alexander A (Grace Charity Laury)",female,47,1,0,A/5. 3337,14.5,,S
|
||||
134,1,2,"Weisz, Mrs. Leopold (Mathilde Francoise Pede)",female,29,1,0,228414,26,,S
|
||||
135,0,2,"Sobey, Mr. Samuel James Hayden",male,25,0,0,C.A. 29178,13,,S
|
||||
136,0,2,"Richard, Mr. Emile",male,23,0,0,SC/PARIS 2133,15.0458,,C
|
||||
137,1,1,"Newsom, Miss. Helen Monypeny",female,19,0,2,11752,26.2833,D47,S
|
||||
138,0,1,"Futrelle, Mr. Jacques Heath",male,37,1,0,113803,53.1,C123,S
|
||||
139,0,3,"Osen, Mr. Olaf Elon",male,16,0,0,7534,9.2167,,S
|
||||
140,0,1,"Giglio, Mr. Victor",male,24,0,0,PC 17593,79.2,B86,C
|
||||
141,0,3,"Boulos, Mrs. Joseph (Sultana)",female,,0,2,2678,15.2458,,C
|
||||
142,1,3,"Nysten, Miss. Anna Sofia",female,22,0,0,347081,7.75,,S
|
||||
143,1,3,"Hakkarainen, Mrs. Pekka Pietari (Elin Matilda Dolck)",female,24,1,0,STON/O2. 3101279,15.85,,S
|
||||
144,0,3,"Burke, Mr. Jeremiah",male,19,0,0,365222,6.75,,Q
|
||||
145,0,2,"Andrew, Mr. Edgardo Samuel",male,18,0,0,231945,11.5,,S
|
||||
146,0,2,"Nicholls, Mr. Joseph Charles",male,19,1,1,C.A. 33112,36.75,,S
|
||||
147,1,3,"Andersson, Mr. August Edvard (""Wennerstrom"")",male,27,0,0,350043,7.7958,,S
|
||||
148,0,3,"Ford, Miss. Robina Maggie ""Ruby""",female,9,2,2,W./C. 6608,34.375,,S
|
||||
149,0,2,"Navratil, Mr. Michel (""Louis M Hoffman"")",male,36.5,0,2,230080,26,F2,S
|
||||
150,0,2,"Byles, Rev. Thomas Roussel Davids",male,42,0,0,244310,13,,S
|
||||
151,0,2,"Bateman, Rev. Robert James",male,51,0,0,S.O.P. 1166,12.525,,S
|
||||
152,1,1,"Pears, Mrs. Thomas (Edith Wearne)",female,22,1,0,113776,66.6,C2,S
|
||||
153,0,3,"Meo, Mr. Alfonzo",male,55.5,0,0,A.5. 11206,8.05,,S
|
||||
154,0,3,"van Billiard, Mr. Austin Blyler",male,40.5,0,2,A/5. 851,14.5,,S
|
||||
155,0,3,"Olsen, Mr. Ole Martin",male,,0,0,Fa 265302,7.3125,,S
|
||||
156,0,1,"Williams, Mr. Charles Duane",male,51,0,1,PC 17597,61.3792,,C
|
||||
157,1,3,"Gilnagh, Miss. Katherine ""Katie""",female,16,0,0,35851,7.7333,,Q
|
||||
158,0,3,"Corn, Mr. Harry",male,30,0,0,SOTON/OQ 392090,8.05,,S
|
||||
159,0,3,"Smiljanic, Mr. Mile",male,,0,0,315037,8.6625,,S
|
||||
160,0,3,"Sage, Master. Thomas Henry",male,,8,2,CA. 2343,69.55,,S
|
||||
161,0,3,"Cribb, Mr. John Hatfield",male,44,0,1,371362,16.1,,S
|
||||
162,1,2,"Watt, Mrs. James (Elizabeth ""Bessie"" Inglis Milne)",female,40,0,0,C.A. 33595,15.75,,S
|
||||
163,0,3,"Bengtsson, Mr. John Viktor",male,26,0,0,347068,7.775,,S
|
||||
164,0,3,"Calic, Mr. Jovo",male,17,0,0,315093,8.6625,,S
|
||||
165,0,3,"Panula, Master. Eino Viljami",male,1,4,1,3101295,39.6875,,S
|
||||
166,1,3,"Goldsmith, Master. Frank John William ""Frankie""",male,9,0,2,363291,20.525,,S
|
||||
167,1,1,"Chibnall, Mrs. (Edith Martha Bowerman)",female,,0,1,113505,55,E33,S
|
||||
168,0,3,"Skoog, Mrs. William (Anna Bernhardina Karlsson)",female,45,1,4,347088,27.9,,S
|
||||
169,0,1,"Baumann, Mr. John D",male,,0,0,PC 17318,25.925,,S
|
||||
170,0,3,"Ling, Mr. Lee",male,28,0,0,1601,56.4958,,S
|
||||
171,0,1,"Van der hoef, Mr. Wyckoff",male,61,0,0,111240,33.5,B19,S
|
||||
172,0,3,"Rice, Master. Arthur",male,4,4,1,382652,29.125,,Q
|
||||
173,1,3,"Johnson, Miss. Eleanor Ileen",female,1,1,1,347742,11.1333,,S
|
||||
174,0,3,"Sivola, Mr. Antti Wilhelm",male,21,0,0,STON/O 2. 3101280,7.925,,S
|
||||
175,0,1,"Smith, Mr. James Clinch",male,56,0,0,17764,30.6958,A7,C
|
||||
176,0,3,"Klasen, Mr. Klas Albin",male,18,1,1,350404,7.8542,,S
|
||||
177,0,3,"Lefebre, Master. Henry Forbes",male,,3,1,4133,25.4667,,S
|
||||
178,0,1,"Isham, Miss. Ann Elizabeth",female,50,0,0,PC 17595,28.7125,C49,C
|
||||
179,0,2,"Hale, Mr. Reginald",male,30,0,0,250653,13,,S
|
||||
180,0,3,"Leonard, Mr. Lionel",male,36,0,0,LINE,0,,S
|
||||
181,0,3,"Sage, Miss. Constance Gladys",female,,8,2,CA. 2343,69.55,,S
|
||||
182,0,2,"Pernot, Mr. Rene",male,,0,0,SC/PARIS 2131,15.05,,C
|
||||
183,0,3,"Asplund, Master. Clarence Gustaf Hugo",male,9,4,2,347077,31.3875,,S
|
||||
184,1,2,"Becker, Master. Richard F",male,1,2,1,230136,39,F4,S
|
||||
185,1,3,"Kink-Heilmann, Miss. Luise Gretchen",female,4,0,2,315153,22.025,,S
|
||||
186,0,1,"Rood, Mr. Hugh Roscoe",male,,0,0,113767,50,A32,S
|
||||
187,1,3,"O'Brien, Mrs. Thomas (Johanna ""Hannah"" Godfrey)",female,,1,0,370365,15.5,,Q
|
||||
188,1,1,"Romaine, Mr. Charles Hallace (""Mr C Rolmane"")",male,45,0,0,111428,26.55,,S
|
||||
189,0,3,"Bourke, Mr. John",male,40,1,1,364849,15.5,,Q
|
||||
190,0,3,"Turcin, Mr. Stjepan",male,36,0,0,349247,7.8958,,S
|
||||
191,1,2,"Pinsky, Mrs. (Rosa)",female,32,0,0,234604,13,,S
|
||||
192,0,2,"Carbines, Mr. William",male,19,0,0,28424,13,,S
|
||||
193,1,3,"Andersen-Jensen, Miss. Carla Christine Nielsine",female,19,1,0,350046,7.8542,,S
|
||||
194,1,2,"Navratil, Master. Michel M",male,3,1,1,230080,26,F2,S
|
||||
195,1,1,"Brown, Mrs. James Joseph (Margaret Tobin)",female,44,0,0,PC 17610,27.7208,B4,C
|
||||
196,1,1,"Lurette, Miss. Elise",female,58,0,0,PC 17569,146.5208,B80,C
|
||||
197,0,3,"Mernagh, Mr. Robert",male,,0,0,368703,7.75,,Q
|
||||
198,0,3,"Olsen, Mr. Karl Siegwart Andreas",male,42,0,1,4579,8.4042,,S
|
||||
199,1,3,"Madigan, Miss. Margaret ""Maggie""",female,,0,0,370370,7.75,,Q
|
||||
200,0,2,"Yrois, Miss. Henriette (""Mrs Harbeck"")",female,24,0,0,248747,13,,S
|
||||
201,0,3,"Vande Walle, Mr. Nestor Cyriel",male,28,0,0,345770,9.5,,S
|
||||
202,0,3,"Sage, Mr. Frederick",male,,8,2,CA. 2343,69.55,,S
|
||||
203,0,3,"Johanson, Mr. Jakob Alfred",male,34,0,0,3101264,6.4958,,S
|
||||
204,0,3,"Youseff, Mr. Gerious",male,45.5,0,0,2628,7.225,,C
|
||||
205,1,3,"Cohen, Mr. Gurshon ""Gus""",male,18,0,0,A/5 3540,8.05,,S
|
||||
206,0,3,"Strom, Miss. Telma Matilda",female,2,0,1,347054,10.4625,G6,S
|
||||
207,0,3,"Backstrom, Mr. Karl Alfred",male,32,1,0,3101278,15.85,,S
|
||||
208,1,3,"Albimona, Mr. Nassef Cassem",male,26,0,0,2699,18.7875,,C
|
||||
209,1,3,"Carr, Miss. Helen ""Ellen""",female,16,0,0,367231,7.75,,Q
|
||||
210,1,1,"Blank, Mr. Henry",male,40,0,0,112277,31,A31,C
|
||||
211,0,3,"Ali, Mr. Ahmed",male,24,0,0,SOTON/O.Q. 3101311,7.05,,S
|
||||
212,1,2,"Cameron, Miss. Clear Annie",female,35,0,0,F.C.C. 13528,21,,S
|
||||
213,0,3,"Perkin, Mr. John Henry",male,22,0,0,A/5 21174,7.25,,S
|
||||
214,0,2,"Givard, Mr. Hans Kristensen",male,30,0,0,250646,13,,S
|
||||
215,0,3,"Kiernan, Mr. Philip",male,,1,0,367229,7.75,,Q
|
||||
216,1,1,"Newell, Miss. Madeleine",female,31,1,0,35273,113.275,D36,C
|
||||
217,1,3,"Honkanen, Miss. Eliina",female,27,0,0,STON/O2. 3101283,7.925,,S
|
||||
218,0,2,"Jacobsohn, Mr. Sidney Samuel",male,42,1,0,243847,27,,S
|
||||
219,1,1,"Bazzani, Miss. Albina",female,32,0,0,11813,76.2917,D15,C
|
||||
220,0,2,"Harris, Mr. Walter",male,30,0,0,W/C 14208,10.5,,S
|
||||
221,1,3,"Sunderland, Mr. Victor Francis",male,16,0,0,SOTON/OQ 392089,8.05,,S
|
||||
222,0,2,"Bracken, Mr. James H",male,27,0,0,220367,13,,S
|
||||
223,0,3,"Green, Mr. George Henry",male,51,0,0,21440,8.05,,S
|
||||
224,0,3,"Nenkoff, Mr. Christo",male,,0,0,349234,7.8958,,S
|
||||
225,1,1,"Hoyt, Mr. Frederick Maxfield",male,38,1,0,19943,90,C93,S
|
||||
226,0,3,"Berglund, Mr. Karl Ivar Sven",male,22,0,0,PP 4348,9.35,,S
|
||||
227,1,2,"Mellors, Mr. William John",male,19,0,0,SW/PP 751,10.5,,S
|
||||
228,0,3,"Lovell, Mr. John Hall (""Henry"")",male,20.5,0,0,A/5 21173,7.25,,S
|
||||
229,0,2,"Fahlstrom, Mr. Arne Jonas",male,18,0,0,236171,13,,S
|
||||
230,0,3,"Lefebre, Miss. Mathilde",female,,3,1,4133,25.4667,,S
|
||||
231,1,1,"Harris, Mrs. Henry Birkhardt (Irene Wallach)",female,35,1,0,36973,83.475,C83,S
|
||||
232,0,3,"Larsson, Mr. Bengt Edvin",male,29,0,0,347067,7.775,,S
|
||||
233,0,2,"Sjostedt, Mr. Ernst Adolf",male,59,0,0,237442,13.5,,S
|
||||
234,1,3,"Asplund, Miss. Lillian Gertrud",female,5,4,2,347077,31.3875,,S
|
||||
235,0,2,"Leyson, Mr. Robert William Norman",male,24,0,0,C.A. 29566,10.5,,S
|
||||
236,0,3,"Harknett, Miss. Alice Phoebe",female,,0,0,W./C. 6609,7.55,,S
|
||||
237,0,2,"Hold, Mr. Stephen",male,44,1,0,26707,26,,S
|
||||
238,1,2,"Collyer, Miss. Marjorie ""Lottie""",female,8,0,2,C.A. 31921,26.25,,S
|
||||
239,0,2,"Pengelly, Mr. Frederick William",male,19,0,0,28665,10.5,,S
|
||||
240,0,2,"Hunt, Mr. George Henry",male,33,0,0,SCO/W 1585,12.275,,S
|
||||
241,0,3,"Zabour, Miss. Thamine",female,,1,0,2665,14.4542,,C
|
||||
242,1,3,"Murphy, Miss. Katherine ""Kate""",female,,1,0,367230,15.5,,Q
|
||||
243,0,2,"Coleridge, Mr. Reginald Charles",male,29,0,0,W./C. 14263,10.5,,S
|
||||
244,0,3,"Maenpaa, Mr. Matti Alexanteri",male,22,0,0,STON/O 2. 3101275,7.125,,S
|
||||
245,0,3,"Attalah, Mr. Sleiman",male,30,0,0,2694,7.225,,C
|
||||
246,0,1,"Minahan, Dr. William Edward",male,44,2,0,19928,90,C78,Q
|
||||
247,0,3,"Lindahl, Miss. Agda Thorilda Viktoria",female,25,0,0,347071,7.775,,S
|
||||
248,1,2,"Hamalainen, Mrs. William (Anna)",female,24,0,2,250649,14.5,,S
|
||||
249,1,1,"Beckwith, Mr. Richard Leonard",male,37,1,1,11751,52.5542,D35,S
|
||||
250,0,2,"Carter, Rev. Ernest Courtenay",male,54,1,0,244252,26,,S
|
||||
251,0,3,"Reed, Mr. James George",male,,0,0,362316,7.25,,S
|
||||
252,0,3,"Strom, Mrs. Wilhelm (Elna Matilda Persson)",female,29,1,1,347054,10.4625,G6,S
|
||||
253,0,1,"Stead, Mr. William Thomas",male,62,0,0,113514,26.55,C87,S
|
||||
254,0,3,"Lobb, Mr. William Arthur",male,30,1,0,A/5. 3336,16.1,,S
|
||||
255,0,3,"Rosblom, Mrs. Viktor (Helena Wilhelmina)",female,41,0,2,370129,20.2125,,S
|
||||
256,1,3,"Touma, Mrs. Darwis (Hanne Youssef Razi)",female,29,0,2,2650,15.2458,,C
|
||||
257,1,1,"Thorne, Mrs. Gertrude Maybelle",female,,0,0,PC 17585,79.2,,C
|
||||
258,1,1,"Cherry, Miss. Gladys",female,30,0,0,110152,86.5,B77,S
|
||||
259,1,1,"Ward, Miss. Anna",female,35,0,0,PC 17755,512.3292,,C
|
||||
260,1,2,"Parrish, Mrs. (Lutie Davis)",female,50,0,1,230433,26,,S
|
||||
261,0,3,"Smith, Mr. Thomas",male,,0,0,384461,7.75,,Q
|
||||
262,1,3,"Asplund, Master. Edvin Rojj Felix",male,3,4,2,347077,31.3875,,S
|
||||
263,0,1,"Taussig, Mr. Emil",male,52,1,1,110413,79.65,E67,S
|
||||
264,0,1,"Harrison, Mr. William",male,40,0,0,112059,0,B94,S
|
||||
265,0,3,"Henry, Miss. Delia",female,,0,0,382649,7.75,,Q
|
||||
266,0,2,"Reeves, Mr. David",male,36,0,0,C.A. 17248,10.5,,S
|
||||
267,0,3,"Panula, Mr. Ernesti Arvid",male,16,4,1,3101295,39.6875,,S
|
||||
268,1,3,"Persson, Mr. Ernst Ulrik",male,25,1,0,347083,7.775,,S
|
||||
269,1,1,"Graham, Mrs. William Thompson (Edith Junkins)",female,58,0,1,PC 17582,153.4625,C125,S
|
||||
270,1,1,"Bissette, Miss. Amelia",female,35,0,0,PC 17760,135.6333,C99,S
|
||||
271,0,1,"Cairns, Mr. Alexander",male,,0,0,113798,31,,S
|
||||
272,1,3,"Tornquist, Mr. William Henry",male,25,0,0,LINE,0,,S
|
||||
273,1,2,"Mellinger, Mrs. (Elizabeth Anne Maidment)",female,41,0,1,250644,19.5,,S
|
||||
274,0,1,"Natsch, Mr. Charles H",male,37,0,1,PC 17596,29.7,C118,C
|
||||
275,1,3,"Healy, Miss. Hanora ""Nora""",female,,0,0,370375,7.75,,Q
|
||||
276,1,1,"Andrews, Miss. Kornelia Theodosia",female,63,1,0,13502,77.9583,D7,S
|
||||
277,0,3,"Lindblom, Miss. Augusta Charlotta",female,45,0,0,347073,7.75,,S
|
||||
278,0,2,"Parkes, Mr. Francis ""Frank""",male,,0,0,239853,0,,S
|
||||
279,0,3,"Rice, Master. Eric",male,7,4,1,382652,29.125,,Q
|
||||
280,1,3,"Abbott, Mrs. Stanton (Rosa Hunt)",female,35,1,1,C.A. 2673,20.25,,S
|
||||
281,0,3,"Duane, Mr. Frank",male,65,0,0,336439,7.75,,Q
|
||||
282,0,3,"Olsson, Mr. Nils Johan Goransson",male,28,0,0,347464,7.8542,,S
|
||||
283,0,3,"de Pelsmaeker, Mr. Alfons",male,16,0,0,345778,9.5,,S
|
||||
284,1,3,"Dorking, Mr. Edward Arthur",male,19,0,0,A/5. 10482,8.05,,S
|
||||
285,0,1,"Smith, Mr. Richard William",male,,0,0,113056,26,A19,S
|
||||
286,0,3,"Stankovic, Mr. Ivan",male,33,0,0,349239,8.6625,,C
|
||||
287,1,3,"de Mulder, Mr. Theodore",male,30,0,0,345774,9.5,,S
|
||||
288,0,3,"Naidenoff, Mr. Penko",male,22,0,0,349206,7.8958,,S
|
||||
289,1,2,"Hosono, Mr. Masabumi",male,42,0,0,237798,13,,S
|
||||
290,1,3,"Connolly, Miss. Kate",female,22,0,0,370373,7.75,,Q
|
||||
291,1,1,"Barber, Miss. Ellen ""Nellie""",female,26,0,0,19877,78.85,,S
|
||||
292,1,1,"Bishop, Mrs. Dickinson H (Helen Walton)",female,19,1,0,11967,91.0792,B49,C
|
||||
293,0,2,"Levy, Mr. Rene Jacques",male,36,0,0,SC/Paris 2163,12.875,D,C
|
||||
294,0,3,"Haas, Miss. Aloisia",female,24,0,0,349236,8.85,,S
|
||||
295,0,3,"Mineff, Mr. Ivan",male,24,0,0,349233,7.8958,,S
|
||||
296,0,1,"Lewy, Mr. Ervin G",male,,0,0,PC 17612,27.7208,,C
|
||||
297,0,3,"Hanna, Mr. Mansour",male,23.5,0,0,2693,7.2292,,C
|
||||
298,0,1,"Allison, Miss. Helen Loraine",female,2,1,2,113781,151.55,C22 C26,S
|
||||
299,1,1,"Saalfeld, Mr. Adolphe",male,,0,0,19988,30.5,C106,S
|
||||
300,1,1,"Baxter, Mrs. James (Helene DeLaudeniere Chaput)",female,50,0,1,PC 17558,247.5208,B58 B60,C
|
||||
301,1,3,"Kelly, Miss. Anna Katherine ""Annie Kate""",female,,0,0,9234,7.75,,Q
|
||||
302,1,3,"McCoy, Mr. Bernard",male,,2,0,367226,23.25,,Q
|
||||
303,0,3,"Johnson, Mr. William Cahoone Jr",male,19,0,0,LINE,0,,S
|
||||
304,1,2,"Keane, Miss. Nora A",female,,0,0,226593,12.35,E101,Q
|
||||
305,0,3,"Williams, Mr. Howard Hugh ""Harry""",male,,0,0,A/5 2466,8.05,,S
|
||||
306,1,1,"Allison, Master. Hudson Trevor",male,0.92,1,2,113781,151.55,C22 C26,S
|
||||
307,1,1,"Fleming, Miss. Margaret",female,,0,0,17421,110.8833,,C
|
||||
308,1,1,"Penasco y Castellana, Mrs. Victor de Satode (Maria Josefa Perez de Soto y Vallejo)",female,17,1,0,PC 17758,108.9,C65,C
|
||||
309,0,2,"Abelson, Mr. Samuel",male,30,1,0,P/PP 3381,24,,C
|
||||
310,1,1,"Francatelli, Miss. Laura Mabel",female,30,0,0,PC 17485,56.9292,E36,C
|
||||
311,1,1,"Hays, Miss. Margaret Bechstein",female,24,0,0,11767,83.1583,C54,C
|
||||
312,1,1,"Ryerson, Miss. Emily Borie",female,18,2,2,PC 17608,262.375,B57 B59 B63 B66,C
|
||||
313,0,2,"Lahtinen, Mrs. William (Anna Sylfven)",female,26,1,1,250651,26,,S
|
||||
314,0,3,"Hendekovic, Mr. Ignjac",male,28,0,0,349243,7.8958,,S
|
||||
315,0,2,"Hart, Mr. Benjamin",male,43,1,1,F.C.C. 13529,26.25,,S
|
||||
316,1,3,"Nilsson, Miss. Helmina Josefina",female,26,0,0,347470,7.8542,,S
|
||||
317,1,2,"Kantor, Mrs. Sinai (Miriam Sternin)",female,24,1,0,244367,26,,S
|
||||
318,0,2,"Moraweck, Dr. Ernest",male,54,0,0,29011,14,,S
|
||||
319,1,1,"Wick, Miss. Mary Natalie",female,31,0,2,36928,164.8667,C7,S
|
||||
320,1,1,"Spedden, Mrs. Frederic Oakley (Margaretta Corning Stone)",female,40,1,1,16966,134.5,E34,C
|
||||
321,0,3,"Dennis, Mr. Samuel",male,22,0,0,A/5 21172,7.25,,S
|
||||
322,0,3,"Danoff, Mr. Yoto",male,27,0,0,349219,7.8958,,S
|
||||
323,1,2,"Slayter, Miss. Hilda Mary",female,30,0,0,234818,12.35,,Q
|
||||
324,1,2,"Caldwell, Mrs. Albert Francis (Sylvia Mae Harbaugh)",female,22,1,1,248738,29,,S
|
||||
325,0,3,"Sage, Mr. George John Jr",male,,8,2,CA. 2343,69.55,,S
|
||||
326,1,1,"Young, Miss. Marie Grice",female,36,0,0,PC 17760,135.6333,C32,C
|
||||
327,0,3,"Nysveen, Mr. Johan Hansen",male,61,0,0,345364,6.2375,,S
|
||||
328,1,2,"Ball, Mrs. (Ada E Hall)",female,36,0,0,28551,13,D,S
|
||||
329,1,3,"Goldsmith, Mrs. Frank John (Emily Alice Brown)",female,31,1,1,363291,20.525,,S
|
||||
330,1,1,"Hippach, Miss. Jean Gertrude",female,16,0,1,111361,57.9792,B18,C
|
||||
331,1,3,"McCoy, Miss. Agnes",female,,2,0,367226,23.25,,Q
|
||||
332,0,1,"Partner, Mr. Austen",male,45.5,0,0,113043,28.5,C124,S
|
||||
333,0,1,"Graham, Mr. George Edward",male,38,0,1,PC 17582,153.4625,C91,S
|
||||
334,0,3,"Vander Planke, Mr. Leo Edmondus",male,16,2,0,345764,18,,S
|
||||
335,1,1,"Frauenthal, Mrs. Henry William (Clara Heinsheimer)",female,,1,0,PC 17611,133.65,,S
|
||||
336,0,3,"Denkoff, Mr. Mitto",male,,0,0,349225,7.8958,,S
|
||||
337,0,1,"Pears, Mr. Thomas Clinton",male,29,1,0,113776,66.6,C2,S
|
||||
338,1,1,"Burns, Miss. Elizabeth Margaret",female,41,0,0,16966,134.5,E40,C
|
||||
339,1,3,"Dahl, Mr. Karl Edwart",male,45,0,0,7598,8.05,,S
|
||||
340,0,1,"Blackwell, Mr. Stephen Weart",male,45,0,0,113784,35.5,T,S
|
||||
341,1,2,"Navratil, Master. Edmond Roger",male,2,1,1,230080,26,F2,S
|
||||
342,1,1,"Fortune, Miss. Alice Elizabeth",female,24,3,2,19950,263,C23 C25 C27,S
|
||||
343,0,2,"Collander, Mr. Erik Gustaf",male,28,0,0,248740,13,,S
|
||||
344,0,2,"Sedgwick, Mr. Charles Frederick Waddington",male,25,0,0,244361,13,,S
|
||||
345,0,2,"Fox, Mr. Stanley Hubert",male,36,0,0,229236,13,,S
|
||||
346,1,2,"Brown, Miss. Amelia ""Mildred""",female,24,0,0,248733,13,F33,S
|
||||
347,1,2,"Smith, Miss. Marion Elsie",female,40,0,0,31418,13,,S
|
||||
348,1,3,"Davison, Mrs. Thomas Henry (Mary E Finck)",female,,1,0,386525,16.1,,S
|
||||
349,1,3,"Coutts, Master. William Loch ""William""",male,3,1,1,C.A. 37671,15.9,,S
|
||||
350,0,3,"Dimic, Mr. Jovan",male,42,0,0,315088,8.6625,,S
|
||||
351,0,3,"Odahl, Mr. Nils Martin",male,23,0,0,7267,9.225,,S
|
||||
352,0,1,"Williams-Lambert, Mr. Fletcher Fellows",male,,0,0,113510,35,C128,S
|
||||
353,0,3,"Elias, Mr. Tannous",male,15,1,1,2695,7.2292,,C
|
||||
354,0,3,"Arnold-Franchi, Mr. Josef",male,25,1,0,349237,17.8,,S
|
||||
355,0,3,"Yousif, Mr. Wazli",male,,0,0,2647,7.225,,C
|
||||
356,0,3,"Vanden Steen, Mr. Leo Peter",male,28,0,0,345783,9.5,,S
|
||||
357,1,1,"Bowerman, Miss. Elsie Edith",female,22,0,1,113505,55,E33,S
|
||||
358,0,2,"Funk, Miss. Annie Clemmer",female,38,0,0,237671,13,,S
|
||||
359,1,3,"McGovern, Miss. Mary",female,,0,0,330931,7.8792,,Q
|
||||
360,1,3,"Mockler, Miss. Helen Mary ""Ellie""",female,,0,0,330980,7.8792,,Q
|
||||
361,0,3,"Skoog, Mr. Wilhelm",male,40,1,4,347088,27.9,,S
|
||||
362,0,2,"del Carlo, Mr. Sebastiano",male,29,1,0,SC/PARIS 2167,27.7208,,C
|
||||
363,0,3,"Barbara, Mrs. (Catherine David)",female,45,0,1,2691,14.4542,,C
|
||||
364,0,3,"Asim, Mr. Adola",male,35,0,0,SOTON/O.Q. 3101310,7.05,,S
|
||||
365,0,3,"O'Brien, Mr. Thomas",male,,1,0,370365,15.5,,Q
|
||||
366,0,3,"Adahl, Mr. Mauritz Nils Martin",male,30,0,0,C 7076,7.25,,S
|
||||
367,1,1,"Warren, Mrs. Frank Manley (Anna Sophia Atkinson)",female,60,1,0,110813,75.25,D37,C
|
||||
368,1,3,"Moussa, Mrs. (Mantoura Boulos)",female,,0,0,2626,7.2292,,C
|
||||
369,1,3,"Jermyn, Miss. Annie",female,,0,0,14313,7.75,,Q
|
||||
370,1,1,"Aubart, Mme. Leontine Pauline",female,24,0,0,PC 17477,69.3,B35,C
|
||||
371,1,1,"Harder, Mr. George Achilles",male,25,1,0,11765,55.4417,E50,C
|
||||
372,0,3,"Wiklund, Mr. Jakob Alfred",male,18,1,0,3101267,6.4958,,S
|
||||
373,0,3,"Beavan, Mr. William Thomas",male,19,0,0,323951,8.05,,S
|
||||
374,0,1,"Ringhini, Mr. Sante",male,22,0,0,PC 17760,135.6333,,C
|
||||
375,0,3,"Palsson, Miss. Stina Viola",female,3,3,1,349909,21.075,,S
|
||||
376,1,1,"Meyer, Mrs. Edgar Joseph (Leila Saks)",female,,1,0,PC 17604,82.1708,,C
|
||||
377,1,3,"Landergren, Miss. Aurora Adelia",female,22,0,0,C 7077,7.25,,S
|
||||
378,0,1,"Widener, Mr. Harry Elkins",male,27,0,2,113503,211.5,C82,C
|
||||
379,0,3,"Betros, Mr. Tannous",male,20,0,0,2648,4.0125,,C
|
||||
380,0,3,"Gustafsson, Mr. Karl Gideon",male,19,0,0,347069,7.775,,S
|
||||
381,1,1,"Bidois, Miss. Rosalie",female,42,0,0,PC 17757,227.525,,C
|
||||
382,1,3,"Nakid, Miss. Maria (""Mary"")",female,1,0,2,2653,15.7417,,C
|
||||
383,0,3,"Tikkanen, Mr. Juho",male,32,0,0,STON/O 2. 3101293,7.925,,S
|
||||
384,1,1,"Holverson, Mrs. Alexander Oskar (Mary Aline Towner)",female,35,1,0,113789,52,,S
|
||||
385,0,3,"Plotcharsky, Mr. Vasil",male,,0,0,349227,7.8958,,S
|
||||
386,0,2,"Davies, Mr. Charles Henry",male,18,0,0,S.O.C. 14879,73.5,,S
|
||||
387,0,3,"Goodwin, Master. Sidney Leonard",male,1,5,2,CA 2144,46.9,,S
|
||||
388,1,2,"Buss, Miss. Kate",female,36,0,0,27849,13,,S
|
||||
389,0,3,"Sadlier, Mr. Matthew",male,,0,0,367655,7.7292,,Q
|
||||
390,1,2,"Lehmann, Miss. Bertha",female,17,0,0,SC 1748,12,,C
|
||||
391,1,1,"Carter, Mr. William Ernest",male,36,1,2,113760,120,B96 B98,S
|
||||
392,1,3,"Jansson, Mr. Carl Olof",male,21,0,0,350034,7.7958,,S
|
||||
393,0,3,"Gustafsson, Mr. Johan Birger",male,28,2,0,3101277,7.925,,S
|
||||
394,1,1,"Newell, Miss. Marjorie",female,23,1,0,35273,113.275,D36,C
|
||||
395,1,3,"Sandstrom, Mrs. Hjalmar (Agnes Charlotta Bengtsson)",female,24,0,2,PP 9549,16.7,G6,S
|
||||
396,0,3,"Johansson, Mr. Erik",male,22,0,0,350052,7.7958,,S
|
||||
397,0,3,"Olsson, Miss. Elina",female,31,0,0,350407,7.8542,,S
|
||||
398,0,2,"McKane, Mr. Peter David",male,46,0,0,28403,26,,S
|
||||
399,0,2,"Pain, Dr. Alfred",male,23,0,0,244278,10.5,,S
|
||||
400,1,2,"Trout, Mrs. William H (Jessie L)",female,28,0,0,240929,12.65,,S
|
||||
401,1,3,"Niskanen, Mr. Juha",male,39,0,0,STON/O 2. 3101289,7.925,,S
|
||||
402,0,3,"Adams, Mr. John",male,26,0,0,341826,8.05,,S
|
||||
403,0,3,"Jussila, Miss. Mari Aina",female,21,1,0,4137,9.825,,S
|
||||
404,0,3,"Hakkarainen, Mr. Pekka Pietari",male,28,1,0,STON/O2. 3101279,15.85,,S
|
||||
405,0,3,"Oreskovic, Miss. Marija",female,20,0,0,315096,8.6625,,S
|
||||
406,0,2,"Gale, Mr. Shadrach",male,34,1,0,28664,21,,S
|
||||
407,0,3,"Widegren, Mr. Carl/Charles Peter",male,51,0,0,347064,7.75,,S
|
||||
408,1,2,"Richards, Master. William Rowe",male,3,1,1,29106,18.75,,S
|
||||
409,0,3,"Birkeland, Mr. Hans Martin Monsen",male,21,0,0,312992,7.775,,S
|
||||
410,0,3,"Lefebre, Miss. Ida",female,,3,1,4133,25.4667,,S
|
||||
411,0,3,"Sdycoff, Mr. Todor",male,,0,0,349222,7.8958,,S
|
||||
412,0,3,"Hart, Mr. Henry",male,,0,0,394140,6.8583,,Q
|
||||
413,1,1,"Minahan, Miss. Daisy E",female,33,1,0,19928,90,C78,Q
|
||||
414,0,2,"Cunningham, Mr. Alfred Fleming",male,,0,0,239853,0,,S
|
||||
415,1,3,"Sundman, Mr. Johan Julian",male,44,0,0,STON/O 2. 3101269,7.925,,S
|
||||
416,0,3,"Meek, Mrs. Thomas (Annie Louise Rowley)",female,,0,0,343095,8.05,,S
|
||||
417,1,2,"Drew, Mrs. James Vivian (Lulu Thorne Christian)",female,34,1,1,28220,32.5,,S
|
||||
418,1,2,"Silven, Miss. Lyyli Karoliina",female,18,0,2,250652,13,,S
|
||||
419,0,2,"Matthews, Mr. William John",male,30,0,0,28228,13,,S
|
||||
420,0,3,"Van Impe, Miss. Catharina",female,10,0,2,345773,24.15,,S
|
||||
421,0,3,"Gheorgheff, Mr. Stanio",male,,0,0,349254,7.8958,,C
|
||||
422,0,3,"Charters, Mr. David",male,21,0,0,A/5. 13032,7.7333,,Q
|
||||
423,0,3,"Zimmerman, Mr. Leo",male,29,0,0,315082,7.875,,S
|
||||
424,0,3,"Danbom, Mrs. Ernst Gilbert (Anna Sigrid Maria Brogren)",female,28,1,1,347080,14.4,,S
|
||||
425,0,3,"Rosblom, Mr. Viktor Richard",male,18,1,1,370129,20.2125,,S
|
||||
426,0,3,"Wiseman, Mr. Phillippe",male,,0,0,A/4. 34244,7.25,,S
|
||||
427,1,2,"Clarke, Mrs. Charles V (Ada Maria Winfield)",female,28,1,0,2003,26,,S
|
||||
428,1,2,"Phillips, Miss. Kate Florence (""Mrs Kate Louise Phillips Marshall"")",female,19,0,0,250655,26,,S
|
||||
429,0,3,"Flynn, Mr. James",male,,0,0,364851,7.75,,Q
|
||||
430,1,3,"Pickard, Mr. Berk (Berk Trembisky)",male,32,0,0,SOTON/O.Q. 392078,8.05,E10,S
|
||||
431,1,1,"Bjornstrom-Steffansson, Mr. Mauritz Hakan",male,28,0,0,110564,26.55,C52,S
|
||||
432,1,3,"Thorneycroft, Mrs. Percival (Florence Kate White)",female,,1,0,376564,16.1,,S
|
||||
433,1,2,"Louch, Mrs. Charles Alexander (Alice Adelaide Slow)",female,42,1,0,SC/AH 3085,26,,S
|
||||
434,0,3,"Kallio, Mr. Nikolai Erland",male,17,0,0,STON/O 2. 3101274,7.125,,S
|
||||
435,0,1,"Silvey, Mr. William Baird",male,50,1,0,13507,55.9,E44,S
|
||||
436,1,1,"Carter, Miss. Lucile Polk",female,14,1,2,113760,120,B96 B98,S
|
||||
437,0,3,"Ford, Miss. Doolina Margaret ""Daisy""",female,21,2,2,W./C. 6608,34.375,,S
|
||||
438,1,2,"Richards, Mrs. Sidney (Emily Hocking)",female,24,2,3,29106,18.75,,S
|
||||
439,0,1,"Fortune, Mr. Mark",male,64,1,4,19950,263,C23 C25 C27,S
|
||||
440,0,2,"Kvillner, Mr. Johan Henrik Johannesson",male,31,0,0,C.A. 18723,10.5,,S
|
||||
441,1,2,"Hart, Mrs. Benjamin (Esther Ada Bloomfield)",female,45,1,1,F.C.C. 13529,26.25,,S
|
||||
442,0,3,"Hampe, Mr. Leon",male,20,0,0,345769,9.5,,S
|
||||
443,0,3,"Petterson, Mr. Johan Emil",male,25,1,0,347076,7.775,,S
|
||||
444,1,2,"Reynaldo, Ms. Encarnacion",female,28,0,0,230434,13,,S
|
||||
445,1,3,"Johannesen-Bratthammer, Mr. Bernt",male,,0,0,65306,8.1125,,S
|
||||
446,1,1,"Dodge, Master. Washington",male,4,0,2,33638,81.8583,A34,S
|
||||
447,1,2,"Mellinger, Miss. Madeleine Violet",female,13,0,1,250644,19.5,,S
|
||||
448,1,1,"Seward, Mr. Frederic Kimber",male,34,0,0,113794,26.55,,S
|
||||
449,1,3,"Baclini, Miss. Marie Catherine",female,5,2,1,2666,19.2583,,C
|
||||
450,1,1,"Peuchen, Major. Arthur Godfrey",male,52,0,0,113786,30.5,C104,S
|
||||
451,0,2,"West, Mr. Edwy Arthur",male,36,1,2,C.A. 34651,27.75,,S
|
||||
452,0,3,"Hagland, Mr. Ingvald Olai Olsen",male,,1,0,65303,19.9667,,S
|
||||
453,0,1,"Foreman, Mr. Benjamin Laventall",male,30,0,0,113051,27.75,C111,C
|
||||
454,1,1,"Goldenberg, Mr. Samuel L",male,49,1,0,17453,89.1042,C92,C
|
||||
455,0,3,"Peduzzi, Mr. Joseph",male,,0,0,A/5 2817,8.05,,S
|
||||
456,1,3,"Jalsevac, Mr. Ivan",male,29,0,0,349240,7.8958,,C
|
||||
457,0,1,"Millet, Mr. Francis Davis",male,65,0,0,13509,26.55,E38,S
|
||||
458,1,1,"Kenyon, Mrs. Frederick R (Marion)",female,,1,0,17464,51.8625,D21,S
|
||||
459,1,2,"Toomey, Miss. Ellen",female,50,0,0,F.C.C. 13531,10.5,,S
|
||||
460,0,3,"O'Connor, Mr. Maurice",male,,0,0,371060,7.75,,Q
|
||||
461,1,1,"Anderson, Mr. Harry",male,48,0,0,19952,26.55,E12,S
|
||||
462,0,3,"Morley, Mr. William",male,34,0,0,364506,8.05,,S
|
||||
463,0,1,"Gee, Mr. Arthur H",male,47,0,0,111320,38.5,E63,S
|
||||
464,0,2,"Milling, Mr. Jacob Christian",male,48,0,0,234360,13,,S
|
||||
465,0,3,"Maisner, Mr. Simon",male,,0,0,A/S 2816,8.05,,S
|
||||
466,0,3,"Goncalves, Mr. Manuel Estanslas",male,38,0,0,SOTON/O.Q. 3101306,7.05,,S
|
||||
467,0,2,"Campbell, Mr. William",male,,0,0,239853,0,,S
|
||||
468,0,1,"Smart, Mr. John Montgomery",male,56,0,0,113792,26.55,,S
|
||||
469,0,3,"Scanlan, Mr. James",male,,0,0,36209,7.725,,Q
|
||||
470,1,3,"Baclini, Miss. Helene Barbara",female,0.75,2,1,2666,19.2583,,C
|
||||
471,0,3,"Keefe, Mr. Arthur",male,,0,0,323592,7.25,,S
|
||||
472,0,3,"Cacic, Mr. Luka",male,38,0,0,315089,8.6625,,S
|
||||
473,1,2,"West, Mrs. Edwy Arthur (Ada Mary Worth)",female,33,1,2,C.A. 34651,27.75,,S
|
||||
474,1,2,"Jerwan, Mrs. Amin S (Marie Marthe Thuillard)",female,23,0,0,SC/AH Basle 541,13.7917,D,C
|
||||
475,0,3,"Strandberg, Miss. Ida Sofia",female,22,0,0,7553,9.8375,,S
|
||||
476,0,1,"Clifford, Mr. George Quincy",male,,0,0,110465,52,A14,S
|
||||
477,0,2,"Renouf, Mr. Peter Henry",male,34,1,0,31027,21,,S
|
||||
478,0,3,"Braund, Mr. Lewis Richard",male,29,1,0,3460,7.0458,,S
|
||||
479,0,3,"Karlsson, Mr. Nils August",male,22,0,0,350060,7.5208,,S
|
||||
480,1,3,"Hirvonen, Miss. Hildur E",female,2,0,1,3101298,12.2875,,S
|
||||
481,0,3,"Goodwin, Master. Harold Victor",male,9,5,2,CA 2144,46.9,,S
|
||||
482,0,2,"Frost, Mr. Anthony Wood ""Archie""",male,,0,0,239854,0,,S
|
||||
483,0,3,"Rouse, Mr. Richard Henry",male,50,0,0,A/5 3594,8.05,,S
|
||||
484,1,3,"Turkula, Mrs. (Hedwig)",female,63,0,0,4134,9.5875,,S
|
||||
485,1,1,"Bishop, Mr. Dickinson H",male,25,1,0,11967,91.0792,B49,C
|
||||
486,0,3,"Lefebre, Miss. Jeannie",female,,3,1,4133,25.4667,,S
|
||||
487,1,1,"Hoyt, Mrs. Frederick Maxfield (Jane Anne Forby)",female,35,1,0,19943,90,C93,S
|
||||
488,0,1,"Kent, Mr. Edward Austin",male,58,0,0,11771,29.7,B37,C
|
||||
489,0,3,"Somerton, Mr. Francis William",male,30,0,0,A.5. 18509,8.05,,S
|
||||
490,1,3,"Coutts, Master. Eden Leslie ""Neville""",male,9,1,1,C.A. 37671,15.9,,S
|
||||
491,0,3,"Hagland, Mr. Konrad Mathias Reiersen",male,,1,0,65304,19.9667,,S
|
||||
492,0,3,"Windelov, Mr. Einar",male,21,0,0,SOTON/OQ 3101317,7.25,,S
|
||||
493,0,1,"Molson, Mr. Harry Markland",male,55,0,0,113787,30.5,C30,S
|
||||
494,0,1,"Artagaveytia, Mr. Ramon",male,71,0,0,PC 17609,49.5042,,C
|
||||
495,0,3,"Stanley, Mr. Edward Roland",male,21,0,0,A/4 45380,8.05,,S
|
||||
496,0,3,"Yousseff, Mr. Gerious",male,,0,0,2627,14.4583,,C
|
||||
497,1,1,"Eustis, Miss. Elizabeth Mussey",female,54,1,0,36947,78.2667,D20,C
|
||||
498,0,3,"Shellard, Mr. Frederick William",male,,0,0,C.A. 6212,15.1,,S
|
||||
499,0,1,"Allison, Mrs. Hudson J C (Bessie Waldo Daniels)",female,25,1,2,113781,151.55,C22 C26,S
|
||||
500,0,3,"Svensson, Mr. Olof",male,24,0,0,350035,7.7958,,S
|
||||
501,0,3,"Calic, Mr. Petar",male,17,0,0,315086,8.6625,,S
|
||||
502,0,3,"Canavan, Miss. Mary",female,21,0,0,364846,7.75,,Q
|
||||
503,0,3,"O'Sullivan, Miss. Bridget Mary",female,,0,0,330909,7.6292,,Q
|
||||
504,0,3,"Laitinen, Miss. Kristina Sofia",female,37,0,0,4135,9.5875,,S
|
||||
505,1,1,"Maioni, Miss. Roberta",female,16,0,0,110152,86.5,B79,S
|
||||
506,0,1,"Penasco y Castellana, Mr. Victor de Satode",male,18,1,0,PC 17758,108.9,C65,C
|
||||
507,1,2,"Quick, Mrs. Frederick Charles (Jane Richards)",female,33,0,2,26360,26,,S
|
||||
508,1,1,"Bradley, Mr. George (""George Arthur Brayton"")",male,,0,0,111427,26.55,,S
|
||||
509,0,3,"Olsen, Mr. Henry Margido",male,28,0,0,C 4001,22.525,,S
|
||||
510,1,3,"Lang, Mr. Fang",male,26,0,0,1601,56.4958,,S
|
||||
511,1,3,"Daly, Mr. Eugene Patrick",male,29,0,0,382651,7.75,,Q
|
||||
512,0,3,"Webber, Mr. James",male,,0,0,SOTON/OQ 3101316,8.05,,S
|
||||
513,1,1,"McGough, Mr. James Robert",male,36,0,0,PC 17473,26.2875,E25,S
|
||||
514,1,1,"Rothschild, Mrs. Martin (Elizabeth L. Barrett)",female,54,1,0,PC 17603,59.4,,C
|
||||
515,0,3,"Coleff, Mr. Satio",male,24,0,0,349209,7.4958,,S
|
||||
516,0,1,"Walker, Mr. William Anderson",male,47,0,0,36967,34.0208,D46,S
|
||||
517,1,2,"Lemore, Mrs. (Amelia Milley)",female,34,0,0,C.A. 34260,10.5,F33,S
|
||||
518,0,3,"Ryan, Mr. Patrick",male,,0,0,371110,24.15,,Q
|
||||
519,1,2,"Angle, Mrs. William A (Florence ""Mary"" Agnes Hughes)",female,36,1,0,226875,26,,S
|
||||
520,0,3,"Pavlovic, Mr. Stefo",male,32,0,0,349242,7.8958,,S
|
||||
521,1,1,"Perreault, Miss. Anne",female,30,0,0,12749,93.5,B73,S
|
||||
522,0,3,"Vovk, Mr. Janko",male,22,0,0,349252,7.8958,,S
|
||||
523,0,3,"Lahoud, Mr. Sarkis",male,,0,0,2624,7.225,,C
|
||||
524,1,1,"Hippach, Mrs. Louis Albert (Ida Sophia Fischer)",female,44,0,1,111361,57.9792,B18,C
|
||||
525,0,3,"Kassem, Mr. Fared",male,,0,0,2700,7.2292,,C
|
||||
526,0,3,"Farrell, Mr. James",male,40.5,0,0,367232,7.75,,Q
|
||||
527,1,2,"Ridsdale, Miss. Lucy",female,50,0,0,W./C. 14258,10.5,,S
|
||||
528,0,1,"Farthing, Mr. John",male,,0,0,PC 17483,221.7792,C95,S
|
||||
529,0,3,"Salonen, Mr. Johan Werner",male,39,0,0,3101296,7.925,,S
|
||||
530,0,2,"Hocking, Mr. Richard George",male,23,2,1,29104,11.5,,S
|
||||
531,1,2,"Quick, Miss. Phyllis May",female,2,1,1,26360,26,,S
|
||||
532,0,3,"Toufik, Mr. Nakli",male,,0,0,2641,7.2292,,C
|
||||
533,0,3,"Elias, Mr. Joseph Jr",male,17,1,1,2690,7.2292,,C
|
||||
534,1,3,"Peter, Mrs. Catherine (Catherine Rizk)",female,,0,2,2668,22.3583,,C
|
||||
535,0,3,"Cacic, Miss. Marija",female,30,0,0,315084,8.6625,,S
|
||||
536,1,2,"Hart, Miss. Eva Miriam",female,7,0,2,F.C.C. 13529,26.25,,S
|
||||
537,0,1,"Butt, Major. Archibald Willingham",male,45,0,0,113050,26.55,B38,S
|
||||
538,1,1,"LeRoy, Miss. Bertha",female,30,0,0,PC 17761,106.425,,C
|
||||
539,0,3,"Risien, Mr. Samuel Beard",male,,0,0,364498,14.5,,S
|
||||
540,1,1,"Frolicher, Miss. Hedwig Margaritha",female,22,0,2,13568,49.5,B39,C
|
||||
541,1,1,"Crosby, Miss. Harriet R",female,36,0,2,WE/P 5735,71,B22,S
|
||||
542,0,3,"Andersson, Miss. Ingeborg Constanzia",female,9,4,2,347082,31.275,,S
|
||||
543,0,3,"Andersson, Miss. Sigrid Elisabeth",female,11,4,2,347082,31.275,,S
|
||||
544,1,2,"Beane, Mr. Edward",male,32,1,0,2908,26,,S
|
||||
545,0,1,"Douglas, Mr. Walter Donald",male,50,1,0,PC 17761,106.425,C86,C
|
||||
546,0,1,"Nicholson, Mr. Arthur Ernest",male,64,0,0,693,26,,S
|
||||
547,1,2,"Beane, Mrs. Edward (Ethel Clarke)",female,19,1,0,2908,26,,S
|
||||
548,1,2,"Padro y Manent, Mr. Julian",male,,0,0,SC/PARIS 2146,13.8625,,C
|
||||
549,0,3,"Goldsmith, Mr. Frank John",male,33,1,1,363291,20.525,,S
|
||||
550,1,2,"Davies, Master. John Morgan Jr",male,8,1,1,C.A. 33112,36.75,,S
|
||||
551,1,1,"Thayer, Mr. John Borland Jr",male,17,0,2,17421,110.8833,C70,C
|
||||
552,0,2,"Sharp, Mr. Percival James R",male,27,0,0,244358,26,,S
|
||||
553,0,3,"O'Brien, Mr. Timothy",male,,0,0,330979,7.8292,,Q
|
||||
554,1,3,"Leeni, Mr. Fahim (""Philip Zenni"")",male,22,0,0,2620,7.225,,C
|
||||
555,1,3,"Ohman, Miss. Velin",female,22,0,0,347085,7.775,,S
|
||||
556,0,1,"Wright, Mr. George",male,62,0,0,113807,26.55,,S
|
||||
557,1,1,"Duff Gordon, Lady. (Lucille Christiana Sutherland) (""Mrs Morgan"")",female,48,1,0,11755,39.6,A16,C
|
||||
558,0,1,"Robbins, Mr. Victor",male,,0,0,PC 17757,227.525,,C
|
||||
559,1,1,"Taussig, Mrs. Emil (Tillie Mandelbaum)",female,39,1,1,110413,79.65,E67,S
|
||||
560,1,3,"de Messemaeker, Mrs. Guillaume Joseph (Emma)",female,36,1,0,345572,17.4,,S
|
||||
561,0,3,"Morrow, Mr. Thomas Rowan",male,,0,0,372622,7.75,,Q
|
||||
562,0,3,"Sivic, Mr. Husein",male,40,0,0,349251,7.8958,,S
|
||||
563,0,2,"Norman, Mr. Robert Douglas",male,28,0,0,218629,13.5,,S
|
||||
564,0,3,"Simmons, Mr. John",male,,0,0,SOTON/OQ 392082,8.05,,S
|
||||
565,0,3,"Meanwell, Miss. (Marion Ogden)",female,,0,0,SOTON/O.Q. 392087,8.05,,S
|
||||
566,0,3,"Davies, Mr. Alfred J",male,24,2,0,A/4 48871,24.15,,S
|
||||
567,0,3,"Stoytcheff, Mr. Ilia",male,19,0,0,349205,7.8958,,S
|
||||
568,0,3,"Palsson, Mrs. Nils (Alma Cornelia Berglund)",female,29,0,4,349909,21.075,,S
|
||||
569,0,3,"Doharr, Mr. Tannous",male,,0,0,2686,7.2292,,C
|
||||
570,1,3,"Jonsson, Mr. Carl",male,32,0,0,350417,7.8542,,S
|
||||
571,1,2,"Harris, Mr. George",male,62,0,0,S.W./PP 752,10.5,,S
|
||||
572,1,1,"Appleton, Mrs. Edward Dale (Charlotte Lamson)",female,53,2,0,11769,51.4792,C101,S
|
||||
573,1,1,"Flynn, Mr. John Irwin (""Irving"")",male,36,0,0,PC 17474,26.3875,E25,S
|
||||
574,1,3,"Kelly, Miss. Mary",female,,0,0,14312,7.75,,Q
|
||||
575,0,3,"Rush, Mr. Alfred George John",male,16,0,0,A/4. 20589,8.05,,S
|
||||
576,0,3,"Patchett, Mr. George",male,19,0,0,358585,14.5,,S
|
||||
577,1,2,"Garside, Miss. Ethel",female,34,0,0,243880,13,,S
|
||||
578,1,1,"Silvey, Mrs. William Baird (Alice Munger)",female,39,1,0,13507,55.9,E44,S
|
||||
579,0,3,"Caram, Mrs. Joseph (Maria Elias)",female,,1,0,2689,14.4583,,C
|
||||
580,1,3,"Jussila, Mr. Eiriik",male,32,0,0,STON/O 2. 3101286,7.925,,S
|
||||
581,1,2,"Christy, Miss. Julie Rachel",female,25,1,1,237789,30,,S
|
||||
582,1,1,"Thayer, Mrs. John Borland (Marian Longstreth Morris)",female,39,1,1,17421,110.8833,C68,C
|
||||
583,0,2,"Downton, Mr. William James",male,54,0,0,28403,26,,S
|
||||
584,0,1,"Ross, Mr. John Hugo",male,36,0,0,13049,40.125,A10,C
|
||||
585,0,3,"Paulner, Mr. Uscher",male,,0,0,3411,8.7125,,C
|
||||
586,1,1,"Taussig, Miss. Ruth",female,18,0,2,110413,79.65,E68,S
|
||||
587,0,2,"Jarvis, Mr. John Denzil",male,47,0,0,237565,15,,S
|
||||
588,1,1,"Frolicher-Stehli, Mr. Maxmillian",male,60,1,1,13567,79.2,B41,C
|
||||
589,0,3,"Gilinski, Mr. Eliezer",male,22,0,0,14973,8.05,,S
|
||||
590,0,3,"Murdlin, Mr. Joseph",male,,0,0,A./5. 3235,8.05,,S
|
||||
591,0,3,"Rintamaki, Mr. Matti",male,35,0,0,STON/O 2. 3101273,7.125,,S
|
||||
592,1,1,"Stephenson, Mrs. Walter Bertram (Martha Eustis)",female,52,1,0,36947,78.2667,D20,C
|
||||
593,0,3,"Elsbury, Mr. William James",male,47,0,0,A/5 3902,7.25,,S
|
||||
594,0,3,"Bourke, Miss. Mary",female,,0,2,364848,7.75,,Q
|
||||
595,0,2,"Chapman, Mr. John Henry",male,37,1,0,SC/AH 29037,26,,S
|
||||
596,0,3,"Van Impe, Mr. Jean Baptiste",male,36,1,1,345773,24.15,,S
|
||||
597,1,2,"Leitch, Miss. Jessie Wills",female,,0,0,248727,33,,S
|
||||
598,0,3,"Johnson, Mr. Alfred",male,49,0,0,LINE,0,,S
|
||||
599,0,3,"Boulos, Mr. Hanna",male,,0,0,2664,7.225,,C
|
||||
600,1,1,"Duff Gordon, Sir. Cosmo Edmund (""Mr Morgan"")",male,49,1,0,PC 17485,56.9292,A20,C
|
||||
601,1,2,"Jacobsohn, Mrs. Sidney Samuel (Amy Frances Christy)",female,24,2,1,243847,27,,S
|
||||
602,0,3,"Slabenoff, Mr. Petco",male,,0,0,349214,7.8958,,S
|
||||
603,0,1,"Harrington, Mr. Charles H",male,,0,0,113796,42.4,,S
|
||||
604,0,3,"Torber, Mr. Ernst William",male,44,0,0,364511,8.05,,S
|
||||
605,1,1,"Homer, Mr. Harry (""Mr E Haven"")",male,35,0,0,111426,26.55,,C
|
||||
606,0,3,"Lindell, Mr. Edvard Bengtsson",male,36,1,0,349910,15.55,,S
|
||||
607,0,3,"Karaic, Mr. Milan",male,30,0,0,349246,7.8958,,S
|
||||
608,1,1,"Daniel, Mr. Robert Williams",male,27,0,0,113804,30.5,,S
|
||||
609,1,2,"Laroche, Mrs. Joseph (Juliette Marie Louise Lafargue)",female,22,1,2,SC/Paris 2123,41.5792,,C
|
||||
610,1,1,"Shutes, Miss. Elizabeth W",female,40,0,0,PC 17582,153.4625,C125,S
|
||||
611,0,3,"Andersson, Mrs. Anders Johan (Alfrida Konstantia Brogren)",female,39,1,5,347082,31.275,,S
|
||||
612,0,3,"Jardin, Mr. Jose Neto",male,,0,0,SOTON/O.Q. 3101305,7.05,,S
|
||||
613,1,3,"Murphy, Miss. Margaret Jane",female,,1,0,367230,15.5,,Q
|
||||
614,0,3,"Horgan, Mr. John",male,,0,0,370377,7.75,,Q
|
||||
615,0,3,"Brocklebank, Mr. William Alfred",male,35,0,0,364512,8.05,,S
|
||||
616,1,2,"Herman, Miss. Alice",female,24,1,2,220845,65,,S
|
||||
617,0,3,"Danbom, Mr. Ernst Gilbert",male,34,1,1,347080,14.4,,S
|
||||
618,0,3,"Lobb, Mrs. William Arthur (Cordelia K Stanlick)",female,26,1,0,A/5. 3336,16.1,,S
|
||||
619,1,2,"Becker, Miss. Marion Louise",female,4,2,1,230136,39,F4,S
|
||||
620,0,2,"Gavey, Mr. Lawrence",male,26,0,0,31028,10.5,,S
|
||||
621,0,3,"Yasbeck, Mr. Antoni",male,27,1,0,2659,14.4542,,C
|
||||
622,1,1,"Kimball, Mr. Edwin Nelson Jr",male,42,1,0,11753,52.5542,D19,S
|
||||
623,1,3,"Nakid, Mr. Sahid",male,20,1,1,2653,15.7417,,C
|
||||
624,0,3,"Hansen, Mr. Henry Damsgaard",male,21,0,0,350029,7.8542,,S
|
||||
625,0,3,"Bowen, Mr. David John ""Dai""",male,21,0,0,54636,16.1,,S
|
||||
626,0,1,"Sutton, Mr. Frederick",male,61,0,0,36963,32.3208,D50,S
|
||||
627,0,2,"Kirkland, Rev. Charles Leonard",male,57,0,0,219533,12.35,,Q
|
||||
628,1,1,"Longley, Miss. Gretchen Fiske",female,21,0,0,13502,77.9583,D9,S
|
||||
629,0,3,"Bostandyeff, Mr. Guentcho",male,26,0,0,349224,7.8958,,S
|
||||
630,0,3,"O'Connell, Mr. Patrick D",male,,0,0,334912,7.7333,,Q
|
||||
631,1,1,"Barkworth, Mr. Algernon Henry Wilson",male,80,0,0,27042,30,A23,S
|
||||
632,0,3,"Lundahl, Mr. Johan Svensson",male,51,0,0,347743,7.0542,,S
|
||||
633,1,1,"Stahelin-Maeglin, Dr. Max",male,32,0,0,13214,30.5,B50,C
|
||||
634,0,1,"Parr, Mr. William Henry Marsh",male,,0,0,112052,0,,S
|
||||
635,0,3,"Skoog, Miss. Mabel",female,9,3,2,347088,27.9,,S
|
||||
636,1,2,"Davis, Miss. Mary",female,28,0,0,237668,13,,S
|
||||
637,0,3,"Leinonen, Mr. Antti Gustaf",male,32,0,0,STON/O 2. 3101292,7.925,,S
|
||||
638,0,2,"Collyer, Mr. Harvey",male,31,1,1,C.A. 31921,26.25,,S
|
||||
639,0,3,"Panula, Mrs. Juha (Maria Emilia Ojala)",female,41,0,5,3101295,39.6875,,S
|
||||
640,0,3,"Thorneycroft, Mr. Percival",male,,1,0,376564,16.1,,S
|
||||
641,0,3,"Jensen, Mr. Hans Peder",male,20,0,0,350050,7.8542,,S
|
||||
642,1,1,"Sagesser, Mlle. Emma",female,24,0,0,PC 17477,69.3,B35,C
|
||||
643,0,3,"Skoog, Miss. Margit Elizabeth",female,2,3,2,347088,27.9,,S
|
||||
644,1,3,"Foo, Mr. Choong",male,,0,0,1601,56.4958,,S
|
||||
645,1,3,"Baclini, Miss. Eugenie",female,0.75,2,1,2666,19.2583,,C
|
||||
646,1,1,"Harper, Mr. Henry Sleeper",male,48,1,0,PC 17572,76.7292,D33,C
|
||||
647,0,3,"Cor, Mr. Liudevit",male,19,0,0,349231,7.8958,,S
|
||||
648,1,1,"Simonius-Blumer, Col. Oberst Alfons",male,56,0,0,13213,35.5,A26,C
|
||||
649,0,3,"Willey, Mr. Edward",male,,0,0,S.O./P.P. 751,7.55,,S
|
||||
650,1,3,"Stanley, Miss. Amy Zillah Elsie",female,23,0,0,CA. 2314,7.55,,S
|
||||
651,0,3,"Mitkoff, Mr. Mito",male,,0,0,349221,7.8958,,S
|
||||
652,1,2,"Doling, Miss. Elsie",female,18,0,1,231919,23,,S
|
||||
653,0,3,"Kalvik, Mr. Johannes Halvorsen",male,21,0,0,8475,8.4333,,S
|
||||
654,1,3,"O'Leary, Miss. Hanora ""Norah""",female,,0,0,330919,7.8292,,Q
|
||||
655,0,3,"Hegarty, Miss. Hanora ""Nora""",female,18,0,0,365226,6.75,,Q
|
||||
656,0,2,"Hickman, Mr. Leonard Mark",male,24,2,0,S.O.C. 14879,73.5,,S
|
||||
657,0,3,"Radeff, Mr. Alexander",male,,0,0,349223,7.8958,,S
|
||||
658,0,3,"Bourke, Mrs. John (Catherine)",female,32,1,1,364849,15.5,,Q
|
||||
659,0,2,"Eitemiller, Mr. George Floyd",male,23,0,0,29751,13,,S
|
||||
660,0,1,"Newell, Mr. Arthur Webster",male,58,0,2,35273,113.275,D48,C
|
||||
661,1,1,"Frauenthal, Dr. Henry William",male,50,2,0,PC 17611,133.65,,S
|
||||
662,0,3,"Badt, Mr. Mohamed",male,40,0,0,2623,7.225,,C
|
||||
663,0,1,"Colley, Mr. Edward Pomeroy",male,47,0,0,5727,25.5875,E58,S
|
||||
664,0,3,"Coleff, Mr. Peju",male,36,0,0,349210,7.4958,,S
|
||||
665,1,3,"Lindqvist, Mr. Eino William",male,20,1,0,STON/O 2. 3101285,7.925,,S
|
||||
666,0,2,"Hickman, Mr. Lewis",male,32,2,0,S.O.C. 14879,73.5,,S
|
||||
667,0,2,"Butler, Mr. Reginald Fenton",male,25,0,0,234686,13,,S
|
||||
668,0,3,"Rommetvedt, Mr. Knud Paust",male,,0,0,312993,7.775,,S
|
||||
669,0,3,"Cook, Mr. Jacob",male,43,0,0,A/5 3536,8.05,,S
|
||||
670,1,1,"Taylor, Mrs. Elmer Zebley (Juliet Cummins Wright)",female,,1,0,19996,52,C126,S
|
||||
671,1,2,"Brown, Mrs. Thomas William Solomon (Elizabeth Catherine Ford)",female,40,1,1,29750,39,,S
|
||||
672,0,1,"Davidson, Mr. Thornton",male,31,1,0,F.C. 12750,52,B71,S
|
||||
673,0,2,"Mitchell, Mr. Henry Michael",male,70,0,0,C.A. 24580,10.5,,S
|
||||
674,1,2,"Wilhelms, Mr. Charles",male,31,0,0,244270,13,,S
|
||||
675,0,2,"Watson, Mr. Ennis Hastings",male,,0,0,239856,0,,S
|
||||
676,0,3,"Edvardsson, Mr. Gustaf Hjalmar",male,18,0,0,349912,7.775,,S
|
||||
677,0,3,"Sawyer, Mr. Frederick Charles",male,24.5,0,0,342826,8.05,,S
|
||||
678,1,3,"Turja, Miss. Anna Sofia",female,18,0,0,4138,9.8417,,S
|
||||
679,0,3,"Goodwin, Mrs. Frederick (Augusta Tyler)",female,43,1,6,CA 2144,46.9,,S
|
||||
680,1,1,"Cardeza, Mr. Thomas Drake Martinez",male,36,0,1,PC 17755,512.3292,B51 B53 B55,C
|
||||
681,0,3,"Peters, Miss. Katie",female,,0,0,330935,8.1375,,Q
|
||||
682,1,1,"Hassab, Mr. Hammad",male,27,0,0,PC 17572,76.7292,D49,C
|
||||
683,0,3,"Olsvigen, Mr. Thor Anderson",male,20,0,0,6563,9.225,,S
|
||||
684,0,3,"Goodwin, Mr. Charles Edward",male,14,5,2,CA 2144,46.9,,S
|
||||
685,0,2,"Brown, Mr. Thomas William Solomon",male,60,1,1,29750,39,,S
|
||||
686,0,2,"Laroche, Mr. Joseph Philippe Lemercier",male,25,1,2,SC/Paris 2123,41.5792,,C
|
||||
687,0,3,"Panula, Mr. Jaako Arnold",male,14,4,1,3101295,39.6875,,S
|
||||
688,0,3,"Dakic, Mr. Branko",male,19,0,0,349228,10.1708,,S
|
||||
689,0,3,"Fischer, Mr. Eberhard Thelander",male,18,0,0,350036,7.7958,,S
|
||||
690,1,1,"Madill, Miss. Georgette Alexandra",female,15,0,1,24160,211.3375,B5,S
|
||||
691,1,1,"Dick, Mr. Albert Adrian",male,31,1,0,17474,57,B20,S
|
||||
692,1,3,"Karun, Miss. Manca",female,4,0,1,349256,13.4167,,C
|
||||
693,1,3,"Lam, Mr. Ali",male,,0,0,1601,56.4958,,S
|
||||
694,0,3,"Saad, Mr. Khalil",male,25,0,0,2672,7.225,,C
|
||||
695,0,1,"Weir, Col. John",male,60,0,0,113800,26.55,,S
|
||||
696,0,2,"Chapman, Mr. Charles Henry",male,52,0,0,248731,13.5,,S
|
||||
697,0,3,"Kelly, Mr. James",male,44,0,0,363592,8.05,,S
|
||||
698,1,3,"Mullens, Miss. Katherine ""Katie""",female,,0,0,35852,7.7333,,Q
|
||||
699,0,1,"Thayer, Mr. John Borland",male,49,1,1,17421,110.8833,C68,C
|
||||
700,0,3,"Humblen, Mr. Adolf Mathias Nicolai Olsen",male,42,0,0,348121,7.65,F G63,S
|
||||
701,1,1,"Astor, Mrs. John Jacob (Madeleine Talmadge Force)",female,18,1,0,PC 17757,227.525,C62 C64,C
|
||||
702,1,1,"Silverthorne, Mr. Spencer Victor",male,35,0,0,PC 17475,26.2875,E24,S
|
||||
703,0,3,"Barbara, Miss. Saiide",female,18,0,1,2691,14.4542,,C
|
||||
704,0,3,"Gallagher, Mr. Martin",male,25,0,0,36864,7.7417,,Q
|
||||
705,0,3,"Hansen, Mr. Henrik Juul",male,26,1,0,350025,7.8542,,S
|
||||
706,0,2,"Morley, Mr. Henry Samuel (""Mr Henry Marshall"")",male,39,0,0,250655,26,,S
|
||||
707,1,2,"Kelly, Mrs. Florence ""Fannie""",female,45,0,0,223596,13.5,,S
|
||||
708,1,1,"Calderhead, Mr. Edward Pennington",male,42,0,0,PC 17476,26.2875,E24,S
|
||||
709,1,1,"Cleaver, Miss. Alice",female,22,0,0,113781,151.55,,S
|
||||
710,1,3,"Moubarek, Master. Halim Gonios (""William George"")",male,,1,1,2661,15.2458,,C
|
||||
711,1,1,"Mayne, Mlle. Berthe Antonine (""Mrs de Villiers"")",female,24,0,0,PC 17482,49.5042,C90,C
|
||||
712,0,1,"Klaber, Mr. Herman",male,,0,0,113028,26.55,C124,S
|
||||
713,1,1,"Taylor, Mr. Elmer Zebley",male,48,1,0,19996,52,C126,S
|
||||
714,0,3,"Larsson, Mr. August Viktor",male,29,0,0,7545,9.4833,,S
|
||||
715,0,2,"Greenberg, Mr. Samuel",male,52,0,0,250647,13,,S
|
||||
716,0,3,"Soholt, Mr. Peter Andreas Lauritz Andersen",male,19,0,0,348124,7.65,F G73,S
|
||||
717,1,1,"Endres, Miss. Caroline Louise",female,38,0,0,PC 17757,227.525,C45,C
|
||||
718,1,2,"Troutt, Miss. Edwina Celia ""Winnie""",female,27,0,0,34218,10.5,E101,S
|
||||
719,0,3,"McEvoy, Mr. Michael",male,,0,0,36568,15.5,,Q
|
||||
720,0,3,"Johnson, Mr. Malkolm Joackim",male,33,0,0,347062,7.775,,S
|
||||
721,1,2,"Harper, Miss. Annie Jessie ""Nina""",female,6,0,1,248727,33,,S
|
||||
722,0,3,"Jensen, Mr. Svend Lauritz",male,17,1,0,350048,7.0542,,S
|
||||
723,0,2,"Gillespie, Mr. William Henry",male,34,0,0,12233,13,,S
|
||||
724,0,2,"Hodges, Mr. Henry Price",male,50,0,0,250643,13,,S
|
||||
725,1,1,"Chambers, Mr. Norman Campbell",male,27,1,0,113806,53.1,E8,S
|
||||
726,0,3,"Oreskovic, Mr. Luka",male,20,0,0,315094,8.6625,,S
|
||||
727,1,2,"Renouf, Mrs. Peter Henry (Lillian Jefferys)",female,30,3,0,31027,21,,S
|
||||
728,1,3,"Mannion, Miss. Margareth",female,,0,0,36866,7.7375,,Q
|
||||
729,0,2,"Bryhl, Mr. Kurt Arnold Gottfrid",male,25,1,0,236853,26,,S
|
||||
730,0,3,"Ilmakangas, Miss. Pieta Sofia",female,25,1,0,STON/O2. 3101271,7.925,,S
|
||||
731,1,1,"Allen, Miss. Elisabeth Walton",female,29,0,0,24160,211.3375,B5,S
|
||||
732,0,3,"Hassan, Mr. Houssein G N",male,11,0,0,2699,18.7875,,C
|
||||
733,0,2,"Knight, Mr. Robert J",male,,0,0,239855,0,,S
|
||||
734,0,2,"Berriman, Mr. William John",male,23,0,0,28425,13,,S
|
||||
735,0,2,"Troupiansky, Mr. Moses Aaron",male,23,0,0,233639,13,,S
|
||||
736,0,3,"Williams, Mr. Leslie",male,28.5,0,0,54636,16.1,,S
|
||||
737,0,3,"Ford, Mrs. Edward (Margaret Ann Watson)",female,48,1,3,W./C. 6608,34.375,,S
|
||||
738,1,1,"Lesurer, Mr. Gustave J",male,35,0,0,PC 17755,512.3292,B101,C
|
||||
739,0,3,"Ivanoff, Mr. Kanio",male,,0,0,349201,7.8958,,S
|
||||
740,0,3,"Nankoff, Mr. Minko",male,,0,0,349218,7.8958,,S
|
||||
741,1,1,"Hawksford, Mr. Walter James",male,,0,0,16988,30,D45,S
|
||||
742,0,1,"Cavendish, Mr. Tyrell William",male,36,1,0,19877,78.85,C46,S
|
||||
743,1,1,"Ryerson, Miss. Susan Parker ""Suzette""",female,21,2,2,PC 17608,262.375,B57 B59 B63 B66,C
|
||||
744,0,3,"McNamee, Mr. Neal",male,24,1,0,376566,16.1,,S
|
||||
745,1,3,"Stranden, Mr. Juho",male,31,0,0,STON/O 2. 3101288,7.925,,S
|
||||
746,0,1,"Crosby, Capt. Edward Gifford",male,70,1,1,WE/P 5735,71,B22,S
|
||||
747,0,3,"Abbott, Mr. Rossmore Edward",male,16,1,1,C.A. 2673,20.25,,S
|
||||
748,1,2,"Sinkkonen, Miss. Anna",female,30,0,0,250648,13,,S
|
||||
749,0,1,"Marvin, Mr. Daniel Warner",male,19,1,0,113773,53.1,D30,S
|
||||
750,0,3,"Connaghton, Mr. Michael",male,31,0,0,335097,7.75,,Q
|
||||
751,1,2,"Wells, Miss. Joan",female,4,1,1,29103,23,,S
|
||||
752,1,3,"Moor, Master. Meier",male,6,0,1,392096,12.475,E121,S
|
||||
753,0,3,"Vande Velde, Mr. Johannes Joseph",male,33,0,0,345780,9.5,,S
|
||||
754,0,3,"Jonkoff, Mr. Lalio",male,23,0,0,349204,7.8958,,S
|
||||
755,1,2,"Herman, Mrs. Samuel (Jane Laver)",female,48,1,2,220845,65,,S
|
||||
756,1,2,"Hamalainen, Master. Viljo",male,0.67,1,1,250649,14.5,,S
|
||||
757,0,3,"Carlsson, Mr. August Sigfrid",male,28,0,0,350042,7.7958,,S
|
||||
758,0,2,"Bailey, Mr. Percy Andrew",male,18,0,0,29108,11.5,,S
|
||||
759,0,3,"Theobald, Mr. Thomas Leonard",male,34,0,0,363294,8.05,,S
|
||||
760,1,1,"Rothes, the Countess. of (Lucy Noel Martha Dyer-Edwards)",female,33,0,0,110152,86.5,B77,S
|
||||
761,0,3,"Garfirth, Mr. John",male,,0,0,358585,14.5,,S
|
||||
762,0,3,"Nirva, Mr. Iisakki Antino Aijo",male,41,0,0,SOTON/O2 3101272,7.125,,S
|
||||
763,1,3,"Barah, Mr. Hanna Assi",male,20,0,0,2663,7.2292,,C
|
||||
764,1,1,"Carter, Mrs. William Ernest (Lucile Polk)",female,36,1,2,113760,120,B96 B98,S
|
||||
765,0,3,"Eklund, Mr. Hans Linus",male,16,0,0,347074,7.775,,S
|
||||
766,1,1,"Hogeboom, Mrs. John C (Anna Andrews)",female,51,1,0,13502,77.9583,D11,S
|
||||
767,0,1,"Brewe, Dr. Arthur Jackson",male,,0,0,112379,39.6,,C
|
||||
768,0,3,"Mangan, Miss. Mary",female,30.5,0,0,364850,7.75,,Q
|
||||
769,0,3,"Moran, Mr. Daniel J",male,,1,0,371110,24.15,,Q
|
||||
770,0,3,"Gronnestad, Mr. Daniel Danielsen",male,32,0,0,8471,8.3625,,S
|
||||
771,0,3,"Lievens, Mr. Rene Aime",male,24,0,0,345781,9.5,,S
|
||||
772,0,3,"Jensen, Mr. Niels Peder",male,48,0,0,350047,7.8542,,S
|
||||
773,0,2,"Mack, Mrs. (Mary)",female,57,0,0,S.O./P.P. 3,10.5,E77,S
|
||||
774,0,3,"Elias, Mr. Dibo",male,,0,0,2674,7.225,,C
|
||||
775,1,2,"Hocking, Mrs. Elizabeth (Eliza Needs)",female,54,1,3,29105,23,,S
|
||||
776,0,3,"Myhrman, Mr. Pehr Fabian Oliver Malkolm",male,18,0,0,347078,7.75,,S
|
||||
777,0,3,"Tobin, Mr. Roger",male,,0,0,383121,7.75,F38,Q
|
||||
778,1,3,"Emanuel, Miss. Virginia Ethel",female,5,0,0,364516,12.475,,S
|
||||
779,0,3,"Kilgannon, Mr. Thomas J",male,,0,0,36865,7.7375,,Q
|
||||
780,1,1,"Robert, Mrs. Edward Scott (Elisabeth Walton McMillan)",female,43,0,1,24160,211.3375,B3,S
|
||||
781,1,3,"Ayoub, Miss. Banoura",female,13,0,0,2687,7.2292,,C
|
||||
782,1,1,"Dick, Mrs. Albert Adrian (Vera Gillespie)",female,17,1,0,17474,57,B20,S
|
||||
783,0,1,"Long, Mr. Milton Clyde",male,29,0,0,113501,30,D6,S
|
||||
784,0,3,"Johnston, Mr. Andrew G",male,,1,2,W./C. 6607,23.45,,S
|
||||
785,0,3,"Ali, Mr. William",male,25,0,0,SOTON/O.Q. 3101312,7.05,,S
|
||||
786,0,3,"Harmer, Mr. Abraham (David Lishin)",male,25,0,0,374887,7.25,,S
|
||||
787,1,3,"Sjoblom, Miss. Anna Sofia",female,18,0,0,3101265,7.4958,,S
|
||||
788,0,3,"Rice, Master. George Hugh",male,8,4,1,382652,29.125,,Q
|
||||
789,1,3,"Dean, Master. Bertram Vere",male,1,1,2,C.A. 2315,20.575,,S
|
||||
790,0,1,"Guggenheim, Mr. Benjamin",male,46,0,0,PC 17593,79.2,B82 B84,C
|
||||
791,0,3,"Keane, Mr. Andrew ""Andy""",male,,0,0,12460,7.75,,Q
|
||||
792,0,2,"Gaskell, Mr. Alfred",male,16,0,0,239865,26,,S
|
||||
793,0,3,"Sage, Miss. Stella Anna",female,,8,2,CA. 2343,69.55,,S
|
||||
794,0,1,"Hoyt, Mr. William Fisher",male,,0,0,PC 17600,30.6958,,C
|
||||
795,0,3,"Dantcheff, Mr. Ristiu",male,25,0,0,349203,7.8958,,S
|
||||
796,0,2,"Otter, Mr. Richard",male,39,0,0,28213,13,,S
|
||||
797,1,1,"Leader, Dr. Alice (Farnham)",female,49,0,0,17465,25.9292,D17,S
|
||||
798,1,3,"Osman, Mrs. Mara",female,31,0,0,349244,8.6833,,S
|
||||
799,0,3,"Ibrahim Shawah, Mr. Yousseff",male,30,0,0,2685,7.2292,,C
|
||||
800,0,3,"Van Impe, Mrs. Jean Baptiste (Rosalie Paula Govaert)",female,30,1,1,345773,24.15,,S
|
||||
801,0,2,"Ponesell, Mr. Martin",male,34,0,0,250647,13,,S
|
||||
802,1,2,"Collyer, Mrs. Harvey (Charlotte Annie Tate)",female,31,1,1,C.A. 31921,26.25,,S
|
||||
803,1,1,"Carter, Master. William Thornton II",male,11,1,2,113760,120,B96 B98,S
|
||||
804,1,3,"Thomas, Master. Assad Alexander",male,0.42,0,1,2625,8.5167,,C
|
||||
805,1,3,"Hedman, Mr. Oskar Arvid",male,27,0,0,347089,6.975,,S
|
||||
806,0,3,"Johansson, Mr. Karl Johan",male,31,0,0,347063,7.775,,S
|
||||
807,0,1,"Andrews, Mr. Thomas Jr",male,39,0,0,112050,0,A36,S
|
||||
808,0,3,"Pettersson, Miss. Ellen Natalia",female,18,0,0,347087,7.775,,S
|
||||
809,0,2,"Meyer, Mr. August",male,39,0,0,248723,13,,S
|
||||
810,1,1,"Chambers, Mrs. Norman Campbell (Bertha Griggs)",female,33,1,0,113806,53.1,E8,S
|
||||
811,0,3,"Alexander, Mr. William",male,26,0,0,3474,7.8875,,S
|
||||
812,0,3,"Lester, Mr. James",male,39,0,0,A/4 48871,24.15,,S
|
||||
813,0,2,"Slemen, Mr. Richard James",male,35,0,0,28206,10.5,,S
|
||||
814,0,3,"Andersson, Miss. Ebba Iris Alfrida",female,6,4,2,347082,31.275,,S
|
||||
815,0,3,"Tomlin, Mr. Ernest Portage",male,30.5,0,0,364499,8.05,,S
|
||||
816,0,1,"Fry, Mr. Richard",male,,0,0,112058,0,B102,S
|
||||
817,0,3,"Heininen, Miss. Wendla Maria",female,23,0,0,STON/O2. 3101290,7.925,,S
|
||||
818,0,2,"Mallet, Mr. Albert",male,31,1,1,S.C./PARIS 2079,37.0042,,C
|
||||
819,0,3,"Holm, Mr. John Fredrik Alexander",male,43,0,0,C 7075,6.45,,S
|
||||
820,0,3,"Skoog, Master. Karl Thorsten",male,10,3,2,347088,27.9,,S
|
||||
821,1,1,"Hays, Mrs. Charles Melville (Clara Jennings Gregg)",female,52,1,1,12749,93.5,B69,S
|
||||
822,1,3,"Lulic, Mr. Nikola",male,27,0,0,315098,8.6625,,S
|
||||
823,0,1,"Reuchlin, Jonkheer. John George",male,38,0,0,19972,0,,S
|
||||
824,1,3,"Moor, Mrs. (Beila)",female,27,0,1,392096,12.475,E121,S
|
||||
825,0,3,"Panula, Master. Urho Abraham",male,2,4,1,3101295,39.6875,,S
|
||||
826,0,3,"Flynn, Mr. John",male,,0,0,368323,6.95,,Q
|
||||
827,0,3,"Lam, Mr. Len",male,,0,0,1601,56.4958,,S
|
||||
828,1,2,"Mallet, Master. Andre",male,1,0,2,S.C./PARIS 2079,37.0042,,C
|
||||
829,1,3,"McCormack, Mr. Thomas Joseph",male,,0,0,367228,7.75,,Q
|
||||
830,1,1,"Stone, Mrs. George Nelson (Martha Evelyn)",female,62,0,0,113572,80,B28,
|
||||
831,1,3,"Yasbeck, Mrs. Antoni (Selini Alexander)",female,15,1,0,2659,14.4542,,C
|
||||
832,1,2,"Richards, Master. George Sibley",male,0.83,1,1,29106,18.75,,S
|
||||
833,0,3,"Saad, Mr. Amin",male,,0,0,2671,7.2292,,C
|
||||
834,0,3,"Augustsson, Mr. Albert",male,23,0,0,347468,7.8542,,S
|
||||
835,0,3,"Allum, Mr. Owen George",male,18,0,0,2223,8.3,,S
|
||||
836,1,1,"Compton, Miss. Sara Rebecca",female,39,1,1,PC 17756,83.1583,E49,C
|
||||
837,0,3,"Pasic, Mr. Jakob",male,21,0,0,315097,8.6625,,S
|
||||
838,0,3,"Sirota, Mr. Maurice",male,,0,0,392092,8.05,,S
|
||||
839,1,3,"Chip, Mr. Chang",male,32,0,0,1601,56.4958,,S
|
||||
840,1,1,"Marechal, Mr. Pierre",male,,0,0,11774,29.7,C47,C
|
||||
841,0,3,"Alhomaki, Mr. Ilmari Rudolf",male,20,0,0,SOTON/O2 3101287,7.925,,S
|
||||
842,0,2,"Mudd, Mr. Thomas Charles",male,16,0,0,S.O./P.P. 3,10.5,,S
|
||||
843,1,1,"Serepeca, Miss. Augusta",female,30,0,0,113798,31,,C
|
||||
844,0,3,"Lemberopolous, Mr. Peter L",male,34.5,0,0,2683,6.4375,,C
|
||||
845,0,3,"Culumovic, Mr. Jeso",male,17,0,0,315090,8.6625,,S
|
||||
846,0,3,"Abbing, Mr. Anthony",male,42,0,0,C.A. 5547,7.55,,S
|
||||
847,0,3,"Sage, Mr. Douglas Bullen",male,,8,2,CA. 2343,69.55,,S
|
||||
848,0,3,"Markoff, Mr. Marin",male,35,0,0,349213,7.8958,,C
|
||||
849,0,2,"Harper, Rev. John",male,28,0,1,248727,33,,S
|
||||
850,1,1,"Goldenberg, Mrs. Samuel L (Edwiga Grabowska)",female,,1,0,17453,89.1042,C92,C
|
||||
851,0,3,"Andersson, Master. Sigvard Harald Elias",male,4,4,2,347082,31.275,,S
|
||||
852,0,3,"Svensson, Mr. Johan",male,74,0,0,347060,7.775,,S
|
||||
853,0,3,"Boulos, Miss. Nourelain",female,9,1,1,2678,15.2458,,C
|
||||
854,1,1,"Lines, Miss. Mary Conover",female,16,0,1,PC 17592,39.4,D28,S
|
||||
855,0,2,"Carter, Mrs. Ernest Courtenay (Lilian Hughes)",female,44,1,0,244252,26,,S
|
||||
856,1,3,"Aks, Mrs. Sam (Leah Rosen)",female,18,0,1,392091,9.35,,S
|
||||
857,1,1,"Wick, Mrs. George Dennick (Mary Hitchcock)",female,45,1,1,36928,164.8667,,S
|
||||
858,1,1,"Daly, Mr. Peter Denis ",male,51,0,0,113055,26.55,E17,S
|
||||
859,1,3,"Baclini, Mrs. Solomon (Latifa Qurban)",female,24,0,3,2666,19.2583,,C
|
||||
860,0,3,"Razi, Mr. Raihed",male,,0,0,2629,7.2292,,C
|
||||
861,0,3,"Hansen, Mr. Claus Peter",male,41,2,0,350026,14.1083,,S
|
||||
862,0,2,"Giles, Mr. Frederick Edward",male,21,1,0,28134,11.5,,S
|
||||
863,1,1,"Swift, Mrs. Frederick Joel (Margaret Welles Barron)",female,48,0,0,17466,25.9292,D17,S
|
||||
864,0,3,"Sage, Miss. Dorothy Edith ""Dolly""",female,,8,2,CA. 2343,69.55,,S
|
||||
865,0,2,"Gill, Mr. John William",male,24,0,0,233866,13,,S
|
||||
866,1,2,"Bystrom, Mrs. (Karolina)",female,42,0,0,236852,13,,S
|
||||
867,1,2,"Duran y More, Miss. Asuncion",female,27,1,0,SC/PARIS 2149,13.8583,,C
|
||||
868,0,1,"Roebling, Mr. Washington Augustus II",male,31,0,0,PC 17590,50.4958,A24,S
|
||||
869,0,3,"van Melkebeke, Mr. Philemon",male,,0,0,345777,9.5,,S
|
||||
870,1,3,"Johnson, Master. Harold Theodor",male,4,1,1,347742,11.1333,,S
|
||||
871,0,3,"Balkic, Mr. Cerin",male,26,0,0,349248,7.8958,,S
|
||||
872,1,1,"Beckwith, Mrs. Richard Leonard (Sallie Monypeny)",female,47,1,1,11751,52.5542,D35,S
|
||||
873,0,1,"Carlsson, Mr. Frans Olof",male,33,0,0,695,5,B51 B53 B55,S
|
||||
874,0,3,"Vander Cruyssen, Mr. Victor",male,47,0,0,345765,9,,S
|
||||
875,1,2,"Abelson, Mrs. Samuel (Hannah Wizosky)",female,28,1,0,P/PP 3381,24,,C
|
||||
876,1,3,"Najib, Miss. Adele Kiamie ""Jane""",female,15,0,0,2667,7.225,,C
|
||||
877,0,3,"Gustafsson, Mr. Alfred Ossian",male,20,0,0,7534,9.8458,,S
|
||||
878,0,3,"Petroff, Mr. Nedelio",male,19,0,0,349212,7.8958,,S
|
||||
879,0,3,"Laleff, Mr. Kristo",male,,0,0,349217,7.8958,,S
|
||||
880,1,1,"Potter, Mrs. Thomas Jr (Lily Alexenia Wilson)",female,56,0,1,11767,83.1583,C50,C
|
||||
881,1,2,"Shelley, Mrs. William (Imanita Parrish Hall)",female,25,0,1,230433,26,,S
|
||||
882,0,3,"Markun, Mr. Johann",male,33,0,0,349257,7.8958,,S
|
||||
883,0,3,"Dahlberg, Miss. Gerda Ulrika",female,22,0,0,7552,10.5167,,S
|
||||
884,0,2,"Banfield, Mr. Frederick James",male,28,0,0,C.A./SOTON 34068,10.5,,S
|
||||
885,0,3,"Sutehall, Mr. Henry Jr",male,25,0,0,SOTON/OQ 392076,7.05,,S
|
||||
886,0,3,"Rice, Mrs. William (Margaret Norton)",female,39,0,5,382652,29.125,,Q
|
||||
887,0,2,"Montvila, Rev. Juozas",male,27,0,0,211536,13,,S
|
||||
888,1,1,"Graham, Miss. Margaret Edith",female,19,0,0,112053,30,B42,S
|
||||
889,0,3,"Johnston, Miss. Catherine Helen ""Carrie""",female,,1,2,W./C. 6607,23.45,,S
|
||||
890,1,1,"Behr, Mr. Karl Howell",male,26,0,0,111369,30,C148,C
|
||||
891,0,3,"Dooley, Mr. Patrick",male,32,0,0,370376,7.75,,Q
|
|
Binary file not shown.
Binary file not shown.
@ -1,43 +0,0 @@
|
||||
# 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 `templates` directory.
|
||||
|
||||
Make sure you have `langchain-cli` installed.
|
||||
|
||||
```shell
|
||||
pip install -U langchain-cli
|
||||
```
|
||||
|
||||
You can then run the following command to create a new skeleton of a package.
|
||||
By convention, package names should use `-` delimiters (not `_`).
|
||||
|
||||
```shell
|
||||
langchain template 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.
|
@ -1,80 +0,0 @@
|
||||
# Templates
|
||||
|
||||
Highlighting a few different categories of templates
|
||||
|
||||
## ⭐ Popular
|
||||
|
||||
These are some of the more popular templates to get started with.
|
||||
|
||||
- [Retrieval Augmented Generation Chatbot](../rag-conversation): Build a chatbot over your data. Defaults to OpenAI and PineconeVectorStore.
|
||||
- [Extraction with OpenAI Functions](../extraction-openai-functions): Do extraction of structured data from unstructured data. Uses OpenAI function calling.
|
||||
- [Local Retrieval Augmented Generation](../rag-chroma-private): Build a chatbot over your data. Uses only local tooling: Ollama, GPT4all, Chroma.
|
||||
- [OpenAI Functions Agent](../openai-functions-agent): Build a chatbot that can take actions. Uses OpenAI function calling and Tavily.
|
||||
- [XML Agent](../xml-agent): Build a chatbot that can take actions. Uses Anthropic and You.com.
|
||||
|
||||
|
||||
## 📥 Advanced Retrieval
|
||||
|
||||
These templates cover advanced retrieval techniques, which can be used for chat and QA over databases or documents.
|
||||
|
||||
- [Reranking](../rag-pinecone-rerank): This retrieval technique uses Cohere's reranking endpoint to rerank documents from an initial retrieval step.
|
||||
- [Anthropic Iterative Search](../anthropic-iterative-search): This retrieval technique uses iterative prompting to determine what to retrieve and whether the retriever documents are good enough.
|
||||
- **Parent Document Retrieval** using [Neo4j](../neo4j-parent) or [MongoDB](../mongo-parent-document-retrieval): This retrieval technique stores embeddings for smaller chunks, but then returns larger chunks to pass to the model for generation.
|
||||
- [Semi-Structured RAG](../rag-semi-structured): The template shows how to do retrieval over semi-structured data (e.g. data that involves both text and tables).
|
||||
- [Temporal RAG](../rag-timescale-hybrid-search-time): The template shows how to do hybrid search over data with a time-based component using [Timescale Vector](https://www.timescale.com/ai?utm_campaign=vectorlaunch&utm_source=langchain&utm_medium=referral).
|
||||
|
||||
## 🔍Advanced Retrieval - Query Transformation
|
||||
|
||||
A selection of advanced retrieval methods that involve transforming the original user query, which can improve retrieval quality.
|
||||
|
||||
- [Hypothetical Document Embeddings](../hyde): A retrieval technique that generates a hypothetical document for a given query, and then uses the embedding of that document to do semantic search. [Paper](https://arxiv.org/abs/2212.10496).
|
||||
- [Rewrite-Retrieve-Read](../rewrite-retrieve-read): A retrieval technique that rewrites a given query before passing it to a search engine. [Paper](https://arxiv.org/abs/2305.14283).
|
||||
- [Step-back QA Prompting](../stepback-qa-prompting): A retrieval technique that generates a "step-back" question and then retrieves documents relevant to both that question and the original question. [Paper](https://arxiv.org/abs//2310.06117).
|
||||
- [RAG-Fusion](../rag-fusion): A retrieval technique that generates multiple queries and then reranks the retrieved documents using reciprocal rank fusion. [Article](https://towardsdatascience.com/forget-rag-the-future-is-rag-fusion-1147298d8ad1).
|
||||
- [Multi-Query Retriever](../rag-pinecone-multi-query): This retrieval technique uses an LLM to generate multiple queries and then fetches documents for all queries.
|
||||
|
||||
|
||||
## 🧠Advanced Retrieval - Query Construction
|
||||
|
||||
A selection of advanced retrieval methods that involve constructing a query in a separate DSL from natural language, which enable natural language chat over various structured databases.
|
||||
|
||||
- [Elastic Query Generator](../elastic-query-generator): Generate elastic search queries from natural language.
|
||||
- [Neo4j Cypher Generation](../neo4j-cypher): Generate cypher statements from natural language. Available with a ["full text" option](../neo4j-cypher-ft) as well.
|
||||
- [Supabase Self Query](../self-query-supabase): Parse a natural language query into a semantic query as well as a metadata filter for Supabase.
|
||||
|
||||
## 🦙 OSS Models
|
||||
|
||||
These templates use OSS models, which enable privacy for sensitive data.
|
||||
|
||||
- [Local Retrieval Augmented Generation](../rag-chroma-private): Build a chatbot over your data. Uses only local tooling: Ollama, GPT4all, Chroma.
|
||||
- [SQL Question Answering (Replicate)](../sql-llama2): Question answering over a SQL database, using Llama2 hosted on [Replicate](https://replicate.com/).
|
||||
- [SQL Question Answering (LlamaCpp)](../sql-llamacpp): Question answering over a SQL database, using Llama2 through [LlamaCpp](https://github.com/ggerganov/llama.cpp).
|
||||
- [SQL Question Answering (Ollama)](../sql-ollama): Question answering over a SQL database, using Llama2 through [Ollama](https://github.com/jmorganca/ollama).
|
||||
|
||||
## ⛏️ Extraction
|
||||
|
||||
These templates extract data in a structured format based upon a user-specified schema.
|
||||
|
||||
- [Extraction Using OpenAI Functions](../extraction-openai-functions): Extract information from text using OpenAI Function Calling.
|
||||
- [Extraction Using Anthropic Functions](../extraction-anthropic-functions): Extract information from text using a LangChain wrapper around the Anthropic endpoints intended to simulate function calling.
|
||||
- [Extract BioTech Plate Data](../plate-chain): Extract microplate data from messy Excel spreadsheets into a more normalized format.
|
||||
|
||||
## ⛏️Summarization and tagging
|
||||
|
||||
These templates summarize or categorize documents and text.
|
||||
|
||||
- [Summarization using Anthropic](../summarize-anthropic): Uses Anthropic's Claude2 to summarize long documents.
|
||||
|
||||
## 🤖 Agents
|
||||
|
||||
These templates build chatbots that can take actions, helping to automate tasks.
|
||||
|
||||
- [OpenAI Functions Agent](../openai-functions-agent): Build a chatbot that can take actions. Uses OpenAI function calling and Tavily.
|
||||
- [XML Agent](../xml-agent): Build a chatbot that can take actions. Uses Anthropic and You.com.
|
||||
|
||||
## :rotating_light: Safety and evaluation
|
||||
|
||||
These templates enable moderation or evaluation of LLM outputs.
|
||||
|
||||
- [Guardrails Output Parser](../guardrails-output-parser): Use guardrails-ai to validate LLM output.
|
||||
- [Chatbot Feedback](../chat-bot-feedback): Use LangSmith to evaluate chatbot responses.
|
@ -1,41 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
|
||||
You can then run:
|
||||
|
||||
```shell
|
||||
langchain template serve
|
||||
```
|
||||
|
||||
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/)
|
||||
|
||||
 "LangServe Playground Interface"
|
Binary file not shown.
Before ![]() (image error) Size: 173 KiB |
Binary file not shown.
Before ![]() (image error) Size: 130 KiB |
@ -1,86 +0,0 @@
|
||||
# Elasticsearch - query generator
|
||||
|
||||
This template allows interacting with `Elasticsearch` analytics databases
|
||||
in natural language using LLMs.
|
||||
|
||||
It builds search queries via the `Elasticsearch DSL API` (filters and aggregations).
|
||||
|
||||
## Environment Setup
|
||||
|
||||
Set the `OPENAI_API_KEY` environment variable to access the OpenAI models.
|
||||
|
||||
### Installing Elasticsearch
|
||||
|
||||
There are a number of ways to run Elasticsearch. However, one recommended way is through Elastic Cloud.
|
||||
|
||||
Create a free trial account on [Elastic Cloud](https://cloud.elastic.co/registration?utm_source=langchain&utm_content=langserve).
|
||||
|
||||
With a deployment, update the connection string.
|
||||
|
||||
Password and connection (elasticsearch url) can be found on the deployment console.
|
||||
|
||||
Note that the Elasticsearch client must have permissions for index listing, mapping description, and search queries.
|
||||
|
||||
### Populating with data
|
||||
|
||||
If you want to populate the DB with some example info, you can run `python ingest.py`.
|
||||
|
||||
This will create a `customers` index. In this package, we specify indexes to generate queries against, and we specify `["customers"]`. This is specific to setting up your Elastic index.
|
||||
|
||||
## Usage
|
||||
|
||||
To use this package, you should first have the LangChain CLI installed:
|
||||
|
||||
```shell
|
||||
pip install -U langchain-cli
|
||||
```
|
||||
|
||||
To create a new LangChain project and install this as the only package, you can do:
|
||||
|
||||
```shell
|
||||
langchain app new my-app --package elastic-query-generator
|
||||
```
|
||||
|
||||
If you want to add this to an existing project, you can just run:
|
||||
|
||||
```shell
|
||||
langchain app add elastic-query-generator
|
||||
```
|
||||
|
||||
And add the following code to your `server.py` file:
|
||||
```python
|
||||
from elastic_query_generator.chain import chain as elastic_query_generator_chain
|
||||
|
||||
add_routes(app, elastic_query_generator_chain, path="/elastic-query-generator")
|
||||
```
|
||||
|
||||
(Optional) Let's now configure LangSmith.
|
||||
LangSmith will help us trace, monitor and debug LangChain applications.
|
||||
You can sign up for LangSmith [here](https://smith.langchain.com/).
|
||||
If you don't have access, you can skip this section
|
||||
|
||||
```shell
|
||||
export LANGCHAIN_TRACING_V2=true
|
||||
export LANGCHAIN_API_KEY=<your-api-key>
|
||||
export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
|
||||
```
|
||||
|
||||
If you are inside this directory, then you can spin up a LangServe instance directly by:
|
||||
|
||||
```shell
|
||||
langchain serve
|
||||
```
|
||||
|
||||
This will start the FastAPI app with a server is running locally at
|
||||
[http://localhost:8000](http://localhost:8000)
|
||||
|
||||
We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
|
||||
We can access the playground at [http://127.0.0.1:8000/elastic-query-generator/playground](http://127.0.0.1:8000/elastic-query-generator/playground)
|
||||
|
||||
We can access the template from code with:
|
||||
|
||||
```python
|
||||
from langserve.client import RemoteRunnable
|
||||
|
||||
runnable = RemoteRunnable("http://localhost:8000/elastic-query-generator")
|
||||
```
|
@ -1,5 +0,0 @@
|
||||
from elastic_query_generator.chain import chain
|
||||
|
||||
__all__ = [
|
||||
"chain",
|
||||
]
|
@ -1,51 +0,0 @@
|
||||
from elasticsearch import Elasticsearch
|
||||
from langchain.output_parsers.json import SimpleJsonOutputParser
|
||||
from langchain_community.chat_models import ChatOpenAI
|
||||
from langchain_core.pydantic_v1 import BaseModel
|
||||
|
||||
from .elastic_index_info import get_indices_infos
|
||||
from .prompts import DSL_PROMPT
|
||||
|
||||
# Setup Elasticsearch
|
||||
# This shows how to set it up for a cloud hosted version
|
||||
|
||||
# Password for the 'elastic' user generated by Elasticsearch
|
||||
ELASTIC_PASSWORD = "..."
|
||||
|
||||
# Found in the 'Manage Deployment' page
|
||||
CLOUD_ID = "..."
|
||||
|
||||
# Create the client instance
|
||||
db = Elasticsearch(cloud_id=CLOUD_ID, basic_auth=("elastic", ELASTIC_PASSWORD))
|
||||
|
||||
# Specify indices to include
|
||||
# If you want to use on your own indices, you will need to change this.
|
||||
INCLUDE_INDICES = ["customers"]
|
||||
|
||||
# With the Elasticsearch connection created, we can now move on to the chain
|
||||
|
||||
_model = ChatOpenAI(temperature=0, model="gpt-4")
|
||||
|
||||
chain = (
|
||||
{
|
||||
"input": lambda x: x["input"],
|
||||
# This line only get index info for "customers" index.
|
||||
# If you are running this on your own data, you will want to change.
|
||||
"indices_info": lambda _: get_indices_infos(
|
||||
db, include_indices=INCLUDE_INDICES
|
||||
),
|
||||
"top_k": lambda x: x.get("top_k", 5),
|
||||
}
|
||||
| DSL_PROMPT
|
||||
| _model
|
||||
| SimpleJsonOutputParser()
|
||||
)
|
||||
|
||||
|
||||
# Nicely typed inputs for playground
|
||||
class ChainInputs(BaseModel):
|
||||
input: str
|
||||
top_k: int = 5
|
||||
|
||||
|
||||
chain = chain.with_types(input_type=ChainInputs)
|
@ -1,39 +0,0 @@
|
||||
from typing import List
|
||||
|
||||
|
||||
def _list_indices(database, include_indices=None, ignore_indices=None) -> List[str]:
|
||||
all_indices = [index["index"] for index in database.cat.indices(format="json")]
|
||||
|
||||
if include_indices:
|
||||
all_indices = [i for i in all_indices if i in include_indices]
|
||||
if ignore_indices:
|
||||
all_indices = [i for i in all_indices if i not in ignore_indices]
|
||||
|
||||
return all_indices
|
||||
|
||||
|
||||
def get_indices_infos(
|
||||
database,
|
||||
sample_documents_in_index_info=5,
|
||||
include_indices=None,
|
||||
ignore_indices=None,
|
||||
) -> str:
|
||||
indices = _list_indices(
|
||||
database, include_indices=include_indices, ignore_indices=ignore_indices
|
||||
)
|
||||
mappings = database.indices.get_mapping(index=",".join(indices))
|
||||
if sample_documents_in_index_info > 0:
|
||||
for k, v in mappings.items():
|
||||
hits = database.search(
|
||||
index=k,
|
||||
query={"match_all": {}},
|
||||
size=sample_documents_in_index_info,
|
||||
)["hits"]["hits"]
|
||||
hits = [str(hit["_source"]) for hit in hits]
|
||||
mappings[k]["mappings"] = str(v) + "\n\n/*\n" + "\n".join(hits) + "\n*/"
|
||||
return "\n\n".join(
|
||||
[
|
||||
"Mapping for index {}:\n{}".format(index, mappings[index]["mappings"])
|
||||
for index in mappings
|
||||
]
|
||||
)
|
@ -1,21 +0,0 @@
|
||||
from langchain_core.prompts.prompt import PromptTemplate
|
||||
|
||||
PROMPT_SUFFIX = """Only use the following Elasticsearch indices:
|
||||
{indices_info}
|
||||
|
||||
Question: {input}
|
||||
ESQuery:"""
|
||||
|
||||
DEFAULT_DSL_TEMPLATE = """Given an input question, create a syntactically correct Elasticsearch query to run. Always limit your query to at most {top_k} results, unless the user specifies in their question a specific number of examples they wish to obtain, or unless its implied that they want to see all. You can order the results by a relevant column to return the most interesting examples in the database.
|
||||
|
||||
Unless told to do not query for all the columns from a specific index, only ask for a the few relevant columns given the question.
|
||||
|
||||
Pay attention to use only the column names that you can see in the mapping description. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which index. Return the query as valid json.
|
||||
|
||||
Use the following format:
|
||||
|
||||
Question: Question here
|
||||
ESQuery: Elasticsearch Query formatted as json
|
||||
""" # noqa: E501
|
||||
|
||||
DSL_PROMPT = PromptTemplate.from_template(DEFAULT_DSL_TEMPLATE + PROMPT_SUFFIX)
|
@ -1,23 +0,0 @@
|
||||
from elasticsearch import Elasticsearch
|
||||
|
||||
# Setup Elasticsearch
|
||||
# This shows how to set it up for a cloud hosted version
|
||||
|
||||
# Password for the 'elastic' user generated by Elasticsearch
|
||||
ELASTIC_PASSWORD = "..."
|
||||
|
||||
# Found in the 'Manage Deployment' page
|
||||
CLOUD_ID = "..."
|
||||
|
||||
# Create the client instance
|
||||
db = Elasticsearch(cloud_id=CLOUD_ID, basic_auth=("elastic", ELASTIC_PASSWORD))
|
||||
|
||||
customers = [
|
||||
{"firstname": "Jennifer", "lastname": "Walters"},
|
||||
{"firstname": "Monica", "lastname": "Rambeau"},
|
||||
{"firstname": "Carol", "lastname": "Danvers"},
|
||||
{"firstname": "Wanda", "lastname": "Maximoff"},
|
||||
{"firstname": "Jennifer", "lastname": "Takeda"},
|
||||
]
|
||||
for i, customer in enumerate(customers):
|
||||
db.create(index="customers", document=customer, id=i)
|
@ -1,4 +0,0 @@
|
||||
from elastic_query_generator.chain import chain
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(chain.invoke({"input": "how many customers named Carol"}))
|
@ -1,31 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "elastic-query-generator"
|
||||
version = "0.0.1"
|
||||
description = "Interact with Elasticsearch analytics databases using natural language"
|
||||
authors = []
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.8.1,<4.0"
|
||||
langchain = "^0.1"
|
||||
elasticsearch = "^8.10.1"
|
||||
openai = "<2"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
langchain-cli = ">=0.0.21"
|
||||
|
||||
[tool.langserve]
|
||||
export_module = "elastic_query_generator"
|
||||
export_attr = "chain"
|
||||
|
||||
[tool.templates-hub]
|
||||
use-case = "query"
|
||||
author = "LangChain"
|
||||
integrations = ["Elasticsearch", "OpenAI"]
|
||||
tags = ["query-generation"]
|
||||
|
||||
[build-system]
|
||||
requires = [
|
||||
"poetry-core",
|
||||
]
|
||||
build-backend = "poetry.core.masonry.api"
|
@ -1,21 +0,0 @@
|
||||
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.
|
@ -1,74 +0,0 @@
|
||||
# Extraction - Anthropic functions
|
||||
|
||||
This template enables [Anthropic function calling](https://python.langchain.com/docs/integrations/chat/anthropic_functions).
|
||||
|
||||
This can be used for various tasks, such as extraction or tagging.
|
||||
|
||||
The function output schema can be set in `chain.py`.
|
||||
|
||||
## Environment Setup
|
||||
|
||||
Set the `ANTHROPIC_API_KEY` environment variable to access the Anthropic models.
|
||||
|
||||
## Usage
|
||||
|
||||
To use this package, you should first have the LangChain CLI installed:
|
||||
|
||||
```shell
|
||||
pip install -U langchain-cli
|
||||
```
|
||||
|
||||
To create a new LangChain project and install this as the only package, you can do:
|
||||
|
||||
```shell
|
||||
langchain app new my-app --package extraction-anthropic-functions
|
||||
```
|
||||
|
||||
If you want to add this to an existing project, you can just run:
|
||||
|
||||
```shell
|
||||
langchain app add extraction-anthropic-functions
|
||||
```
|
||||
|
||||
And add the following code to your `server.py` file:
|
||||
```python
|
||||
from extraction_anthropic_functions import chain as extraction_anthropic_functions_chain
|
||||
|
||||
add_routes(app, extraction_anthropic_functions_chain, path="/extraction-anthropic-functions")
|
||||
```
|
||||
|
||||
(Optional) Let's now configure LangSmith.
|
||||
LangSmith will help us trace, monitor and debug LangChain applications.
|
||||
You can sign up for LangSmith [here](https://smith.langchain.com/).
|
||||
If you don't have access, you can skip this section
|
||||
|
||||
|
||||
```shell
|
||||
export LANGCHAIN_TRACING_V2=true
|
||||
export LANGCHAIN_API_KEY=<your-api-key>
|
||||
export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
|
||||
```
|
||||
|
||||
If you are inside this directory, then you can spin up a LangServe instance directly by:
|
||||
|
||||
```shell
|
||||
langchain serve
|
||||
```
|
||||
|
||||
This will start the FastAPI app with a server is running locally at
|
||||
[http://localhost:8000](http://localhost:8000)
|
||||
|
||||
We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
|
||||
We can access the playground at [http://127.0.0.1:8000/extraction-anthropic-functions/playground](http://127.0.0.1:8000/extraction-anthropic-functions/playground)
|
||||
|
||||
We can access the template from code with:
|
||||
|
||||
```python
|
||||
from langserve.client import RemoteRunnable
|
||||
|
||||
runnable = RemoteRunnable("http://localhost:8000/extraction-anthropic-functions")
|
||||
```
|
||||
|
||||
By default, the package will extract the title and author of papers from the information you specify in `chain.py`. This template will use `Claude2` by default.
|
||||
|
||||
---
|
@ -1,76 +0,0 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "4ae4b789",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Document Loading\n",
|
||||
"\n",
|
||||
"Load a blog post on agents."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "5d6bd62e",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langchain_community.document_loaders import WebBaseLoader\n",
|
||||
"\n",
|
||||
"loader = WebBaseLoader(\"https://lilianweng.github.io/posts/2023-06-23-agent/\")\n",
|
||||
"text = loader.load()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "8e21575d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Run Template\n",
|
||||
"\n",
|
||||
"In `server.py`, set -\n",
|
||||
"```\n",
|
||||
"add_routes(app, chain_ext, path=\"/extraction-anthropic-functions\")\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "5fd794ec-a002-490e-8eb9-06ce3e6c2f14",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langserve.client import RemoteRunnable\n",
|
||||
"\n",
|
||||
"anthropic_function_model = RemoteRunnable(\n",
|
||||
" \"http://localhost:8001/extraction-anthropic-functions\"\n",
|
||||
")\n",
|
||||
"anthropic_function_model.invoke(text[0].page_content[0:1500])"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "langserve",
|
||||
"language": "python",
|
||||
"name": "langserve"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.16"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
from extraction_anthropic_functions.chain import chain
|
||||
|
||||
__all__ = ["chain"]
|
@ -1,40 +0,0 @@
|
||||
from typing import List, Optional
|
||||
|
||||
from langchain.utils.openai_functions import convert_pydantic_to_openai_function
|
||||
from langchain_core.output_parsers.openai_functions import JsonKeyOutputFunctionsParser
|
||||
from langchain_core.prompts import ChatPromptTemplate
|
||||
from langchain_core.pydantic_v1 import BaseModel
|
||||
from langchain_experimental.llms.anthropic_functions import AnthropicFunctions
|
||||
|
||||
template = """A article will be passed to you. Extract from it all papers that are mentioned by this article.
|
||||
|
||||
Do not extract the name of the article itself. If no papers are mentioned that's fine - you don't need to extract any! Just return an empty list.
|
||||
|
||||
Do not make up or guess ANY extra information. Only extract what exactly is in the text.""" # noqa: E501
|
||||
|
||||
prompt = ChatPromptTemplate.from_messages([("system", template), ("human", "{input}")])
|
||||
|
||||
|
||||
# Function output schema
|
||||
class Paper(BaseModel):
|
||||
"""Information about papers mentioned."""
|
||||
|
||||
title: str
|
||||
author: Optional[str]
|
||||
|
||||
|
||||
class Info(BaseModel):
|
||||
"""Information to extract"""
|
||||
|
||||
papers: List[Paper]
|
||||
|
||||
|
||||
# Function definition
|
||||
model = AnthropicFunctions()
|
||||
function = [convert_pydantic_to_openai_function(Info)]
|
||||
|
||||
chain = (
|
||||
prompt
|
||||
| model.bind(functions=function, function_call={"name": "Info"})
|
||||
| JsonKeyOutputFunctionsParser(key_name="papers")
|
||||
)
|
@ -1,34 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "extraction-anthropic-functions"
|
||||
version = "0.1.0"
|
||||
description = "Use Anthropic function calling for tasks like extraction or tagging"
|
||||
authors = [
|
||||
"Lance Martin <lance@langchain.dev>",
|
||||
]
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.8.1,<4.0"
|
||||
langchain = "^0.1"
|
||||
anthropic = ">=0.5.0"
|
||||
langchainhub = ">=0.1.13"
|
||||
langchain-experimental = ">=0.0.54"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
langchain-cli = ">=0.0.21"
|
||||
|
||||
[tool.langserve]
|
||||
export_module = "extraction_anthropic_functions"
|
||||
export_attr = "chain"
|
||||
|
||||
[tool.templates-hub]
|
||||
use-case = "extraction"
|
||||
author = "LangChain"
|
||||
integrations = ["Anthropic", "Function Calling"]
|
||||
tags = ["function-calling", "tagging", "extraction"]
|
||||
|
||||
[build-system]
|
||||
requires = [
|
||||
"poetry-core",
|
||||
]
|
||||
build-backend = "poetry.core.masonry.api"
|
@ -1,21 +0,0 @@
|
||||
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.
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user