Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
from crewai import Agent, Task, Crew
|
| 4 |
+
from crewai import Agent
|
| 5 |
+
from crewai import Task, Crew
|
| 6 |
+
|
| 7 |
+
from langchain.tools import tool
|
| 8 |
+
import requests
|
| 9 |
+
import hashlib
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
import schedule
|
| 13 |
+
import time
|
| 14 |
+
|
| 15 |
+
@tool
|
| 16 |
+
def check_streamlit_updates(previous_hash: str) -> str:
|
| 17 |
+
# URL of the Streamlit documentation
|
| 18 |
+
doc_url = 'https://docs.streamlit.io/'
|
| 19 |
+
|
| 20 |
+
# Fetch the content
|
| 21 |
+
response = requests.get(doc_url)
|
| 22 |
+
content = response.text
|
| 23 |
+
|
| 24 |
+
# Hash the content
|
| 25 |
+
current_hash = hashlib.md5(content.encode()).hexdigest()
|
| 26 |
+
|
| 27 |
+
# Compare the hash with the previous hash
|
| 28 |
+
if current_hash != previous_hash:
|
| 29 |
+
return f'Updates found in Streamlit documentation. New Hash: {current_hash}', current_hash
|
| 30 |
+
else:
|
| 31 |
+
return 'No updates in Streamlit documentation.', current_hash
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
# Define the Streamlit Documentation Expert agent
|
| 36 |
+
streamlit_expert = Agent(
|
| 37 |
+
role='Streamlit Documentation Expert',
|
| 38 |
+
goal='Stay updated with the latest Streamlit documentation and notify users',
|
| 39 |
+
tools=[check_streamlit_updates], # Assuming the tool is already defined and available
|
| 40 |
+
verbose=True
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
# Define a task for periodic update checks
|
| 46 |
+
update_task = Task(
|
| 47 |
+
description='Check for updates in the Streamlit documentation.',
|
| 48 |
+
agent=streamlit_expert
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
# Define a crew with the Streamlit Documentation Expert
|
| 52 |
+
crew = Crew(
|
| 53 |
+
agents=[streamlit_expert],
|
| 54 |
+
tasks=[update_task],
|
| 55 |
+
verbose=True
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
# This is a conceptual example and might require adjustments based on the deployment environment
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def check_for_updates():
|
| 63 |
+
# Trigger the Crew to perform the update task
|
| 64 |
+
# Implementation details depend on CrewAI's execution model
|
| 65 |
+
crew.kickoff()
|
| 66 |
+
|
| 67 |
+
# Schedule the task
|
| 68 |
+
schedule.every().day.at("10:00").do(check_for_updates)
|
| 69 |
+
|
| 70 |
+
while True:
|
| 71 |
+
schedule.run_pending()
|
| 72 |
+
time.sleep(60)
|
| 73 |
+
|
| 74 |
+
# Define the custom tool
|
| 75 |
+
@tool
|
| 76 |
+
def check_streamlit_updates(previous_hash: str) -> str:
|
| 77 |
+
# ... (custom tool code here)
|
| 78 |
+
|
| 79 |
+
# Define the Streamlit Documentation Expert agent
|
| 80 |
+
streamlit_expert = Agent(
|
| 81 |
+
role='Streamlit Documentation Expert',
|
| 82 |
+
goal='Stay updated with the latest Streamlit documentation and notify users',
|
| 83 |
+
tools=[check_streamlit_updates],
|
| 84 |
+
verbose=True
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
# Define a task for periodic update checks
|
| 88 |
+
update_task = Task(
|
| 89 |
+
description='Check for updates in the Streamlit documentation.',
|
| 90 |
+
agent=streamlit_expert
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
# Define a crew with the Streamlit Documentation Expert
|
| 94 |
+
crew = Crew(
|
| 95 |
+
agents=[streamlit_expert],
|
| 96 |
+
tasks=[update_task],
|
| 97 |
+
verbose=True
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
# Streamlit app setup
|
| 102 |
+
st.title('CrewAI Streamlit Documentation Expert Control Panel')
|
| 103 |
+
|
| 104 |
+
# Start CrewAI process button
|
| 105 |
+
if st.button('Check Streamlit Documentation Updates'):
|
| 106 |
+
# Code to trigger the CrewAI process
|
| 107 |
+
# ...
|
| 108 |
+
|
| 109 |
+
# Display results
|
| 110 |
+
st.write('Latest check results: ...')
|
| 111 |
+
|
| 112 |
+
# Settings for check frequency
|
| 113 |
+
check_frequency = st.selectbox(
|
| 114 |
+
'Select Check Frequency',
|
| 115 |
+
['Daily', 'Weekly', 'Manually']
|
| 116 |
+
)
|