amasood commited on
Commit
82690a5
Β·
verified Β·
1 Parent(s): dcb66d8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -0
app.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from langchain_community.llms import HuggingFaceHub
3
+
4
+ # Models for each task
5
+ SUMMARY_MODEL = "google/flan-t5-small"
6
+ QUESTIONS_MODEL = "tiiuae/falcon-rw-1b"
7
+ KEYWORDS_MODEL = "google/flan-t5-small"
8
+
9
+ # Function to get LangChain LLM
10
+ def get_llm(model_id):
11
+ return HuggingFaceHub(
12
+ repo_id=model_id,
13
+ model_kwargs={"temperature": 0.5, "max_new_tokens": 150},
14
+ task="text2text-generation"
15
+ )
16
+
17
+ # Streamlit app UI
18
+ st.set_page_config(page_title="🧠 Multi-LLM Research Assistant")
19
+ st.title("🧠 Research Assistant using Multiple LLMs via LangChain")
20
+
21
+ topic = st.text_input("πŸ” Enter your research topic")
22
+
23
+ if st.button("Run Multi-LLM Analysis"):
24
+ if not topic.strip():
25
+ st.warning("Please enter a topic to continue.")
26
+ else:
27
+ with st.spinner("Generating..."):
28
+
29
+ # Step 1: Summary
30
+ summary_prompt = f"Provide a short summary about: {topic}"
31
+ summary_model = get_llm(SUMMARY_MODEL)
32
+ summary = summary_model.predict(summary_prompt)
33
+
34
+ # Step 2: Research Questions
35
+ questions_prompt = f"Give three research questions about: {topic}"
36
+ questions_model = get_llm(QUESTIONS_MODEL)
37
+ questions = questions_model.predict(questions_prompt)
38
+
39
+ # Step 3: Keywords
40
+ keywords_prompt = f"List five keywords related to: {topic}"
41
+ keywords_model = get_llm(KEYWORDS_MODEL)
42
+ keywords = keywords_model.predict(keywords_prompt)
43
+
44
+ # Display results
45
+ st.success("βœ… Done! Here's your research output:")
46
+ st.subheader("πŸ“„ Summary")
47
+ st.write(summary)
48
+
49
+ st.subheader("❓ Research Questions")
50
+ st.write(questions)
51
+
52
+ st.subheader("πŸ”‘ Keywords")
53
+ st.write(keywords)