[Improvements] Add support for creating app from YAML string config (#980)

This commit is contained in:
Deven Patel
2023-11-29 12:25:30 -08:00
committed by GitHub
parent e35eaf1bfc
commit 406c46e7f4
34 changed files with 351 additions and 179 deletions

View File

@@ -1,8 +1,15 @@
---
title: 🔎 Examples
description: 'Collection of Google colab notebook and Replit links for users'
---
# Explore awesome apps
Check out the remarkable work accomplished using [Embedchain](https://app.embedchain.ai/custom-gpts/).
## Collection of Google colab notebook and Replit links for users
Get started with Embedchain by trying out the examples below. You can run the examples in your browser using Google Colab or Replit.
<table>
<thead>
<tr>

View File

@@ -2,13 +2,36 @@
title: ❓ FAQs
description: 'Collections of all the frequently asked questions'
---
#### Does Embedchain support OpenAI's Assistant APIs?
<AccordionGroup>
<Accordion title="Does Embedchain support OpenAI's Assistant APIs?">
Yes, it does. Please refer to the [OpenAI Assistant docs page](/get-started/openai-assistant).
</Accordion>
<Accordion title="How to use MistralAI language model?">
Use the model provided on huggingface: `mistralai/Mistral-7B-v0.1`
<CodeGroup>
```python main.py
import os
from embedchain import Pipeline as App
#### How to use `gpt-4-turbo` model released on OpenAI DevDay?
os.environ["OPENAI_API_KEY"] = "sk-xxx"
os.environ["HUGGINGFACE_ACCESS_TOKEN"] = "hf_your_token"
app = App.from_config("huggingface.yaml")
```
```yaml huggingface.yaml
llm:
provider: huggingface
config:
model: 'mistralai/Mistral-7B-v0.1'
temperature: 0.5
max_tokens: 1000
top_p: 0.5
stream: false
```
</CodeGroup>
</Accordion>
<Accordion title="How to use ChatGPT 4 turbo model released on OpenAI DevDay?">
Use the model `gpt-4-turbo` provided my openai.
<CodeGroup>
```python main.py
@@ -18,7 +41,7 @@ from embedchain import Pipeline as App
os.environ['OPENAI_API_KEY'] = 'xxx'
# load llm configuration from gpt4_turbo.yaml file
app = App.from_config(yaml_path="gpt4_turbo.yaml")
app = App.from_config(config_path="gpt4_turbo.yaml")
```
```yaml gpt4_turbo.yaml
@@ -31,12 +54,9 @@ llm:
top_p: 1
stream: false
```
</CodeGroup>
#### How to use GPT-4 as the LLM model?
</Accordion>
<Accordion title="How to use GPT-4 as the LLM model?">
<CodeGroup>
```python main.py
@@ -46,7 +66,7 @@ from embedchain import Pipeline as App
os.environ['OPENAI_API_KEY'] = 'xxx'
# load llm configuration from gpt4.yaml file
app = App.from_config(yaml_path="gpt4.yaml")
app = App.from_config(config_path="gpt4.yaml")
```
```yaml gpt4.yaml
@@ -61,9 +81,8 @@ llm:
```
</CodeGroup>
#### I don't have OpenAI credits. How can I use some open source model?
</Accordion>
<Accordion title="I don't have OpenAI credits. How can I use some open source model?">
<CodeGroup>
```python main.py
@@ -73,7 +92,7 @@ from embedchain import Pipeline as App
os.environ['OPENAI_API_KEY'] = 'xxx'
# load llm configuration from opensource.yaml file
app = App.from_config(yaml_path="opensource.yaml")
app = App.from_config(config_path="opensource.yaml")
```
```yaml opensource.yaml
@@ -93,8 +112,10 @@ embedder:
```
</CodeGroup>
#### How to contact support?
</Accordion>
</AccordionGroup>
#### Need more help?
If docs aren't sufficient, please feel free to reach out to us using one of the following methods:
<Snippet file="get-help.mdx" />

View File

@@ -105,7 +105,7 @@ app.deploy()
# ✅ Data of type: web_page, value: https://www.forbes.com/profile/elon-musk added successfully.
```
## 🚀 How it works?
## 🛠️ How it works?
Embedchain abstracts out the following steps from you to easily create LLM powered apps:
@@ -129,3 +129,5 @@ The process of loading the dataset and querying involves multiple steps, each wi
- How should I find similar documents for a query? Which ranking model should I use?
Embedchain takes care of all these nuances and provides a simple interface to create apps on any data.
## [🚀 Get started](https://docs.embedchain.ai/get-started/quickstart)

View File

@@ -12,79 +12,73 @@ pip install embedchain
```
<Tip>
Embedchain now supports OpenAI's latest `gpt-4-turbo` model. Checkout the [docs here](/get-started/faq#how-to-use-gpt-4-turbo-model-released-on-openai-devday) on how to use it.
Embedchain now supports OpenAI's latest `gpt-4-turbo` model. Checkout the [FAQs](/get-started/faq#how-to-use-gpt-4-turbo-model-released-on-openai-devday).
</Tip>
Creating an app involves 3 steps:
<Steps>
<Step title="⚙️ Import app instance">
```python
from embedchain import Pipeline as App
app = App()
```
```python
from embedchain import Pipeline as App
app = App()
```
<Accordion title="Customize your app by a simple YAML config" icon="gear-complex">
Embedchain provides a wide range of options to customize your app. You can customize the model, data sources, and much more.
Explore the custom configurations [here](https://docs.embedchain.ai/advanced/configuration).
```python
from embedchain import Pipeline as App
app = App(yaml_config="config.yaml")
```
</Accordion>
</Step>
<Step title="🗃️ Add data sources">
```python
# Add different data sources
app.add("https://en.wikipedia.org/wiki/Elon_Musk")
app.add("https://www.forbes.com/profile/elon-musk")
# You can also add local data sources such as pdf, csv files etc.
# app.add("/path/to/file.pdf")
```
```python
app.add("https://en.wikipedia.org/wiki/Elon_Musk")
app.add("https://www.forbes.com/profile/elon-musk")
# app.add("path/to/file/elon_musk.pdf")
```
<Accordion title="Embedchain supports adding data from many data sources." icon="files">
Embedchain supports adding data from many data sources including web pages, PDFs, databases, and more.
Explore the list of supported [data sources](https://docs.embedchain.ai/data-sources/overview).
</Accordion>
</Step>
<Step title="💬 Query or chat or search context on your data">
```python
app.query("What is the net worth of Elon Musk today?")
# Answer: The net worth of Elon Musk today is $258.7 billion.
```
<Step title="💬 Ask questions, chat, or search through your data with ease">
```python
app.query("What is the net worth of Elon Musk today?")
# Answer: The net worth of Elon Musk today is $258.7 billion.
```
<Accordion title="Want to chat with your app?" icon="face-thinking">
Embedchain provides a wide range of features to interact with your app. You can chat with your app, ask questions, search through your data, and much more.
```python
app.chat("How many companies does Elon Musk run? Name those")
# Answer: Elon Musk runs 3 companies: Tesla, SpaceX, and Neuralink.
app.chat("What is his net worth today?")
# Answer: The net worth of Elon Musk today is $258.7 billion.
```
To learn about other features, click [here](https://docs.embedchain.ai/get-started/introduction)
</Accordion>
</Step>
<Step title="🚀 (Optional) Deploy your pipeline to Embedchain Platform">
```python
app.deploy()
# 🔑 Enter your Embedchain API key. You can find the API key at https://app.embedchain.ai/settings/keys/
# ec-xxxxxx
<Step title="🚀 Seamlessly launch your App on the Embedchain Platform!">
```python
app.deploy()
# 🔑 Enter your Embedchain API key. You can find the API key at https://app.embedchain.ai/settings/keys/
# ec-xxxxxx
# 🛠️ Creating pipeline on the platform...
# 🎉🎉🎉 Pipeline created successfully! View your pipeline: https://app.embedchain.ai/pipelines/xxxxx
# 🛠️ Creating pipeline on the platform...
# 🎉🎉🎉 Pipeline created successfully! View your pipeline: https://app.embedchain.ai/pipelines/xxxxx
# 🛠️ Adding data to your pipeline...
# ✅ Data of type: web_page, value: https://www.forbes.com/profile/elon-musk added successfully.
```
# 🛠️ Adding data to your pipeline...
# ✅ Data of type: web_page, value: https://www.forbes.com/profile/elon-musk added successfully.
```
<Accordion title="Share your app with others" icon="laptop-mobile">
You can now share your app with others from our platform.
Access your app on our [platform](https://app.embedchain.ai/).
</Accordion>
</Step>
</Steps>
Putting it together, you can run your first app using the following code. Make sure to set the `OPENAI_API_KEY` 🔑 environment variable in the code.
```python
import os
from embedchain import Pipeline as App
os.environ["OPENAI_API_KEY"] = "xxx"
app = App()
# Add different data sources
app.add("https://en.wikipedia.org/wiki/Elon_Musk")
app.add("https://www.forbes.com/profile/elon-musk")
# You can also add local data sources such as pdf, csv files etc.
# app.add("/path/to/file.pdf")
response = app.query("What is the net worth of Elon Musk today?")
print(response)
# Answer: The net worth of Elon Musk today is $258.7 billion.
app.deploy()
# 🔑 Enter your Embedchain API key. You can find the API key at https://app.embedchain.ai/settings/keys/
# ec-xxxxxx
# 🛠️ Creating pipeline on the platform...
# 🎉🎉🎉 Pipeline created successfully! View your pipeline: https://app.embedchain.ai/pipelines/xxxxx
# 🛠️ Adding data to your pipeline...
# ✅ Data of type: web_page, value: https://www.forbes.com/profile/elon-musk added successfully.
```
You can try it out yourself using the following Google Colab notebook:
Putting it together, you can run your first app using the following Google Colab. Make sure to set the `OPENAI_API_KEY` 🔑 environment variable in the code.
<a href="https://colab.research.google.com/drive/17ON1LPonnXAtLaZEebnOktstB_1cJJmh?usp=sharing">
<img src="https://camo.githubusercontent.com/84f0493939e0c4de4e6dbe113251b4bfb5353e57134ffd9fcab6b8714514d4d1/68747470733a2f2f636f6c61622e72657365617263682e676f6f676c652e636f6d2f6173736574732f636f6c61622d62616467652e737667" alt="Open in Colab" />