theRealNG commited on
Commit
1e01d68
·
1 Parent(s): 3307cbd

add support for using semantic scholar

Browse files
crew/research_article_suggester.py CHANGED
@@ -1,6 +1,7 @@
1
  from crewai import Agent, Task, Crew
2
  from langchain_openai import ChatOpenAI
3
  from tavily import TavilyClient
 
4
  import arxiv
5
  import os
6
  import json
@@ -54,6 +55,21 @@ class RecentArticleSuggester:
54
  }
55
  results.append(paper)
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  # pitch_crew = self._create_pitch_crew()
58
  research_paper_suggestions = []
59
  for result in results:
@@ -86,8 +102,8 @@ class RecentArticleSuggester:
86
  f"Formatting Instructions: {parser.get_format_instructions()}"
87
  ),
88
  HumanMessage(
89
- f"Here is the information about the research paper title: {article['title']}, url: {article['url']},"
90
- f" summary: \n{article['content']}.\n\n Research Paper content:\n{article_content}"
91
  )
92
  ])
93
  llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0.2)
@@ -127,9 +143,8 @@ class RecentArticleSuggester:
127
  f"Formatting Instructions: {pitch_parser.get_format_instructions()}"
128
  ),
129
  HumanMessage(
130
- f"Here is the information about the research paper title: {article_info['title']}, url: {article_info['url']}, "
131
- f"published_on: {article_info['published_on']}, authors: {article_info['author']}, "
132
- f"summary: \n{article_info['summary']}.\n\n Research Paper content:\n{article_info['article_content']}"
133
  )
134
  ])
135
  pitch_llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0.2)
 
1
  from crewai import Agent, Task, Crew
2
  from langchain_openai import ChatOpenAI
3
  from tavily import TavilyClient
4
+ from semanticscholar import SemanticScholar
5
  import arxiv
6
  import os
7
  import json
 
55
  }
56
  results.append(paper)
57
 
58
+ print("\nSearching for papers on Semanticscholar...")
59
+ sch = SemanticScholar()
60
+ semantic_results = sch.search_paper(
61
+ self.topic, sort='publicationDate:desc', bulk=True,
62
+ fields=['title', 'url', 'authors', 'publicationDate', 'abstract'])
63
+ for result in semantic_results[:MAX_RESULTS]:
64
+ paper = {
65
+ "title": result.title,
66
+ "authors": ", ".join(str(author.name) for author in result.authors),
67
+ "content": result.abstract,
68
+ "published_on": result.publicationDate,
69
+ "url": result.url,
70
+ }
71
+ results.append(paper)
72
+
73
  # pitch_crew = self._create_pitch_crew()
74
  research_paper_suggestions = []
75
  for result in results:
 
102
  f"Formatting Instructions: {parser.get_format_instructions()}"
103
  ),
104
  HumanMessage(
105
+ f"Here is the information about the research paper:\n {article}\n\n"
106
+ f"Research Paper content:\n{article_content}"
107
  )
108
  ])
109
  llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0.2)
 
143
  f"Formatting Instructions: {pitch_parser.get_format_instructions()}"
144
  ),
145
  HumanMessage(
146
+ f"Here is the information about the research paper:\n {article_info}\n\n"
147
+ f"Research Paper content:\n{article_info['article_content']}"
 
148
  )
149
  ])
150
  pitch_llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0.2)
requirements.txt CHANGED
@@ -7,3 +7,4 @@ langchain_openai
7
  streamlit
8
  tavily-python
9
  arxiv
 
 
7
  streamlit
8
  tavily-python
9
  arxiv
10
+ semanticscholar