diff --git a/Vishnu Sudheer/Hackathon/__init__.py b/Vishnu Sudheer/Hackathon/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Vishnu Sudheer/Hackathon/__pycache__/__init__.cpython-311.pyc b/Vishnu Sudheer/Hackathon/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..f77b7de Binary files /dev/null and b/Vishnu Sudheer/Hackathon/__pycache__/__init__.cpython-311.pyc differ diff --git a/Vishnu Sudheer/Hackathon/__pycache__/settings.cpython-311.pyc b/Vishnu Sudheer/Hackathon/__pycache__/settings.cpython-311.pyc new file mode 100644 index 0000000..74da77c Binary files /dev/null and b/Vishnu Sudheer/Hackathon/__pycache__/settings.cpython-311.pyc differ diff --git a/Vishnu Sudheer/Hackathon/__pycache__/urls.cpython-311.pyc b/Vishnu Sudheer/Hackathon/__pycache__/urls.cpython-311.pyc new file mode 100644 index 0000000..5827f1f Binary files /dev/null and b/Vishnu Sudheer/Hackathon/__pycache__/urls.cpython-311.pyc differ diff --git a/Vishnu Sudheer/Hackathon/__pycache__/wsgi.cpython-311.pyc b/Vishnu Sudheer/Hackathon/__pycache__/wsgi.cpython-311.pyc new file mode 100644 index 0000000..defd798 Binary files /dev/null and b/Vishnu Sudheer/Hackathon/__pycache__/wsgi.cpython-311.pyc differ diff --git a/Vishnu Sudheer/Hackathon/asgi.py b/Vishnu Sudheer/Hackathon/asgi.py new file mode 100644 index 0000000..1833f06 --- /dev/null +++ b/Vishnu Sudheer/Hackathon/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for Hackathon project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Hackathon.settings') + +application = get_asgi_application() diff --git a/Vishnu Sudheer/Hackathon/settings.py b/Vishnu Sudheer/Hackathon/settings.py new file mode 100644 index 0000000..d129bc6 --- /dev/null +++ b/Vishnu Sudheer/Hackathon/settings.py @@ -0,0 +1,135 @@ +""" +Django settings for Hackathon project. + +Generated by 'django-admin startproject' using Django 5.0. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.0/ref/settings/ +""" + +from pathlib import Path +import os +from dotenv import load_dotenv + +load_dotenv() + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = os.getenv('SECRET_KEY') + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = ['*'] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'LLM' +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'Hackathon.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(BASE_DIR,'templates')], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'Hackathon.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/5.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': os.getenv('ENGINE'), + 'NAME': os.getenv('NAME'), + 'USER': os.getenv('USER'), + 'PASSWORD': os.getenv('PASSWORD'), + 'HOST': os.getenv('HOST'), + 'PORT': os.getenv('PORT') + } +} + + +# Password validation +# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.0/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.0/howto/static-files/ + +STATIC_URL = 'static/' + +MEDIA_ROOT = os.path.join(BASE_DIR,'media') +MEDIA_URL = '/media/' + +# Default primary key field type +# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/Vishnu Sudheer/Hackathon/urls.py b/Vishnu Sudheer/Hackathon/urls.py new file mode 100644 index 0000000..65a5f17 --- /dev/null +++ b/Vishnu Sudheer/Hackathon/urls.py @@ -0,0 +1,25 @@ +""" +URL configuration for Hackathon project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.0/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path,include +from django.conf import settings +from django.conf.urls.static import static + +urlpatterns = [ + path('',include('LLM.urls')), + path('admin/', admin.site.urls) +]+static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT) diff --git a/Vishnu Sudheer/Hackathon/wsgi.py b/Vishnu Sudheer/Hackathon/wsgi.py new file mode 100644 index 0000000..afe81ac --- /dev/null +++ b/Vishnu Sudheer/Hackathon/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for Hackathon project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Hackathon.settings') + +application = get_wsgi_application() diff --git a/Vishnu Sudheer/LLM/__init__.py b/Vishnu Sudheer/LLM/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Vishnu Sudheer/LLM/__pycache__/__init__.cpython-311.pyc b/Vishnu Sudheer/LLM/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..72b06a0 Binary files /dev/null and b/Vishnu Sudheer/LLM/__pycache__/__init__.cpython-311.pyc differ diff --git a/Vishnu Sudheer/LLM/__pycache__/admin.cpython-311.pyc b/Vishnu Sudheer/LLM/__pycache__/admin.cpython-311.pyc new file mode 100644 index 0000000..d035d6d Binary files /dev/null and b/Vishnu Sudheer/LLM/__pycache__/admin.cpython-311.pyc differ diff --git a/Vishnu Sudheer/LLM/__pycache__/apps.cpython-311.pyc b/Vishnu Sudheer/LLM/__pycache__/apps.cpython-311.pyc new file mode 100644 index 0000000..7b434b7 Binary files /dev/null and b/Vishnu Sudheer/LLM/__pycache__/apps.cpython-311.pyc differ diff --git a/Vishnu Sudheer/LLM/__pycache__/models.cpython-311.pyc b/Vishnu Sudheer/LLM/__pycache__/models.cpython-311.pyc new file mode 100644 index 0000000..fe94945 Binary files /dev/null and b/Vishnu Sudheer/LLM/__pycache__/models.cpython-311.pyc differ diff --git a/Vishnu Sudheer/LLM/__pycache__/urls.cpython-311.pyc b/Vishnu Sudheer/LLM/__pycache__/urls.cpython-311.pyc new file mode 100644 index 0000000..87070b3 Binary files /dev/null and b/Vishnu Sudheer/LLM/__pycache__/urls.cpython-311.pyc differ diff --git a/Vishnu Sudheer/LLM/__pycache__/views.cpython-311.pyc b/Vishnu Sudheer/LLM/__pycache__/views.cpython-311.pyc new file mode 100644 index 0000000..64bc9f7 Binary files /dev/null and b/Vishnu Sudheer/LLM/__pycache__/views.cpython-311.pyc differ diff --git a/Vishnu Sudheer/LLM/admin.py b/Vishnu Sudheer/LLM/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/Vishnu Sudheer/LLM/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/Vishnu Sudheer/LLM/apps.py b/Vishnu Sudheer/LLM/apps.py new file mode 100644 index 0000000..1770995 --- /dev/null +++ b/Vishnu Sudheer/LLM/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class LlmConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'LLM' diff --git a/Vishnu Sudheer/LLM/migrations/0001_initial.py b/Vishnu Sudheer/LLM/migrations/0001_initial.py new file mode 100644 index 0000000..e5315cb --- /dev/null +++ b/Vishnu Sudheer/LLM/migrations/0001_initial.py @@ -0,0 +1,23 @@ +# Generated by Django 5.0 on 2024-03-28 16:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Output', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('title', models.CharField(max_length=250, null=True)), + ('authors', models.TextField(null=True)), + ('alt', models.CharField(max_length=250, null=True)), + ], + ), + ] diff --git a/Vishnu Sudheer/LLM/migrations/0002_outputtable_delete_output.py b/Vishnu Sudheer/LLM/migrations/0002_outputtable_delete_output.py new file mode 100644 index 0000000..e7078db --- /dev/null +++ b/Vishnu Sudheer/LLM/migrations/0002_outputtable_delete_output.py @@ -0,0 +1,25 @@ +# Generated by Django 5.0 on 2024-03-28 18:15 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('LLM', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='OutputTable', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('title', models.CharField(max_length=250, null=True)), + ('authors', models.TextField(null=True)), + ('alt', models.CharField(max_length=250, null=True)), + ], + ), + migrations.DeleteModel( + name='Output', + ), + ] diff --git a/Vishnu Sudheer/LLM/migrations/0003_output_delete_outputtable.py b/Vishnu Sudheer/LLM/migrations/0003_output_delete_outputtable.py new file mode 100644 index 0000000..b838825 --- /dev/null +++ b/Vishnu Sudheer/LLM/migrations/0003_output_delete_outputtable.py @@ -0,0 +1,25 @@ +# Generated by Django 5.0 on 2024-03-28 18:27 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('LLM', '0002_outputtable_delete_output'), + ] + + operations = [ + migrations.CreateModel( + name='Output', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('title', models.CharField(max_length=250, null=True)), + ('authors', models.TextField(null=True)), + ('alt', models.CharField(max_length=250, null=True)), + ], + ), + migrations.DeleteModel( + name='OutputTable', + ), + ] diff --git a/Vishnu Sudheer/LLM/migrations/0004_outputtable_delete_output.py b/Vishnu Sudheer/LLM/migrations/0004_outputtable_delete_output.py new file mode 100644 index 0000000..fd9f868 --- /dev/null +++ b/Vishnu Sudheer/LLM/migrations/0004_outputtable_delete_output.py @@ -0,0 +1,25 @@ +# Generated by Django 5.0 on 2024-03-28 18:48 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('LLM', '0003_output_delete_outputtable'), + ] + + operations = [ + migrations.CreateModel( + name='OutputTable', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('title', models.CharField(max_length=250, null=True)), + ('authors', models.TextField(null=True)), + ('alt', models.CharField(max_length=250, null=True)), + ], + ), + migrations.DeleteModel( + name='Output', + ), + ] diff --git a/Vishnu Sudheer/LLM/migrations/0005_output_delete_outputtable.py b/Vishnu Sudheer/LLM/migrations/0005_output_delete_outputtable.py new file mode 100644 index 0000000..f63f55d --- /dev/null +++ b/Vishnu Sudheer/LLM/migrations/0005_output_delete_outputtable.py @@ -0,0 +1,25 @@ +# Generated by Django 5.0 on 2024-03-28 19:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('LLM', '0004_outputtable_delete_output'), + ] + + operations = [ + migrations.CreateModel( + name='Output', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('title', models.CharField(max_length=250, null=True)), + ('authors', models.TextField(null=True)), + ('alt', models.CharField(max_length=250, null=True)), + ], + ), + migrations.DeleteModel( + name='OutputTable', + ), + ] diff --git a/Vishnu Sudheer/LLM/migrations/0006_alter_output_id.py b/Vishnu Sudheer/LLM/migrations/0006_alter_output_id.py new file mode 100644 index 0000000..b2400d4 --- /dev/null +++ b/Vishnu Sudheer/LLM/migrations/0006_alter_output_id.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0 on 2024-03-29 02:38 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('LLM', '0005_output_delete_outputtable'), + ] + + operations = [ + migrations.AlterField( + model_name='output', + name='id', + field=models.IntegerField(primary_key=True, serialize=False), + ), + ] diff --git a/Vishnu Sudheer/LLM/migrations/__init__.py b/Vishnu Sudheer/LLM/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Vishnu Sudheer/LLM/migrations/__pycache__/0001_initial.cpython-311.pyc b/Vishnu Sudheer/LLM/migrations/__pycache__/0001_initial.cpython-311.pyc new file mode 100644 index 0000000..d997b4b Binary files /dev/null and b/Vishnu Sudheer/LLM/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/Vishnu Sudheer/LLM/migrations/__pycache__/0002_outputtable_delete_output.cpython-311.pyc b/Vishnu Sudheer/LLM/migrations/__pycache__/0002_outputtable_delete_output.cpython-311.pyc new file mode 100644 index 0000000..910dac0 Binary files /dev/null and b/Vishnu Sudheer/LLM/migrations/__pycache__/0002_outputtable_delete_output.cpython-311.pyc differ diff --git a/Vishnu Sudheer/LLM/migrations/__pycache__/0003_output_delete_outputtable.cpython-311.pyc b/Vishnu Sudheer/LLM/migrations/__pycache__/0003_output_delete_outputtable.cpython-311.pyc new file mode 100644 index 0000000..f238bf8 Binary files /dev/null and b/Vishnu Sudheer/LLM/migrations/__pycache__/0003_output_delete_outputtable.cpython-311.pyc differ diff --git a/Vishnu Sudheer/LLM/migrations/__pycache__/0004_outputtable_delete_output.cpython-311.pyc b/Vishnu Sudheer/LLM/migrations/__pycache__/0004_outputtable_delete_output.cpython-311.pyc new file mode 100644 index 0000000..640d342 Binary files /dev/null and b/Vishnu Sudheer/LLM/migrations/__pycache__/0004_outputtable_delete_output.cpython-311.pyc differ diff --git a/Vishnu Sudheer/LLM/migrations/__pycache__/0005_output_delete_outputtable.cpython-311.pyc b/Vishnu Sudheer/LLM/migrations/__pycache__/0005_output_delete_outputtable.cpython-311.pyc new file mode 100644 index 0000000..e5b2f62 Binary files /dev/null and b/Vishnu Sudheer/LLM/migrations/__pycache__/0005_output_delete_outputtable.cpython-311.pyc differ diff --git a/Vishnu Sudheer/LLM/migrations/__pycache__/0006_alter_output_id.cpython-311.pyc b/Vishnu Sudheer/LLM/migrations/__pycache__/0006_alter_output_id.cpython-311.pyc new file mode 100644 index 0000000..56498b9 Binary files /dev/null and b/Vishnu Sudheer/LLM/migrations/__pycache__/0006_alter_output_id.cpython-311.pyc differ diff --git a/Vishnu Sudheer/LLM/migrations/__pycache__/__init__.cpython-311.pyc b/Vishnu Sudheer/LLM/migrations/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..df2f6cf Binary files /dev/null and b/Vishnu Sudheer/LLM/migrations/__pycache__/__init__.cpython-311.pyc differ diff --git a/Vishnu Sudheer/LLM/models.py b/Vishnu Sudheer/LLM/models.py new file mode 100644 index 0000000..bf6723c --- /dev/null +++ b/Vishnu Sudheer/LLM/models.py @@ -0,0 +1,16 @@ +from django.db import models + +# Create your models here. +class Output(models.Model): + id=models.IntegerField(primary_key=True) + title=models.CharField(max_length=255,null=True) + year=models.IntegerField(null=True) + journal=models.CharField(max_length=255,null=True) + authors=models.TextField(null=True) + description=models.TextField(null=True) + constructs=models.TextField(null=True) + context=models.TextField(null=True) + study=models.TextField(null=True) + level=models.TextField(null=True) + findings=models.TextField(null=True) + summary=models.TextField(null=True) \ No newline at end of file diff --git a/Vishnu Sudheer/LLM/tests.py b/Vishnu Sudheer/LLM/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/Vishnu Sudheer/LLM/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Vishnu Sudheer/LLM/urls.py b/Vishnu Sudheer/LLM/urls.py new file mode 100644 index 0000000..4542792 --- /dev/null +++ b/Vishnu Sudheer/LLM/urls.py @@ -0,0 +1,8 @@ +from django.urls import path +from . import views + +urlpatterns={ + path('',views.home), + path('upload',views.upload), + path('create',views.create) +} \ No newline at end of file diff --git a/Vishnu Sudheer/LLM/views.py b/Vishnu Sudheer/LLM/views.py new file mode 100644 index 0000000..6f9759e --- /dev/null +++ b/Vishnu Sudheer/LLM/views.py @@ -0,0 +1,214 @@ +from django.shortcuts import render +from django.conf import settings +import os +import convertapi +import pytesseract as pyt +from PIL import Image +import google.generativeai as genai +import PyPDF2 +from openpyxl import Workbook +from .models import * +from dotenv import load_dotenv + +load_dotenv() + +def home(request): + #Home page of the website + return render(request,'upload.html') + +def upload(request): + #Handling file upload + if request.method=='POST' and request.FILES.get('pdf'): + pdf_file=request.FILES['pdf'] + file_path=os.path.join(settings.MEDIA_ROOT,'pdfs',pdf_file.name) + + # Save the uploaded file + with open(file_path,'wb') as destination: + for chunk in pdf_file.chunks(): + destination.write(chunk) + + #Finding out the number of pages in the uploaded pdf + with open(file_path,'rb') as file: + pdf_reader=PyPDF2.PdfReader(file) + pages=len(pdf_reader.pages) + + #Data pre-processing + #1. Split pdf into individual pages + #2. Convert .pdf to .png format using api + # Code snippet is using the ConvertAPI Python Client: https://github.com/ConvertAPI/convertapi-python + convertapi.api_secret=os.getenv('API_SECRET') + convertapi.convert('png',{'File': file_path},from_format='pdf').save_files('media/pngs') + + #Configure tesseract ocr + pyt.pytesseract.tesseract_cmd="C:\\Users\\Vishnu\\AppData\\Local\\Programs\\Tesseract-OCR\\tesseract.exe" + + #Extract the name of the pdf without the extension + dot_index=pdf_file.name.rfind('.') + if dot_index!=-1: + name=pdf_file.name[:dot_index] + else: + name=pdf_file.name + + #Configure Google Gemini api for prompting + genai.configure(api_key=os.getenv('API_KEY')) + generation_config={"temperature": 0.9,"top_p": 1,"top_k": 1,"max_output_tokens": 2048} + safety_settings = [ + { + "category": "HARM_CATEGORY_HARASSMENT", + "threshold": "BLOCK_NONE" + }, + { + "category": "HARM_CATEGORY_HATE_SPEECH", + "threshold": "BLOCK_NONE" + }, + { + "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", + "threshold": "BLOCK_NONE" + }, + { + "category": "HARM_CATEGORY_DANGEROUS_CONTENT", + "threshold": "BLOCK_NONE" + } + ] + model = genai.GenerativeModel(model_name="gemini-1.0-pro", generation_config=generation_config,safety_settings=safety_settings) + convo = model.start_chat(history=[]) + + os.remove(file_path) #Delete pdf file from the folder after pre-processing + + #Clear all previous entries in the database table + if Output.objects.exists(): + Output.objects.all().delete() + + #passing pages one by one to the llm for prompting + for i in range(1,pages+1): + if i==1: + file_path=f'media/pngs/{name}.png' + content=pyt.image_to_string(Image.open(file_path)) + else: + file_path=f'media/pngs/{name}-{i}.png' + content=pyt.image_to_string(Image.open(file_path)) + try: + convo.send_message( + f''' + Get the title of the text provided in {content}. + Return the output as a string of the exact name as the title of the content. + Do not add any other content of your own in the output. + ''' + ) + title=convo.last.text + convo.send_message( + f''' + Get the year of the text provided in {content}. + Return the output as a string of the exact year as the year of the content. + Do not add any other content of your own in the output. + ''' + ) + year=int(convo.last.text) + convo.send_message( + f''' + Get the journal of publication of the text provided in {content}. + Return the output as a string of the exact journal as the journal of the content. + Do not add any other content of your own in the output. + ''' + ) + journal=convo.last.text + convo.send_message( + f''' + Get the names of the authors in {content}. + Return the output as a string of all the names of authors separated by commas. + Do not add any other content of your own in the output. + ''' + ) + authors=convo.last.text + convo.send_message( + f''' + Get the type of the text provided in {content}. + Return the output as a string of the type of the content. + ''' + ) + genre=convo.last.text + convo.send_message( + f''' + Get the short description of the text provided in {content}. + Return the output as a string of the description of the content. + ''' + ) + description=convo.last.text + convo.send_message( + f''' + Get the focal constructs of the text provided in {content}. + Return the output as a string of the focal constructs of the content. + ''' + ) + constructs=convo.last.text + convo.send_message( + f''' + Get the theoretical perspectives of the text provided in {content}. + Return the output as a string of the theoretical perspectives of the content. + ''' + ) + perspectives=convo.last.text + convo.send_message( + f''' + Get the context of the text provided in {content}. + Return the output as a string of the context of the content. + ''' + ) + context=convo.last.text + convo.send_message( + f''' + Get the study design of the text provided in {content}. + Return the output as a string of the study design of the content. + ''' + ) + study=convo.last.text + convo.send_message( + f''' + Get the levels of the text provided in {content}. + Return the output as a string of the levels of the content. + ''' + ) + level=convo.last.text + convo.send_message( + f''' + Get the findings of the text provided in {content}. + Return the output as a string of the findings of the content. + ''' + ) + findings=convo.last.text + convo.send_message( + f''' + Get the summary of the text provided in {content}. + Return the output as a string of the summary of the content. + ''' + ) + summary=convo.last.text + except Exception as e: + i=i-1 + continue + + #Stores the title,authorand alternate title in the database + output=Output(id=i,title=title,year=year,journal=journal,authors=authors,description=description,constructs=constructs,context=context,study=study,level=level,findings=findings,summary=summary) + output.save() + os.remove(file_path) + + response=Output.objects.all() + return render(request,'view.html',{'response':response}) + else: + error = "Upload PDF" + return render(request,'error.html',{'error':error}) + +def create(request): + data=Output.objects.all() + + wb=Workbook() + ws=wb.active + + ws.append(['S No.','Title','Year','Journal','Authors','Description','Constructs','Context','Study','Level','Findings','Summary']) + for i in data: + ws.append([i.id,i.title,i.year,i.journal,i.authors,i.description,i.constructs,i.context,i.study,i.level,i.findings,i.summary]) + + file_path = os.path.join(settings.MEDIA_ROOT,'excel','titlr.xlsx') + + wb.save(file_path) + return render(request,'download.html') \ No newline at end of file diff --git a/Vishnu Sudheer/Letter.txt b/Vishnu Sudheer/Letter.txt new file mode 100644 index 0000000..7523966 --- /dev/null +++ b/Vishnu Sudheer/Letter.txt @@ -0,0 +1,9 @@ +Excited about LLM internship at Hardpoint Consulting (International Hackathon 2024). Strong academic background and passion for AI/LLMs/web dev make me eager to contribute and develop my skills in any area. + +Experienced using LLMs with Python frameworks. Hackathon projects led to a deep understanding of LLM training, which I'm eager to apply professionally. + +Ready to tackle any task to gain experience and contribute to team success. Hardpoint Consulting's vision inspires me. + +Short-term goal: Diverse experiences in 1 year. Mid-term goal (3 years): Integrate AI/LLMs into daily life. Long-term goal (5 years): Lead a passionate AI team, developing advancements that rival tech giants. + +Thank you for considering me. Eager to discuss how my skills align with your program. diff --git a/Vishnu Sudheer/images/download.png b/Vishnu Sudheer/images/download.png new file mode 100644 index 0000000..4d46910 Binary files /dev/null and b/Vishnu Sudheer/images/download.png differ diff --git a/Vishnu Sudheer/images/excel.png b/Vishnu Sudheer/images/excel.png new file mode 100644 index 0000000..bdea514 Binary files /dev/null and b/Vishnu Sudheer/images/excel.png differ diff --git a/Vishnu Sudheer/images/upload.png b/Vishnu Sudheer/images/upload.png new file mode 100644 index 0000000..10dbf64 Binary files /dev/null and b/Vishnu Sudheer/images/upload.png differ diff --git a/Vishnu Sudheer/images/view.png b/Vishnu Sudheer/images/view.png new file mode 100644 index 0000000..ae25921 Binary files /dev/null and b/Vishnu Sudheer/images/view.png differ diff --git a/Vishnu Sudheer/manage.py b/Vishnu Sudheer/manage.py new file mode 100644 index 0000000..e10185d --- /dev/null +++ b/Vishnu Sudheer/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Hackathon.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/Vishnu Sudheer/media/excel/titlr.xlsx b/Vishnu Sudheer/media/excel/titlr.xlsx new file mode 100644 index 0000000..6e3db5b Binary files /dev/null and b/Vishnu Sudheer/media/excel/titlr.xlsx differ diff --git a/Vishnu Sudheer/requirements.txt b/Vishnu Sudheer/requirements.txt new file mode 100644 index 0000000..35effd3 --- /dev/null +++ b/Vishnu Sudheer/requirements.txt @@ -0,0 +1,6 @@ +Django>=3.2.0 +pytesseract>=0.3.8 +Pillow>=9.0.0 +google-generativeai>=0.2.0 +python-dotenv>=0.19.0 +openpyxl>=3.0.0 diff --git a/Vishnu Sudheer/templates/download.html b/Vishnu Sudheer/templates/download.html new file mode 100644 index 0000000..02a366d --- /dev/null +++ b/Vishnu Sudheer/templates/download.html @@ -0,0 +1,80 @@ + + +
+ + +Titlr v2 is a state-of-the-art application engineered to automate the extraction of vital information from scientific documents. Ideal for researchers, academics, and students alike, Titlr empowers users to swiftly analyze documents, pinpoint essential details that encapsulate the document's core concepts.
+| S No. | +Title | +Year | +Journal | +Authors | +Description | +Constructs | +Context | +Study | +Level | +Findings | +Summary | +
|---|---|---|---|---|---|---|---|---|---|---|---|
| {{ entry.id }} | +{{ entry.title }} | +{{ entry.year }} | +{{ entry.journal }} | +{{ entry.authors }} | +{{ entry.description }} | +{{ entry.constructs }} | +{{ entry.context }} | +{{ entry.study }} | +{{ entry.level }} | +{{ entry.findings }} | +{{ entry.summary }} | +