Spaces:
Build error
Build error
File size: 1,792 Bytes
82690a5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
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)
|