LangModels / app.py
amasood's picture
Create app.py
82690a5 verified
raw
history blame
1.79 kB
import streamlit as st
from langchain_community.llms import HuggingFaceHub
# Models for each task
SUMMARY_MODEL = "google/flan-t5-small"
QUESTIONS_MODEL = "tiiuae/falcon-rw-1b"
KEYWORDS_MODEL = "google/flan-t5-small"
# Function to get LangChain LLM
def get_llm(model_id):
return HuggingFaceHub(
repo_id=model_id,
model_kwargs={"temperature": 0.5, "max_new_tokens": 150},
task="text2text-generation"
)
# Streamlit app UI
st.set_page_config(page_title="🧠 Multi-LLM Research Assistant")
st.title("🧠 Research Assistant using Multiple LLMs via LangChain")
topic = st.text_input("πŸ” Enter your research topic")
if st.button("Run Multi-LLM Analysis"):
if not topic.strip():
st.warning("Please enter a topic to continue.")
else:
with st.spinner("Generating..."):
# Step 1: Summary
summary_prompt = f"Provide a short summary about: {topic}"
summary_model = get_llm(SUMMARY_MODEL)
summary = summary_model.predict(summary_prompt)
# Step 2: Research Questions
questions_prompt = f"Give three research questions about: {topic}"
questions_model = get_llm(QUESTIONS_MODEL)
questions = questions_model.predict(questions_prompt)
# Step 3: Keywords
keywords_prompt = f"List five keywords related to: {topic}"
keywords_model = get_llm(KEYWORDS_MODEL)
keywords = keywords_model.predict(keywords_prompt)
# Display results
st.success("βœ… Done! Here's your research output:")
st.subheader("πŸ“„ Summary")
st.write(summary)
st.subheader("❓ Research Questions")
st.write(questions)
st.subheader("πŸ”‘ Keywords")
st.write(keywords)