Skip to content

Commit 7e4708d

Browse files
committed
fix merge conflicts
2 parents 231e5be + 146402e commit 7e4708d

File tree

10 files changed

+93
-49
lines changed

10 files changed

+93
-49
lines changed

concepts/watcher.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ The -w (watch) command line option can be passed to the chainlit run command to
55
When this option is specified, the file watcher will be started and any changes to files will cause the server to reload the app, allowing faster iterations.
66

77
```bash
8-
$ chainlit run app.py -w
8+
chainlit run app.py -w
99
```

examples/auto-gpt.mdx

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@
22
title: Auto GPT
33
---
44

5-
Example inspired from the [LangChain doc](https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html)
5+
Auto-GPT is an AI tool that uses OpenAI's GPT-4 or GPT-3.5 APIs to perform autonomous tasks. It is an "AI agent" that can be given a goal in natural language and will attempt to achieve it by breaking it into sub-tasks and using the internet and other tools in an automatic loop.
66

7-
<Note>
8-
This example has extra dependencies, such as `openai`, `google-search-results`
9-
and `faiss-cpu`. You might have to install them manually.
10-
</Note>
7+
Unlike interactive systems such as ChatGPT, which require manual commands for every task, Auto-GPT assigns itself new objectives to work on with the aim of reaching a greater goal, without a mandatory need for human input.
8+
9+
This example is inspired from the [LangChain doc](https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html).
10+
11+
## Prerequisites
12+
13+
This example has extra dependencies. You can install them with:
14+
15+
```bash
16+
pip install chainlit langchain openai google-search-results faiss-cpu
17+
```
18+
19+
Then, you need to go to create an OpenAI key [here](https://platform.openai.com/account/api-keys) and get a SperpApi key [here](https://serpapi.com/).
1120

1221
## Code
1322

@@ -18,10 +27,20 @@ from langchain.tools.file_management.write import WriteFileTool
1827
from langchain.tools.file_management.read import ReadFileTool
1928
import os
2029

30+
from langchain.vectorstores import FAISS
31+
from langchain.docstore import InMemoryDocstore
32+
from langchain.embeddings import OpenAIEmbeddings
33+
import faiss
34+
35+
from langchain.experimental import AutoGPT
36+
from langchain.chat_models import ChatOpenAI
37+
import chainlit as cl
38+
39+
2140
os.environ["OPENAI_API_KEY"] = "OPENAI_API_KEY"
2241
os.environ["SERPAPI_API_KEY"] = "SERPAPI_API_KEY"
2342

24-
43+
# Tools the langchain agent will have access to
2544
search = SerpAPIWrapper()
2645
tools = [
2746
Tool(
@@ -33,23 +52,16 @@ tools = [
3352
ReadFileTool(),
3453
]
3554

36-
from langchain.vectorstores import FAISS
37-
from langchain.docstore import InMemoryDocstore
38-
from langchain.embeddings import OpenAIEmbeddings
3955

4056
# Define your embedding model
4157
embeddings_model = OpenAIEmbeddings()
4258
# Initialize the vectorstore as empty
43-
import faiss
4459

4560
embedding_size = 1536
4661
index = faiss.IndexFlatL2(embedding_size)
4762

48-
from langchain.experimental import AutoGPT
49-
from langchain.chat_models import ChatOpenAI
50-
import chainlit as cl
51-
5263

64+
# Create the agent with the chainlit decorator
5365
@cl.langchain_factory
5466
def agent():
5567
vectorstore = FAISS(embeddings_model.embed_query, index, InMemoryDocstore({}), {})
@@ -71,10 +83,13 @@ def run(agent, input):
7183
cl.send_message(res)
7284
```
7385

86+
Here you can see [langchain_run](/api-reference/langchain-run) and [langchain_factory](/api-reference/langchain-factory) were used.
87+
Langchain agents usually take a string as input. The `AutoGPT` class takes in a list. These two helper functions allow to change the default behavior.
88+
7489
## Try it out
7590

7691
```bash
77-
$ chainlit run autogpt.py
92+
chainlit run autogpt.py
7893
```
7994

8095
You can ask questions like `Create a weather report for san francisco`.

examples/mrkl.mdx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ title: MRKL
44

55
Example inspired from the [LangChain doc](https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl_chat.html)
66

7-
<Note>This example has extra dependencies, such as `google-search-results` and `openai`. You might have to install them manually.</Note>
7+
## Prerequisites
8+
9+
This example has extra dependencies. You can install them with:
10+
11+
```bash
12+
pip install chainlit langchain openai google-search-results
13+
```
814

915
## Code
16+
1017
```python mrkl.py
1118
from langchain import OpenAI, LLMMathChain, SerpAPIWrapper
1219
from langchain.agents import initialize_agent, Tool
@@ -45,9 +52,9 @@ def load():
4552
## Try it out
4653

4754
```bash
48-
$ chainlit run mrkl.py
55+
chainlit run mrkl.py
4956
```
5057

5158
You can ask questions like `What is the Paris weather forecast for tomorrow? How does it compare to today's?`.
5259

53-
![QA](/images/mrkl.png)
60+
![QA](/images/mrkl.png)

examples/openai-sql.mdx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
title: Text to SQL
33
---
44

5-
## Text to SQL with OpenAI
6-
75
Let's build a simple agent that helps users to create SQL queries with natural language.
86

9-
<Note>This example has extra dependencies, such as `openai`. You might have to install them manually.</Note>
7+
## Prerequisites
8+
9+
This example has extra dependencies. You can install them with:
10+
11+
```bash
12+
pip install chainlit openai
13+
```
1014

11-
### Imports
15+
## Imports
1216

1317
```python app.py
1418
import chainlit as cl
@@ -18,7 +22,7 @@ import os
1822
openai.api_key = "YOUR_OPEN_AI_API_KEY"
1923
```
2024

21-
### Define a prompt and LLM settings
25+
## Define a prompt and LLM settings
2226

2327
````python app.py
2428
prompt = """SQL tables (and columns):
@@ -40,7 +44,7 @@ settings = {
4044
}
4145
````
4246

43-
### Listen and Reply
47+
## Listen and Reply
4448

4549
Here, we decorate the `main` function with the [@on_message](api-reference/on-message) decorator to tell Chainlit to run the `main` function each time a user sends a message.
4650
Then, we send back the answer to the UI with the [send_message](api-reference/send-message) function.
@@ -64,10 +68,10 @@ def main(message: str):
6468
)
6569
```
6670

67-
### Try it out
71+
## Try it out
6872

6973
```bash
70-
$ chainlit run app.py -w
74+
chainlit run app.py -w
7175
```
7276

7377
You can ask questions like `Compute the number of customers who watched more than 50 minutes of video this month`.

examples/qa.mdx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@
22
title: Document QA
33
---
44

5-
Example inspired from the [LangChain doc](https://python.langchain.com/en/latest/use_cases/question_answering.html)
5+
In this example, we're going to build an chatbot QA app. We'll learn how to:
66

7-
<Note>
8-
This example has extra dependencies, such as `chromadb`, `tiktoken` and
9-
`openai`. You might have to install them manually.
10-
</Note>
7+
- Upload a document
8+
- Create vector embeddings from a file
9+
- Create a chatbot app with the ability to display sources used to generate an answer
10+
11+
This example is inspired from the [LangChain doc](https://python.langchain.com/en/latest/use_cases/question_answering.html)
12+
13+
## Prerequisites
14+
15+
This example has extra dependencies. You can install them with:
16+
17+
```bash
18+
pip installchromadb tiktoken openai
19+
```
20+
21+
Then, you need to go to create an OpenAI key [here](https://platform.openai.com/account/api-keys) and get a SperpApi key [here](https://serpapi.com/).
1122

1223
<Note>
1324
The state of the union file is available
@@ -135,15 +146,15 @@ def process_response(res):
135146
````
136147

137148
We are making use of the [@langchain_factory](/api-reference/langchain/langchain-factory) decorator to tell Chainlit on how to get the LangChain agent.
138-
Then, we use [@langchain_postprocess](/api-reference/langchain/langchain-postprocess) (which takes the raw response from the agent) as well as [send_text](/api-reference/send-text) to:
149+
Then, we use [@langchain_postprocess](/api-reference/langchain/langchain-postprocess) (which takes the raw response from the agent) as well as the [Text Element](/api-reference/elements/text) to:
139150

140151
- Add the relevant sources to the final answer
141152
- Send the sources to the UI
142153

143154
## Try it out
144155

145156
```bash
146-
$ chainlit run qa.py
157+
chainlit run qa.py
147158
```
148159

149160
You can then upload any `.txt` file to the UI and ask questions about it.

installation.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ Chainlit requires `python>=3.8`.
66

77
Open a terminal and run:
88
```bash
9-
$ pip install chainlit
9+
pip install chainlit
1010
```
1111

12-
To try if everything works correctly run:
12+
Make sure everything runs smoothly:
1313
```bash
14-
$ chainlit hello
14+
chainlit hello
1515
```
1616

1717
This should spawn the chainlit UI and ask for your name like so:
@@ -24,5 +24,5 @@ This should spawn the chainlit UI and ask for your name like so:
2424
</Card>
2525

2626
<Card title="With PurePython" icon="link" href="/pure-python">
27-
Learn on how to use Chainlit with any python code.
27+
Learn on how to use Chainlit with any python code.
2828
</Card>

langchain.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def factory():
2626
That's it. Run the following command to start the chatbot UI.
2727

2828
```bash
29-
$ chainlit run app.py -w
29+
chainlit run app.py -w
3030
```
3131

3232
Congratulations, your first chainlit app is ready 🥳

mint.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
"url": "https://discord.gg/ZThrUxbAYw"
1919
}
2020
],
21+
"topbarCtaButton": {
22+
"type": "link",
23+
"name": "Get Started",
24+
"url": "https://github.com/Chainlit/chainlit"
25+
},
2126
"navigation": [
2227
{
2328
"group": "Get Started",
@@ -42,10 +47,10 @@
4247
{
4348
"group": "Examples",
4449
"pages": [
45-
"examples/auto-gpt",
50+
"examples/openai-sql",
4651
"examples/mrkl",
47-
"examples/qa",
48-
"examples/openai-sql"
52+
"examples/auto-gpt",
53+
"examples/qa"
4954
]
5055
},
5156
{

overview.mdx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ Chainlit is an open-source Python package that focuses on making it incredibly e
66

77

88
## Advantages of Chainlit
9-
1. **Enhanced explainability:** Chainlit's user interface enables you to visualize intermediary steps, enabling you to understand the reasoning behind an answer.
9+
1. **Chatbot UI:** Create cool LLM-based chatbot apps directly from your python code!
1010

11-
2. **Debugging made easy:** Chainlit's prompt playground allows you to iterate on intermediate prompts, making it easier to identify and fix bugs.
11+
2. **Enhanced explainability:** Chainlit's user interface enables you to visualize intermediary steps, enabling you to understand the reasoning behind an answer.
1212

13-
3. **Plug and play integration with LangChain:** Turn your LangChain agent in a chatbot UI with one line of code.
13+
3. **Debugging made easy:** Chainlit's prompt playground allows you to iterate on intermediate prompts, making it easier to identify and fix bugs.
1414

15-
4. **Seamless file management:** The package includes a set of functions to ask and send files or documents.
15+
4. **Plug and play integration with LangChain:** Turn your LangChain agent in a chatbot UI with one line of code.
1616

17-
5. **Free deployment:** Chainlit offers free deployment, allowing you to quickly and easily share your AI applications with your team or the world.
17+
5. **Seamless file management:** The package includes a set of functions to ask and send files or documents.
1818

19-
6. **Improved team collaboration:** Chainlit's features, such as data persistence, human feedback, and prompt versioning, enable your team to work together more effectively and efficiently.
19+
6. **Deployment (coming soon):** Chainlit offers simple & free deployment, allowing you to quickly and easily share your AI applications with your team or the world.
20+
21+
7. **Improved team collaboration (coming soon):** Chainlit's features, such as data persistence, human feedback, and prompt versioning, enable your team to work together more effectively and efficiently.

pure-python.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def main(message: str):
2121
That's it. Run the following command to start the chatbot UI.
2222

2323
```bash
24-
$ chainlit run app.py -w
24+
chainlit run app.py -w
2525
```
2626

2727
Congratulations, your first chainlit app is ready 🥳

0 commit comments

Comments
 (0)