rianders commited on
Commit
ebd164a
·
verified ·
1 Parent(s): 9c27d01

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -12
app.py CHANGED
@@ -10,12 +10,23 @@ from langchain.tools import tool
10
  # Load the OpenAI API key from the .env file
11
  load_dotenv()
12
 
13
- os.environ["OPENAI_API_KEY"]= userdata.get('OPENAI_API_KEY')
14
  GITHUB_ACCESS_TOKEN = userdata.get('GITHUB_ACCESS_TOKEN')
15
 
16
  # Initialize the OpenAI client
17
  openai_client = OpenAI(api_key=os.getenv('OPENAI_API_KEY'))
18
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
 
21
  # Define the custom tool for checking Streamlit documentation updates
@@ -35,12 +46,12 @@ def check_streamlit_updates(previous_hash: str) -> str:
35
  else:
36
  return 'No updates in Streamlit documentation.', current_hash
37
 
38
- # Define the Streamlit Documentation Expert agent with a backstory
39
  streamlit_expert = Agent(
40
- role='Streamlit Documentation Expert',
41
- goal='Stay updated with the latest Streamlit documentation and notify users',
42
- backstory='An AI agent specialized in monitoring and reporting the latest changes in Streamlit documentation.',
43
- tools=[check_streamlit_updates],
44
  verbose=True
45
  )
46
 
@@ -62,8 +73,7 @@ crew = Crew(
62
  chat_history = []
63
 
64
  # Streamlit app setup
65
- st.title('CrewAI Streamlit Documentation Expert - Chat Interface')
66
- st.title("Chat with Streamlit Expert")
67
 
68
 
69
  # Chat input
@@ -87,10 +97,9 @@ for chat in chat_history:
87
  st.text(chat)
88
 
89
  # Manual update button
90
- if st.button('Check for Streamlit Documentation Updates Now'):
91
- # Trigger the Crew to perform the update task manually
92
- result = crew.kickoff() # or similar logic based on CrewAI's execution model
93
  st.write(result)
94
- st.write('Latest check results: ...')
95
  else:
96
  st.write('Click the button above to check for updates.')
 
 
10
  # Load the OpenAI API key from the .env file
11
  load_dotenv()
12
 
13
+ os.environ["OPENAI_API_KEY"] = userdata.get('OPENAI_API_KEY')
14
  GITHUB_ACCESS_TOKEN = userdata.get('GITHUB_ACCESS_TOKEN')
15
 
16
  # Initialize the OpenAI client
17
  openai_client = OpenAI(api_key=os.getenv('OPENAI_API_KEY'))
18
 
19
+ # Define the custom tool for GitHub interaction
20
+ @tool
21
+ def github_streamlit_expert() -> str:
22
+ """
23
+ Interacts with the GitHub API to check for updates in the Streamlit repository.
24
+ Output: Summary of recent changes or a message indicating no updates.
25
+ """
26
+ # Here, you'll implement the logic to interact with the GitHub API
27
+ # and summarize the latest changes in the Streamlit repository.
28
+ # This is a placeholder implementation.
29
+ return "Checked GitHub. No new updates." # Replace with actual implementation.
30
 
31
 
32
  # Define the custom tool for checking Streamlit documentation updates
 
46
  else:
47
  return 'No updates in Streamlit documentation.', current_hash
48
 
49
+ # Define the Streamlit Documentation and GitHub Expert agent
50
  streamlit_expert = Agent(
51
+ role='Streamlit Documentation and GitHub Expert',
52
+ goal='Stay updated with the latest Streamlit documentation and GitHub repository changes',
53
+ backstory='An AI agent specialized in monitoring and reporting the latest changes in Streamlit documentation and repository.',
54
+ tools=[check_streamlit_updates, github_streamlit_expert],
55
  verbose=True
56
  )
57
 
 
73
  chat_history = []
74
 
75
  # Streamlit app setup
76
+ st.title('CrewAI Streamlit Expert - Chat Interface')
 
77
 
78
 
79
  # Chat input
 
97
  st.text(chat)
98
 
99
  # Manual update button
100
+ if st.button('Check for Streamlit Updates Now'):
101
+ result = crew.kickoff() # Trigger the Crew to perform the update task
 
102
  st.write(result)
 
103
  else:
104
  st.write('Click the button above to check for updates.')
105
+