Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add multiprofile demo #114

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add multiprofile demo
ndamulelonemakh committed May 15, 2024
commit ed7ca2048bf495f118a6672fb1e197143acef339
7 changes: 7 additions & 0 deletions multiprofile-chat-with-auth/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
GOOGLE_API_KEY=
DEFAULT_USERNAME=
DEFAULT_USER_PASSWORD=
CHAINLIT_AUTH_SECRET=
LITERAL_API_KEY=
164 changes: 164 additions & 0 deletions multiprofile-chat-with-auth/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/


# Misc
data/
28 changes: 28 additions & 0 deletions multiprofile-chat-with-auth/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM python:3.12-slim

# Set the working directory in the container
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY requirements.txt .
COPY src/ ./src
COPY app.py setup.py .

# Install any needed dependencies specified in requirements.txt
RUN pip install -r requirements.txt

COPY public/ ./public
COPY .chainlit/ ./.chainlit
COPY README.md chainlit.md .

# Set environment variables
ENV PYTHONUNBUFFERED 1
ARG PORT=5500

# Command to run the app
CMD python -m chainlit run app.py -h --host 0.0.0.0 --port ${PORT}

# Alternatively: Use entrypoint file
# COPY entrypoint.sh .
# RUN chmod +x ./entrypoint.sh
# ENTRYPOINT ["./entrypoint.sh"]
105 changes: 105 additions & 0 deletions multiprofile-chat-with-auth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Home AI

* This demo illustrates how to use [Chainlit](https://github.com/Chainlit/chainlit) to build chatbots with LLMs the big
three AI providers: OpenAI, Anthropic, and Gemini.
* [Live Demo](https://homeai.chainlit.com)

## Features

- Multiple user profiles
- Integration with [OpenAI](https://openai.com/), [Anthropic](https://www.anthropic.com/)
and [Gemini](https://www.gemini.com/) chat providers
- Chat settings
- Authentication
- Custom logo and favicon
- Custom theme

## Installation

1. Clone the repository:

```bash
git clone https://github.com/mungana-ai/homeai.git
cd homeai
```

2. Create a virtual environment:

```bash
python -m venv venv # We assume you are using at least Python 3.10
source venv/bin/activate # For Unix-based systems
venv\Scripts\activate.bat # For Windows
```

3. Install the package and its dependencies:

```bash
pip install -r requirements.txt
```

## Configuration

1. Rename the provided `.env.example` file into `.env` in the project root directory.

2. Update the necessary configuration variables to the `.env` file. The following variables are required:

```bash
DEFAULT_USER_PASSWORD=your_default_user_password
CHAINLIT_AUTH_SECRET=your_64_char_chainlit_auth_secret_for_signing_tokens
LITERAL_API_KEY=your_literal_api_key_for_storing_chat_history

# Optional: At least one of the following chat providers is required
OPENAI_API_KEY=your_openai_api_key
ANTHROPIC_API_KEY=your_anthropic_api_key
GOOGLE_API_KEY=your_google_api_key

# Optional
DEFAULT_USERNAME=your_default_username # Default: "admin"
```

> **Hints:** You can generate a 64-character secret key using the following command: `chainlit create-secret`. To
> obtain an API key for [Literal](https://literal.chainlit.com), sign up for an account and create a new project.

## Usage

To run the Chainlit app, use the following command:

```bash
chainlit run app.py --host 0.0.0.0 --port 5500
```

* You app should now be accessible at `http://localhost:5500`

## Project Structure

The project structure is organized as follows:

- `src/`: Contains the main application code.
- `.chainlit/`: Contains the Chainlit configuration files.
- `public/`: Contains the static files for custom logos and favicons.
- `app.py`: The main application entry point.
- `.env.example`: Stores the environment variables template.
- `requirements.txt`: Lists the project dependencies.
- `chainlit.md`: Provides documentation and instructions for the project.

## Issues

If you have any questions or inquiries, please contact [N Nemakhavhani](mailto://[email protected]). Bugs and issues can
be reported on the [GitHub Issues]() page.

## License

This project is licensed under the MIT License. You are free to use, modify, and distribute the code as you see fit.

## Contributions

Contributions are welcome! If you would like to contribute to the project, please fork the repository and submit a pull
request.


## Links

* [OpenAI API](https://platform.openai.com/docs/quickstart)
* [Anthropic API](https://docs.anthropic.com/en/api/getting-started)
* [Gemini API](https://ai.google.dev/gemini-api/docs/api-key)
* [Literal API](https://cloud.getliteral.ai/)
Loading