Skip to content

Commit 967108d

Browse files
committed
add example on readme
1 parent 2ea54ea commit 967108d

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,38 @@ result = smart_scraper_graph.run()
168168
print(result)
169169
```
170170

171-
### Case 5: Extracting information using Gemini
171+
172+
### Case 5: Extracting information using Azure
173+
```python
174+
from langchain_openai import AzureChatOpenAI
175+
from langchain_openai import AzureOpenAIEmbeddings
176+
177+
lm_model_instance = AzureChatOpenAI(
178+
openai_api_version=os.environ["AZURE_OPENAI_API_VERSION"],
179+
azure_deployment=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"]
180+
)
181+
182+
embedder_model_instance = AzureOpenAIEmbeddings(
183+
azure_deployment=os.environ["AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT_NAME"],
184+
openai_api_version=os.environ["AZURE_OPENAI_API_VERSION"],
185+
)
186+
graph_config = {
187+
"llm": {"model_instance": llm_model_instance},
188+
"embeddings": {"model_instance": embedder_model_instance}
189+
}
190+
191+
smart_scraper_graph = SmartScraperGraph(
192+
prompt="""List me all the events, with the following fields: company_name, event_name, event_start_date, event_start_time,
193+
event_end_date, event_end_time, location, event_mode, event_category,
194+
third_party_redirect, no_of_days,
195+
time_in_hours, hosted_or_attending, refreshments_type,
196+
registration_available, registration_link""",
197+
source="https://www.hmhco.com/event",
198+
config=graph_config
199+
)
200+
```
201+
202+
### Case 6: Extracting information using Gemini
172203
```python
173204
from scrapegraphai.graphs import SmartScraperGraph
174205
GOOGLE_APIKEY = "YOUR_API_KEY"

examples/azure/smart_scraper_azure_openai.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from scrapegraphai.utils import prettify_exec_info
1111

1212

13-
## required environment variable in .env
13+
# required environment variable in .env
1414
# AZURE_OPENAI_ENDPOINT
1515
# AZURE_OPENAI_CHAT_DEPLOYMENT_NAME
1616
# MODEL_NAME
@@ -45,8 +45,11 @@
4545
}
4646

4747
smart_scraper_graph = SmartScraperGraph(
48-
prompt="List me all the events, with the following fields: company_name, event_name, event_start_date, event_start_time, event_end_date, event_end_time, location, event_mode, event_category, third_party_redirect, no_of_days,
49-
time_in_hours, hosted_or_attending, refreshments_type, registration_available, registration_link",
48+
prompt="""List me all the events, with the following fields: company_name, event_name, event_start_date, event_start_time,
49+
event_end_date, event_end_time, location, event_mode, event_category,
50+
third_party_redirect, no_of_days,
51+
time_in_hours, hosted_or_attending, refreshments_type,
52+
registration_available, registration_link""",
5053
# also accepts a string with the already downloaded HTML code
5154
source="https://www.hmhco.com/event",
5255
config=graph_config

0 commit comments

Comments
 (0)