From afb89f407b1a920305a292bca87235747a10c42e Mon Sep 17 00:00:00 2001 From: rachittshah <rachitt01@gmail.com> Date: Thu, 8 Feb 2024 13:15:18 +0530 Subject: [PATCH] feat: embedchain cookbook --- embedchain-qa/app.py | 38 ++++++++++++++++++++++++++++++++++++++ embedchain-qa/chainlit.md | 14 ++++++++++++++ embedchain-qa/readme.md | 27 +++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 embedchain-qa/app.py create mode 100644 embedchain-qa/chainlit.md create mode 100644 embedchain-qa/readme.md diff --git a/embedchain-qa/app.py b/embedchain-qa/app.py new file mode 100644 index 000000000..9c11019bd --- /dev/null +++ b/embedchain-qa/app.py @@ -0,0 +1,38 @@ +import os + +import chainlit as cl + +from embedchain import App + +os.environ["OPENAI_API_KEY"] = "OPENAI_API_KEY" + + +@cl.on_chat_start +async def on_chat_start(): + app = App.from_config( + config={ + "app": {"config": {"name": "chainlit-app"}}, + "llm": { + "config": { + "stream": True, + "model": "gpt-3.5-turbo-16k", + "temperature": 0.5, + "max_tokens": 4000, + } + }, + } + ) + # import your data here + app.add("https://docs.chainlit.io/",data_type="docs_site") + app.collect_metrics = True + cl.user_session.set("app", app) + + +@cl.on_message +async def on_message(message: cl.Message): + app = cl.user_session.get("app") + msg = cl.Message(content="") + for chunk in await cl.make_async(app.chat)(message.content): + await msg.stream_token(chunk) + + await msg.send() \ No newline at end of file diff --git a/embedchain-qa/chainlit.md b/embedchain-qa/chainlit.md new file mode 100644 index 000000000..4507ac467 --- /dev/null +++ b/embedchain-qa/chainlit.md @@ -0,0 +1,14 @@ +# Welcome to Chainlit! 🚀🤖 + +Hi there, Developer! 👋 We're excited to have you on board. Chainlit is a powerful tool designed to help you prototype, debug and share applications built on top of LLMs. + +## Useful Links 🔗 + +- **Documentation:** Get started with our comprehensive [Chainlit Documentation](https://docs.chainlit.io) 📚 +- **Discord Community:** Join our friendly [Chainlit Discord](https://discord.gg/k73SQ3FyUh) to ask questions, share your projects, and connect with other developers! 💬 + +We can't wait to see what you create with Chainlit! Happy coding! 💻😊 + +## Welcome screen + +To modify the welcome screen, edit the `chainlit.md` file at the root of your project. If you do not want a welcome screen, just leave this file empty. diff --git a/embedchain-qa/readme.md b/embedchain-qa/readme.md new file mode 100644 index 000000000..8973674e1 --- /dev/null +++ b/embedchain-qa/readme.md @@ -0,0 +1,27 @@ +# Chainlit App + +## Overview + +This cookbooks contains a Chainlit app that uses the `embedchain-qa` model to answer questions based on a given context. The app is built using the Chainlit SDK and can be integrated into your existing Python codebase. + + +## Installation + +To get started with this Chainlit app, you will need Python installed on your system. Follow these steps: + +1. Clone the repository: `git clone https://github.com/Chainlit/cookbook/{cookbook-name}` + +2. Navigate to the `chainlit-cookbook/{cookbook-name}` directory. + +3. perform the following command to install the required dependencies: + +```bash +pip install -r requirements.txt +``` + +4. Run the app using the following command: + +```bash +chainlit run app.py +``` +Make sure to add your openai API key to the `app.py` file before running the app. \ No newline at end of file