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

AIFARMS Springer Ingestion w Doc Group #263

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion ai_ta_backend/database/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self):
# Create a Supabase client
self.supabase_client = supabase.create_client( # type: ignore
supabase_url=os.environ['SUPABASE_URL'], supabase_key=os.environ['SUPABASE_API_KEY'])

def getAllMaterialsForCourse(self, course_name: str):
return self.supabase_client.table(
os.environ['SUPABASE_DOCUMENTS_TABLE']).select('course_name, s3_path, readable_filename, url, base_url').eq(
Expand Down Expand Up @@ -134,3 +134,5 @@ def getConversation(self, course_name: str, key: str, value: str):

def getDisabledDocGroups(self, course_name: str):
return self.supabase_client.table("doc_groups").select("name").eq("course_name", course_name).eq("enabled", False).execute()
def getCourseDocumentByS3Path(self, course_name: str, s3_path: str):
return self.supabase_client.table("documents").select("id, course_name, readable_filename, url, base_url, s3_path, created_at").eq("course_name", course_name).eq("s3_path", s3_path).execute()
51 changes: 51 additions & 0 deletions ai_ta_backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from ai_ta_backend.service.retrieval_service import RetrievalService
from ai_ta_backend.service.sentry_service import SentryService
from ai_ta_backend.service.workflow_service import WorkflowService
from ai_ta_backend.utils.pub_ingest import downloadSpringerFulltext, downloadWileyFulltext

app = Flask(__name__)
CORS(app)
Expand Down Expand Up @@ -480,6 +481,56 @@ def run_flow(service: WorkflowService) -> Response:
return response


@app.route('/get-springer-fulltext', methods=['GET'])
def get_springer_data():
course_name: str = request.args.get('course_name', default='', type=str)
issn = request.args.get('issn', default='', type=str)
subject = request.args.get('subject', default='', type=str)
journal = request.args.get('journal', default='', type=str)
title = request.args.get('title', default='', type=str)
doi = request.args.get('doi', default='', type=str)

print("In /get-springer-fulltext")

if (issn == '' and subject == '' and journal == '' and title == '' and doi == '') or course_name == '':
# proper web error "400 Bad request"
abort(
400,
description=
f"Missing required parameters: 'issn' or 'subject' or 'title' or 'journal' or 'doi' and 'course_name' must be provided."
)

fulltext = downloadSpringerFulltext(issn, subject, journal, title, doi, course_name)

response = jsonify(fulltext)
response.headers.add('Access-Control-Allow-Origin', '*')
return response

@app.route('/get-wiley-fulltext', methods=['POST'])
def get_wiley_data():
data = request.get_json()
print(data)

course_name = data['course_name']
issn = data['issn']

print("In /get-wiley-fulltext")

if issn == [] or course_name == '':
# proper web error "400 Bad request"
abort(
400,
description=
f"Missing required parameters: 'issn' or 'doi' and 'course_name' must be provided."
)

fulltext = downloadWileyFulltext(course_name, issn)

response = jsonify(fulltext)
response.headers.add('Access-Control-Allow-Origin', '*')
return response


def configure(binder: Binder) -> None:
binder.bind(RetrievalService, to=RetrievalService, scope=RequestScope)
binder.bind(PosthogService, to=PosthogService, scope=SingletonScope)
Expand Down
Empty file.
Loading