Skip to content

Commit

Permalink
Merge pull request #519 from ohcnetwork/master
Browse files Browse the repository at this point in the history
Production Release: Switch to Milvus, Added GPT-4 support
  • Loading branch information
gigincg authored Sep 17, 2024
2 parents 7584220 + 381439e commit bd9b8aa
Show file tree
Hide file tree
Showing 33 changed files with 1,678 additions and 1,146 deletions.
1 change: 1 addition & 0 deletions .envs/.local/.django
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ IPYTHONDIR=/app/.ipython
# Redis
# ------------------------------------------------------------------------------
REDIS_URL=redis://redis:6379/0
DATABASE_URL=postgres://debug:debug@postgres:5432/ayushma

# Celery
# ------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- master
jobs:
build:
if: github.repository == 'coronasafe/ayushma'
if: github.repository == 'ohcnetwork/ayushma'
name: Lint Code Base
runs-on: ubuntu-latest
permissions:
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ logs:
docker compose -f $(docker_config_file) logs

makemigrations: up
docker exec django bash -c "python manage.py makemigrations"
docker compose -f $(docker_config_file) exec django bash -c "python manage.py makemigrations"

migrate: up
docker compose -f $(docker_config_file) exec django bash -c "python manage.py migrate"

checkmigration:
docker compose -f $(docker_config_file) exec django bash -c "python manage.py makemigrations --check --dry-run"
Expand Down
3 changes: 2 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ drf-nested-routers = "==0.93.4"
drf-spectacular = "==0.27.0"
requests = "==2.31.0"
openai = "==1.2.4"
pinecone-client = "==2.2.4"
pinecone-client = "==4.1.1"
pypdf2 = "==3.0.1"
tiktoken = "==0.5.2"
langchain = "==0.0.352"
Expand All @@ -41,6 +41,7 @@ nltk = "==3.8.1"
gunicorn = "==21.2.0"
psycopg = {extras = ["c"], version = "==3.1.17"}
sentry-sdk = "==1.30.0"
pymilvus = "*"

[dev-packages]
ipdb = "==0.13.13"
Expand Down
1,847 changes: 1,014 additions & 833 deletions Pipfile.lock

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions Procfile

This file was deleted.

59 changes: 29 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,49 @@
# Ayushma AI

This is a Django Project.
Empowering Nurses with Multilingual ICU Protocols. Leveraging the rapid advancements in AI technology, created multilingual interfaces that assist nurses in rapidly upgrading their knowledge about ICU protocols. This is a Django project.

## Requirements

- Python 3.8
- Postgres 15
- OpenAI Account with a valid API Key
- Pinecone Account with a valid API Key
- Docker

## Optional Requirements

- Docker
- Pinecone Account with a valid API Key
- AWS SES Accout
- AWS S3 Account
- Google Cloud account with access to speech to text API

## Installation
## Running the Project

create a virtual environment and install the requirements
> We strongly recommend using Docker to run the project. Manual methods are not supported at the moment.
```bash
pip3 install --user virtualenv
virtualenv .venv
source .venv/bin/activate
pip3 install -r requirements/local.txt
make up
```

## Env Variables

You can add these at the end of your `activate` file in `[virtualenvfolder] -> bin` like `export [env] = [value]`

| Variable | Description
| --- | ---
| AI_NAME | Name of the AI (default: Ayushma)
| OPENAI_API_KEY | OpenAI API Key
| PINECONE_API_KEY | Pinecone API Key
| PINECONE_ENVIRONMENT | Pinecone Environment
| PINECONE_INDEX | Pinecone Index
| CURRENT_DOMAIN | Current Domain where the frontend is hosted. ex. `https://ayushma.ohc.network`
| EMAIL_HOST | SES Email Host (Optional)
| EMAIL_USER | SES Email User (Optional)
| EMAIL_PASSWORD | SES Email Password (Optional)
| GOOGLE_APPLICATION_CREDENTIALS | Google Cloud Credentials (Optional). These should be in a file named `gc_credential.json` in the root of the project
| S3_SECRET_KEY | AWS S3 Secret Key (Optional)
| S3_KEY_ID | AWS S3 Key ID (Optional)
| S3_BUCKET_NAME | AWS S3 Bucket Name (Optional)
| S3_REGION | AWS S3 Region (Optional)
| GOOGLE_RECAPTCHA_SECRET_KEY | Google Recaptcha Secret Key (Optional)
Add these environment variables to your `.env` file.

| Variable | Description |
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------- |
| AI_NAME | Name of the AI (default: Ayushma) |
| OPENAI_API_KEY | OpenAI API Key |
| PINECONE_API_KEY | Pinecone API Key |
| PINECONE_INDEX | Pinecone Index |
| VECTOR_DB | The Vector DB you would like to choose. "milvus" (default) or "pinecone" |
| CURRENT_DOMAIN | Current Domain where the frontend is hosted. ex. `https://ayushma.ohc.network` |
| EMAIL_HOST | SES Email Host (Optional) |
| EMAIL_USER | SES Email User (Optional) |
| EMAIL_PASSWORD | SES Email Password (Optional) |
| GOOGLE_APPLICATION_CREDENTIALS | Google Cloud Credentials (Optional). These should be in a file named `gc_credential.json` in the root of the project |
| S3_SECRET_KEY | AWS S3 Secret Key (Optional) |
| S3_KEY_ID | AWS S3 Key ID (Optional) |
| S3_BUCKET_NAME | AWS S3 Bucket Name (Optional) |
| S3_REGION | AWS S3 Region (Optional) |
| GOOGLE_RECAPTCHA_SECRET_KEY | Google Recaptcha Secret Key (Optional) |

## Google Cloud

To use Google Cloud Speech to Text API, you need to enable the API and create a service account. Download the credentials and save them in a file named `gc_credential.json` in the root of the project.
13 changes: 12 additions & 1 deletion ayushma/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
from djangoql.admin import DjangoQLSearchMixin

from ayushma.models.services import Service, TempToken
from ayushma.models.testsuite import Feedback, TestQuestion, TestRun, TestSuite
from ayushma.models.testsuite import (
Feedback,
TestQuestion,
TestResult,
TestRun,
TestSuite,
)

from .models import APIKey, Chat, ChatMessage, Document, Project, User

Expand Down Expand Up @@ -132,4 +138,9 @@ class TestRunAdmin(DjangoQLSearchMixin, admin.ModelAdmin):
pass


@admin.register(TestResult)
class TestResultAdmin(DjangoQLSearchMixin, admin.ModelAdmin):
pass


admin.site.site_header = "Ayushma Admin"
Empty file removed ayushma/management/__init__.py
Empty file.
83 changes: 0 additions & 83 deletions ayushma/management/commands/upsert.py

This file was deleted.

46 changes: 46 additions & 0 deletions ayushma/migrations/0053_alter_chat_model_alter_project_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Generated by Django 4.2.6 on 2024-07-02 16:07

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("ayushma", "0052_document_failed"),
]

operations = [
migrations.AlterField(
model_name="chat",
name="model",
field=models.IntegerField(
blank=True,
choices=[
(1, "Gpt 3 5"),
(2, "Gpt 3 5 16K"),
(3, "Gpt 4"),
(4, "Gpt 4 32K"),
(5, "Gpt 4 Visual"),
(6, "Gpt 4 Turbo"),
(7, "Gpt 4 Omni"),
],
null=True,
),
),
migrations.AlterField(
model_name="project",
name="model",
field=models.IntegerField(
choices=[
(1, "Gpt 3 5"),
(2, "Gpt 3 5 16K"),
(3, "Gpt 4"),
(4, "Gpt 4 32K"),
(5, "Gpt 4 Visual"),
(6, "Gpt 4 Turbo"),
(7, "Gpt 4 Omni"),
],
default=1,
),
),
]
48 changes: 48 additions & 0 deletions ayushma/migrations/0054_alter_chat_model_alter_project_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Generated by Django 4.2.6 on 2024-07-24 14:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("ayushma", "0053_alter_chat_model_alter_project_model"),
]

operations = [
migrations.AlterField(
model_name="chat",
name="model",
field=models.IntegerField(
blank=True,
choices=[
(1, "Gpt 3 5"),
(2, "Gpt 3 5 16K"),
(3, "Gpt 4"),
(4, "Gpt 4 32K"),
(5, "Gpt 4 Visual"),
(6, "Gpt 4 Turbo"),
(7, "Gpt 4 Omni"),
(8, "Gpt 4 Omni Mini"),
],
null=True,
),
),
migrations.AlterField(
model_name="project",
name="model",
field=models.IntegerField(
choices=[
(1, "Gpt 3 5"),
(2, "Gpt 3 5 16K"),
(3, "Gpt 4"),
(4, "Gpt 4 32K"),
(5, "Gpt 4 Visual"),
(6, "Gpt 4 Turbo"),
(7, "Gpt 4 Omni"),
(8, "Gpt 4 Omni Mini"),
],
default=1,
),
),
]
52 changes: 52 additions & 0 deletions ayushma/migrations/0055_testresult_model_testrun_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Generated by Django 4.2.6 on 2024-07-26 11:39

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("ayushma", "0054_alter_chat_model_alter_project_model"),
]

operations = [
migrations.AddField(
model_name="testresult",
name="model",
field=models.IntegerField(
blank=True,
choices=[
(1, "Gpt 3 5"),
(2, "Gpt 3 5 16K"),
(3, "Gpt 4"),
(4, "Gpt 4 32K"),
(5, "Gpt 4 Visual"),
(6, "Gpt 4 Turbo"),
(7, "Gpt 4 Omni"),
(8, "Gpt 4 Omni Mini"),
],
null=True,
),
),
migrations.AddField(
model_name="testrun",
name="models",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.IntegerField(
choices=[
(1, "Gpt 3 5"),
(2, "Gpt 3 5 16K"),
(3, "Gpt 4"),
(4, "Gpt 4 32K"),
(5, "Gpt 4 Visual"),
(6, "Gpt 4 Turbo"),
(7, "Gpt 4 Omni"),
(8, "Gpt 4 Omni Mini"),
]
),
default=list,
size=None,
),
),
]
2 changes: 2 additions & 0 deletions ayushma/models/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class ModelType(IntegerChoices):
GPT_4_32K = 4
GPT_4_VISUAL = 5
GPT_4_TURBO = 6
GPT_4_OMNI = 7
GPT_4_OMNI_MINI = 8


class StatusChoices(IntegerChoices):
Expand Down
Loading

0 comments on commit bd9b8aa

Please sign in to comment.