Skip to content

Commit

Permalink
feat(uv) switch from poetry to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
VVoruganti committed Sep 15, 2024
1 parent 22b8269 commit 0f56651
Show file tree
Hide file tree
Showing 9 changed files with 1,160 additions and 3,016 deletions.
64 changes: 34 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
# tutor-gpt
![Static Badge](https://img.shields.io/badge/Version-0.5.1-blue)

![Static Badge](https://img.shields.io/badge/Version-0.6.0-blue)
[![Discord](https://img.shields.io/discord/1076192451997474938?logo=discord&logoColor=%23ffffff&label=Bloom&labelColor=%235865F2)](https://discord.gg/bloombotai)
![GitHub License](https://img.shields.io/github/license/plastic-labs/tutor-gpt)
![GitHub Repo stars](https://img.shields.io/github/stars/plastic-labs/tutor-gpt)
[![X (formerly Twitter) URL](https://img.shields.io/twitter/url?url=https%3A%2F%2Ftwitter.com%2FBloomBotAI&label=Twitter)](https://twitter.com/BloomBotAI)
[![arXiv](https://img.shields.io/badge/arXiv-2310.06983-b31b1b.svg)](https://arxiv.org/abs/2310.06983)


Tutor-GPT is a LangChain LLM application developed by [Plastic
Labs](https://plasticlabs.ai). It dynamically reasons about your learning needs
and *updates its own prompts* to best serve you.
and _updates its own prompts_ to best serve you.

We leaned into theory of mind experiments and it is now more than just a
literacy tutor, it’s an expansive learning companion. Read more about how it
works [here](https://plasticlabs.ai/blog/Theory-of-Mind-is-All-You-Need).
works [here](https://blog.plasticlabs.ai/blog/Theory-of-Mind-Is-All-You-Need).

The hosted version of `tutor-gpt` is called [Bloom](https://bloombot.ai) as a
nod to Benjamin Bloom's Two Sigma Problem. You can try the web version at
[chat.bloombot.ai](https://chat.bloombot.ai) or you can join our
[Discord](https://discord.gg/bloombotai) to try out our implementation for free
(while our OpenAI spend lasts 😄).
(while our OpenAI spend lasts 😄).

Alternatively, you can run your own instance of the bot by following the
instructions below.
instructions below.

## Project Structure

The tutor-gpt project is split between multiple different modules that split up
the backend logic for different clients.
the backend logic for different clients.

- `agent/` - this contains the core logic and prompting architecture
- `agent/` - this contains the core logic and prompting architecture
- `bot/` - this contains the discord bot implementation
- `api/` - this contains an API interface to the tutor-gpt backend
- `www/` - this contains a `NextJS` web front end that can connect to the API interface
- `www/` - this contains a `NextJS` web front end that can connect to the API interface
- `common/` - this contains common used in different interfaces
- `supabase/` - contains SQL scripts necessary for setting up local supabase

Expand All @@ -44,9 +44,9 @@ web interface `yarn` is used.

Additionally, this project uses supabase for managing different users,
authentication, and as the database for holding message and conversation
information. We recommend for testing and local development to use a local instance of supabase. The supabase-cli is the best way to do this.
information. We recommend for testing and local development to use a local instance of supabase. The supabase-cli is the best way to do this.

Follow the [Supabase Documentation](https://supabase.com/docs/guides/cli/local-development) for more information. The project contains a `supabase/` folder that contains the scaffolding SQL migrations necessary for setting up the necessary tables. Once you have the supabase cli installed you can simply run the below command in the `tutor-gpt` folder and a local instance of Supabase will start up.
Follow the [Supabase Documentation](https://supabase.com/docs/guides/cli/local-development) for more information. The project contains a `supabase/` folder that contains the scaffolding SQL migrations necessary for setting up the necessary tables. Once you have the supabase cli installed you can simply run the below command in the `tutor-gpt` folder and a local instance of Supabase will start up.

> NOTE: Local Supabase relies on docker so ensure docker is also running before running the below command
Expand All @@ -63,25 +63,25 @@ on the webui and then immediately sign in with it.
> NOTE: The project uses
> [poetry](https://python-poetry.org/docs/#installing-with-the-official-installer)
> and [yarn](https://yarnpkg.com/getting-started/install) for package
> management.
> management.
The below commands will install all the dependencies necessary for running the
tutor-gpt project. We recommend using poetry to setup a virtual environment for
the project.
the project.

```bash
git clone https://github.com/plastic-labs/tutor-gpt.git
cd tutor-gpt
poetry install # install Python dependencies
cd www/
yarn install # install all NodeJS dependencies
yarn install # install all NodeJS dependencies
```

### Docker

Alternatively (The recommended way) this project can be built and run with
docker. [Install docker](https://docs.docker.com/get-docker/) and ensure it's
running before proceeding.
running before proceeding.

The web front end is built and run separately from the remainder of the
codebase. Below are the commands for building the core of the tutor-gpt project
Expand All @@ -95,6 +95,7 @@ docker build -t tutor-gpt-core .
```

Similarly, to build the web interface run the below commands

```bash
cd tutor-gpt/www
docker build -t tutor-gpt-web .
Expand Down Expand Up @@ -135,22 +136,25 @@ running (web or discord) different variables are necessary. This is explained
below

### Required
- **OPENAI_API_KEY**: Go to [OpenAI](https://beta.openai.com/account/api-keys) to generate your own API key.
- **SUPABASE_URL**: The base URL for your supabase instance
- **SUPABASE_KEY**: The API key for interacting with your supabase project. This corresponds to the service key, get it from your project settings
- **CONVERSATION_TABLE**: the name of the table to hold conversation metadata

- **OPENAI_API_KEY**: Go to [OpenAI](https://beta.openai.com/account/api-keys) to generate your own API key.
- **SUPABASE_URL**: The base URL for your supabase instance
- **SUPABASE_KEY**: The API key for interacting with your supabase project. This corresponds to the service key, get it from your project settings
- **CONVERSATION_TABLE**: the name of the table to hold conversation metadata
- **MEMORY_TABLE**: the name of the table holding messages for different conversations

### Discord Only

- **BOT_TOKEN**: This is the discord bot token. You can find instructions on how
to create a bot and generate a token in the [pycord
docs](https://guide.pycord.dev/getting-started/creating-your-first-bot).
to create a bot and generate a token in the [pycord
docs](https://guide.pycord.dev/getting-started/creating-your-first-bot).
- **THOUGHT_CHANNEL_ID**: This is the discord channel for the bot to output
thoughts to. Make a channel in your server and copy the ID by right clicking the
channel and copying the link. The channel ID is the last string of numbers in
the link.
thoughts to. Make a channel in your server and copy the ID by right clicking the
channel and copying the link. The channel ID is the last string of numbers in
the link.

### Web Only

- **URL**: the URL that the web ui is running from by default this should be http://localhost:3000

### Web UI Environment
Expand All @@ -159,7 +163,7 @@ The `NextJS` application in `www/` also has it's own environment variables which

- **NEXT_PUBLIC_URL**: The url the web application will be accessible the default with `NextJS` is http://localhost:3000
- **NEXT_PUBLIC_API_URL**: The url the api backend will be run from the default for `FastAPI is` http://localhost:8000
- **NEXT_PUBLIC_SUPABASE_URL**: The url for your supabase project should be identical to the one used in the python backend
- **NEXT_PUBLIC_SUPABASE_URL**: The url for your supabase project should be identical to the one used in the python backend
- **NEXT_PUBLIC_SUPABASE_ANON_KEY**: The API key for supabase this time it is the anon key NOT the service key
- **NEXT_PUBLIC_SENTRY_DSN**: Optional for sentry bug tracking
- **NEXT_PUBLIC_SENTRY_ENVIRONMENT**: Optional for sentry bug tracking
Expand All @@ -170,7 +174,7 @@ The `NextJS` application in `www/` also has it's own environment variables which

### Docker/Containerization

You can also optionally use the docker containers to run the application locally. Below is the command to run the discord bot locally using a `.env` file that is not within the docker container. Be careful not to add your `.env` in the docker container as this is insecure and can leak your secrets.
You can also optionally use the docker containers to run the application locally. Below is the command to run the discord bot locally using a `.env` file that is not within the docker container. Be careful not to add your `.env` in the docker container as this is insecure and can leak your secrets.

```bash
docker run --env-file .env tutor-gpt-core python -u -m bot.app
Expand All @@ -185,18 +189,18 @@ docker run -p 8000:8000 --env-file .env tutor-gpt-core python -m uvicorn api.mai
docker run tutor-gpt-web
```

> NOTE: the default run command in the docker file for the core runs the FastAPI backend so you could just run docker run --env-file .env tutor-gpt-core
> NOTE: the default run command in the docker file for the core runs the FastAPI backend so you could just run docker run --env-file .env tutor-gpt-core
### Architecture

Below is high level diagram of the architecture for the bot.
![Tutor-GPT Discord Architecture](assets/ToM Chain Flow.png)
![Tutor-GPT Discord Architecture](<assets/ToM Chain Flow.png>)

## Contributing

This project is completely open source and welcomes any and all open source contributions. The workflow for contributing is to make a fork of the repository. You can claim an issue in the issues tab or start a new thread to indicate a feature or bug fix you are working on.
This project is completely open source and welcomes any and all open source contributions. The workflow for contributing is to make a fork of the repository. You can claim an issue in the issues tab or start a new thread to indicate a feature or bug fix you are working on.

Once you have finished your contribution make a PR pointed at the `staging` branch and it will be reviewed by a project manager. Feel free to join us in our [discord](http://discord.gg/bloombotai) to discuss your changes or get help.
Once you have finished your contribution make a PR pointed at the `staging` branch and it will be reviewed by a project manager. Feel free to join us in our [discord](http://discord.gg/bloombotai) to discuss your changes or get help.

Once your changes are accepted and merged into staging they will under go a period of live testing before entering the upstream into `main`

Expand Down
Loading

0 comments on commit 0f56651

Please sign in to comment.