-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from hwchase17/harrison/add_readme
Harrison/add readme
- Loading branch information
Showing
8 changed files
with
245 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,56 @@ | ||
# LangChain | ||
# 🦜️🔗 LangChain | ||
|
||
⚡ Building applications with LLMs through composability ⚡ | ||
|
||
[![lint](https://github.com/hwchase17/langchain/actions/workflows/lint.yml/badge.svg)](https://github.com/hwchase17/langchain/actions/workflows/lint.yml) [![test](https://github.com/hwchase17/langchain/actions/workflows/test.yml/badge.svg)](https://github.com/hwchase17/langchain/actions/workflows/test.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
|
||
|
||
|
||
## Quick Install | ||
|
||
`pip install langchain` | ||
|
||
## 🤔 What is this? | ||
|
||
Large language models (LLMs) are emerging as a transformative technology, enabling | ||
developers to build applications that they previously could not. | ||
But using these LLMs in isolation is often not enough to | ||
create a truly powerful app - the real power comes when you are able to | ||
combine them with other sources of computation or knowledge. | ||
|
||
This library is aimed at assisting in the development of those types of applications. | ||
It aims to create: | ||
1. a comprehensive collection of pieces you would ever want to combine | ||
2. a flexible interface for combining pieces into a single comprehensive "chain" | ||
3. a schema for easily saving and sharing those chains | ||
|
||
## 🚀 What can I do with this | ||
|
||
This project was largely inspired by a few projects seen on Twitter for which we thought it would make sense to have more explicit tooling. A lot of the initial functionality was done in an attempt to recreate those. Those are: | ||
|
||
**[Self-ask-with-search](https://ofir.io/self-ask.pdf)** | ||
|
||
To recreate this paper, use the following code snippet or checkout the [example notebook](examples/self_ask_with_search.ipynb). | ||
|
||
``` | ||
from langchain import SelfAskWithSearchChain, OpenAI, SerpAPIChain | ||
llm = OpenAI(temperature=0) | ||
search = SerpAPIChain() | ||
self_ask_with_search = SelfAskWithSearchChain(llm=llm, search_chain=search) | ||
self_ask_with_search.run("What is the hometown of the reigning men's U.S. Open champion?") | ||
``` | ||
|
||
**[LLM Math](https://twitter.com/amasad/status/1568824744367259648?s=20&t=-7wxpXBJinPgDuyHLouP1w)** | ||
To recreate this example, use the following code snippet or check out the [example notebook](examples/llm_math.ipynb). | ||
|
||
``` | ||
from langchain import OpenAI, LLMMathChain | ||
llm = OpenAI(temperature=0) | ||
llm_math = LLMMathChain(llm=llm) | ||
llm_math.run("How many of the integers between 0 and 99 inclusive are divisible by 8?") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "44e9ba31", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"'Answer: 13\\n'" | ||
] | ||
}, | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"from langchain import OpenAI, LLMMathChain\n", | ||
"\n", | ||
"llm = OpenAI(temperature=0)\n", | ||
"llm_math = LLMMathChain(llm=llm)\n", | ||
"\n", | ||
"llm_math.run(\"How many of the integers between 0 and 99 inclusive are divisible by 8?\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "f62f0c75", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"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.7.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "7e3b513e", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"What is the hometown of the reigning men's U.S. Open champion?\n", | ||
"Are follow up questions needed here:\u001b[102m Yes.\n", | ||
"Follow up: Who is the reigning men's U.S. Open champion?\u001b[0m\n", | ||
"Intermediate answer: \u001b[106mCarlos Alcaraz\u001b[0m.\u001b[102m\n", | ||
"Follow up: Where is Carlos Alcaraz from?\u001b[0m\n", | ||
"Intermediate answer: \u001b[106mEl Palmar, Murcia, Spain\u001b[0m.\u001b[102m\n", | ||
"So the final answer is: El Palmar, Murcia, Spain\u001b[0m" | ||
] | ||
}, | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"\"What is the hometown of the reigning men's U.S. Open champion?\\nAre follow up questions needed here: Yes.\\nFollow up: Who is the reigning men's U.S. Open champion?\\nIntermediate answer: Carlos Alcaraz.\\nFollow up: Where is Carlos Alcaraz from?\\nIntermediate answer: El Palmar, Murcia, Spain.\\nSo the final answer is: El Palmar, Murcia, Spain\"" | ||
] | ||
}, | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"from langchain import SelfAskWithSearchChain, OpenAI, SerpAPIChain\n", | ||
"\n", | ||
"llm = OpenAI(temperature=0)\n", | ||
"search = SerpAPIChain()\n", | ||
"\n", | ||
"self_ask_with_search = SelfAskWithSearchChain(llm=llm, search_chain=search)\n", | ||
"\n", | ||
"self_ask_with_search.run(\"What is the hometown of the reigning men's U.S. Open champion?\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6195fc82", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"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.7.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,21 @@ | ||
"""Main entrypoint into package.""" | ||
from langchain.chains import ( | ||
LLMChain, | ||
LLMMathChain, | ||
PythonChain, | ||
SelfAskWithSearchChain, | ||
SerpAPIChain, | ||
) | ||
from langchain.llms import Cohere, OpenAI | ||
from langchain.prompt import Prompt | ||
|
||
__all__ = [ | ||
"LLMChain", | ||
"LLMMathChain", | ||
"PythonChain", | ||
"SelfAskWithSearchChain", | ||
"SerpAPIChain", | ||
"Cohere", | ||
"OpenAI", | ||
"Prompt", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
"""Chains are easily reusable components which can be linked together.""" | ||
from langchain.chains.llm import LLMChain | ||
from langchain.chains.llm_math.base import LLMMathChain | ||
from langchain.chains.python import PythonChain | ||
from langchain.chains.self_ask_with_search.base import SelfAskWithSearchChain | ||
from langchain.chains.serpapi import SerpAPIChain | ||
|
||
__all__ = [ | ||
"LLMChain", | ||
"LLMMathChain", | ||
"PythonChain", | ||
"SelfAskWithSearchChain", | ||
"SerpAPIChain", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
"""Wrappers on top of large language models.""" | ||
from langchain.llms.cohere import Cohere | ||
from langchain.llms.openai import OpenAI | ||
|
||
__all__ = ["Cohere", "OpenAI"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters