chburhan64 commited on
Commit
d0f2866
·
verified ·
1 Parent(s): 227bfd9

Upload idea_generator.py

Browse files
Files changed (1) hide show
  1. idea_generator.py +39 -0
idea_generator.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain.chains.combine_documents import create_stuff_documents_chain
2
+ from langchain.chains import LLMChain
3
+ from langchain_core.prompts import ChatPromptTemplate
4
+ from summarizer import get_summary_prompt
5
+ from gap_analyzer import get_gap_prompt
6
+
7
+ def get_idea_prompt():
8
+ """Get the prompt template for research idea generation"""
9
+ return ChatPromptTemplate.from_template("""
10
+ Given the research gaps:
11
+ {gaps}
12
+ Suggest 2-3 original research project ideas or questions that address these gaps. Explain why they are valuable.
13
+ """)
14
+
15
+ def suggest_research_ideas(llm, documents):
16
+ """
17
+ Suggest research ideas based on identified gaps
18
+
19
+ Args:
20
+ llm: Language model instance
21
+ documents: List of document chunks
22
+
23
+ Returns:
24
+ str: Research ideas suggestions
25
+ """
26
+ # First get summary
27
+ summary_prompt = get_summary_prompt()
28
+ chain1 = create_stuff_documents_chain(llm, summary_prompt)
29
+ summary = chain1.invoke({"context": documents})
30
+
31
+ # Then identify gaps
32
+ gap_prompt = get_gap_prompt()
33
+ chain2 = LLMChain(llm=llm, prompt=gap_prompt)
34
+ gaps = chain2.invoke({"summary": summary})
35
+
36
+ # Finally suggest ideas
37
+ idea_prompt = get_idea_prompt()
38
+ chain3 = LLMChain(llm=llm, prompt=idea_prompt)
39
+ return chain3.invoke({"gaps": gaps})