Skip to content

Commit

Permalink
Merge branch 'main' into merge-with-main
Browse files Browse the repository at this point in the history
  • Loading branch information
shadrach-tayo committed Jun 24, 2024
2 parents f8fddaa + 350e34e commit 200fb3b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions app/langchain_orcid2.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def published_metadata(doi, cremail, pyalexemail):
'creator': authors_info,
'datePublished':pub_date,
'keywords':keywords,
'abstract':abstract,
'oa_url':oa_url,
'license':license
}
Expand Down Expand Up @@ -393,7 +394,8 @@ async def langchain_paper_search(pdf_CID):
queries_schemas_docs = [
("Tell me who all the authors of this paper are. Your response should be a comma separated list of the authors of the paper, \
looking like 'first author name, second author name", document),
("Tell me the title of this paper", document)
("Tell me the title of this paper", document),
("Tell me the abstract of this paper, do not change any of the words only return the abstract as it is written", document)
]

tasks = []
Expand All @@ -406,11 +408,12 @@ async def langchain_paper_search(pdf_CID):
summary = await asyncio.gather(*tasks)

# Extracting individual elements from the summary
authors, title = summary
authors, title, abstract = summary

llm_output = {
"authors": authors,
"title": title
"title": title,
"abstract": abstract
}

#transform outputs into comma separated lists and then into a structured dictionary of authors.
Expand All @@ -435,12 +438,14 @@ def get_orcid(authors):
orcid = response["results"][0]["orcid"]
print(orcid)
affiliation = response["results"][0]["affiliations"][0]["institution"]["display_name"]
ror = response["results"][0]["affiliations"][0]["institution"]["ror"]
display_name = response["results"][0]["display_name"] # Updated to use display_name

author_info = {
"@id": f"{orcid}",
"role": "Person",
"affiliation": affiliation,
"ror": ror,
"name": display_name
}

Expand Down Expand Up @@ -495,8 +500,11 @@ def run(pdf=None, doi=None, cremail=None, pyalexemail=None):
#published_metadata(doi, cremail, pyalexemail)['creator']
if not doi_validation["is_valid"] or published_metadata(doi, cremail, pyalexemail)['creator'] is None and pdf:
print("DOI isn't valid, searching through the PDF for metadata")
output = asyncio.run(langchain_paper_search(pdf))
return
if pdf:
output = asyncio.run(langchain_paper_search(pdf))
return output
else:
return "DOI error. Please use another DOI or include a PDF."
elif not doi_validation["is_valid"] and not pdf:
print("Failed to fetch the PDF and Metadata from the DOI. Please fill in your metadata manually or upload a PDF.")
return
Expand Down

0 comments on commit 200fb3b

Please sign in to comment.