-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebscraping.py
31 lines (25 loc) · 1.04 KB
/
webscraping.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import autogen
# Configuration from JSON or environment variables
config_list = autogen.config_list_from_json("OAI_CONFIG_LIST")
llm_config = {"config_list": config_list}
# Define the AssistantAgent for generating Python scripts
assistant = autogen.AssistantAgent(name="assistant", llm_config=llm_config)
# Define the UserProxyAgent to execute scripts
user_proxy = autogen.UserProxyAgent(
name="user_proxy",
human_input_mode="TERMINATE", # The user proxy will not wait for human input
code_execution_config={
"work_dir": "web_scraping",
"use_docker": False # Use Docker for secure execution
},
llm_config=llm_config
)
# Example task to scrape data
task_message = "Scrape the latest financial news articles from a given URL."
# Start the process by initiating a chat with the assistant
user_proxy.initiate_chat(
assistant,
message=task_message
)
# Assistant needs to be set up to handle creating the Python script for web scraping
# Assuming assistant is programmed to generate the scraping script in response to tasks