juanmaguitar commited on
Commit
cd969b0
·
1 Parent(s): 79a8ee7

Added environment variables confir for WP interaction

Browse files
Files changed (2) hide show
  1. README.md +25 -5
  2. app.py +15 -0
README.md CHANGED
@@ -8,11 +8,31 @@ sdk_version: 5.15.0
8
  app_file: app.py
9
  pinned: false
10
  tags:
11
- - smolagents
12
- - agent
13
- - smolagent
14
- - tool
15
- - agent-course
16
  ---
17
 
18
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  app_file: app.py
9
  pinned: false
10
  tags:
11
+ - smolagents
12
+ - agent
13
+ - smolagent
14
+ - tool
15
+ - agent-course
16
  ---
17
 
18
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
19
+
20
+ ## Environment Variables
21
+
22
+ The application requires the following environment variables to be set in a `.env` file:
23
+
24
+ ### WordPress Credentials
25
+
26
+ ```
27
+ WORDPRESS_SITE_URL=https://your-wordpress-site.com
28
+ WORDPRESS_USERNAME=your-username
29
+ WORDPRESS_APP_PASSWORD=your-app-password
30
+ ```
31
+
32
+ ### Weather API
33
+
34
+ ```
35
+ OPENWEATHER_API_KEY=your-api-key
36
+ ```
37
+
38
+ Make sure to create a `.env` file in the root directory and add these variables with your actual credentials before running the application.
app.py CHANGED
@@ -21,6 +21,17 @@ load_dotenv()
21
  if not os.getenv("OPENWEATHER_API_KEY"):
22
  print("Warning: OPENWEATHER_API_KEY not set. Weather functionality will be limited.")
23
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  @tool
26
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -141,6 +152,10 @@ wordpress_auth = WordPressAuthTool()
141
  wordpress_post = WordPressPostTool(auth_tool=wordpress_auth)
142
  blog_generator = BlogGeneratorTool(model=model)
143
 
 
 
 
 
144
  agent = CodeAgent(
145
  model=model,
146
  tools=[
 
21
  if not os.getenv("OPENWEATHER_API_KEY"):
22
  print("Warning: OPENWEATHER_API_KEY not set. Weather functionality will be limited.")
23
 
24
+ # Load WordPress credentials from environment variables
25
+ wordpress_credentials = {
26
+ 'site_url': os.getenv('WORDPRESS_SITE_URL'),
27
+ 'username': os.getenv('WORDPRESS_USERNAME'),
28
+ 'app_password': os.getenv('WORDPRESS_APP_PASSWORD')
29
+ }
30
+
31
+ # Verify WordPress credentials
32
+ if not all(wordpress_credentials.values()):
33
+ print("Warning: WordPress credentials not fully set. Blog functionality will be limited.")
34
+
35
 
36
  @tool
37
  def get_current_time_in_timezone(timezone: str) -> str:
 
152
  wordpress_post = WordPressPostTool(auth_tool=wordpress_auth)
153
  blog_generator = BlogGeneratorTool(model=model)
154
 
155
+ # Set WordPress credentials
156
+ wordpress_auth.forward(action="set_credentials",
157
+ credentials=wordpress_credentials)
158
+
159
  agent = CodeAgent(
160
  model=model,
161
  tools=[