Spaces:
Sleeping
Sleeping
Create app.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445import streamlit as stfrom phi.agent import Agentfrom phi.model.groq import Groqfrom phi.tools.duckduckgo import DuckDuckGofrom phi.tools.newspaper4k import Newspaper4kimport osfrom dotenv import load_dotenv
# Load environment variablesload_dotenv()
# Access the Groq API keygroq_api_key = os.getenv("GROQ_API_KEY")
# Create the Agentagent = Agent( model=Groq(id="llama-3.3-70b-versatile", api_key=groq_api_key), tools=[DuckDuckGo(), Newspaper4k()], description="You are a senior NYT researcher writing an article on a topic.", instructions=[ "For a given topic, search for the top 5 links.", "Then read each URL and extract the article text, if a URL isn't available, ignore it.", "Analyse and prepare an NYT worthy article based on the information.", ], markdown=True, show_tool_calls=True, add_datetime_to_instructions=True, # debug_mode=True,)
# Streamlit appdef main(): st.title("NYT Article Generator") topic = st.text_input("Enter a topic:")
if st.button("Generate Article"): if topic: with st.spinner("Generating article..."): response = agent.run(topic) st.markdown(response) else: st.warning("Please enter a topic.")
if __name__ == "__main__": main()app.pyAdded+45