Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import os | |
| from crewai import Agent, Task, Crew | |
| st.set_page_config(page_title="CrewAI Fix", layout="wide") | |
| st.title("CrewAI Clean Encoding Version") | |
| with st.sidebar: | |
| hf_token = st.text_input("Hugging Face Token", type="password") | |
| if st.button("Run"): | |
| if not hf_token: | |
| st.error("Please enter a token.") | |
| else: | |
| # Use the variable name LiteLLM expects | |
| os.environ["HUGGINGFACE_API_KEY"] = hf_token | |
| # Use a reliable model string | |
| model_id = "huggingface/Qwen/Qwen2.5-7B-Instruct" | |
| try: | |
| # 1. AGENTS (Ensure NO emojis or special symbols here) | |
| analyst = Agent( | |
| role='Technical Researcher', | |
| goal='Summarize the benefits of AI agents.', | |
| backstory='A professional software engineer focused on automation.', | |
| llm=model_id, | |
| verbose=True, | |
| allow_delegation=False | |
| ) | |
| # 2. TASKS (Keep text plain and simple) | |
| simple_task = Task( | |
| description="List two major benefits of AI orchestration.", | |
| expected_output="A two-sentence summary.", | |
| agent=analyst | |
| ) | |
| # 3. CREW | |
| crew = Crew( | |
| agents=[analyst], | |
| tasks=[simple_task] | |
| ) | |
| with st.spinner("Processing..."): | |
| result = crew.kickoff() | |
| st.success("Execution Successful!") | |
| st.write(str(result)) | |
| except Exception as e: | |
| st.error(f"Error: {e}") |