SuccessfulCrab commited on
Commit
9f26975
·
verified ·
1 Parent(s): 5e56f62

Update firecrawler.py

Browse files
Files changed (1) hide show
  1. firecrawler.py +23 -23
firecrawler.py CHANGED
@@ -25,31 +25,31 @@ class FireCrawlTool(Tool):
25
 
26
  def forward(self, websites_string: str):
27
 
28
- # Initialize the FirecrawlApp with the API key
29
- app = FirecrawlApp(api_key = api_key)
30
 
31
- # Convert the websites string to a list
32
- # Split by commas, newlines, or spaces and strip whitespace
33
- websites_list = [
34
- website.strip()
35
- for website in websites_string.replace(',', ' ').replace('\n', ' ').split()
36
- if website.strip()
37
- ]
38
 
39
- # Define the extraction schema
40
- class ExtractSchema(BaseModel):
41
- company_name: str
42
- website_purpose: str
43
 
44
- prompt_string = 'Extract the website purpose and company name.'
45
 
46
- # Execute the API call
47
- data = app.extract(
48
- websites_list,
49
- {
50
- 'prompt': prompt_string,
51
- 'schema': ExtractSchema.model_json_schema(),
52
- }
53
- )
54
 
55
- return data
 
25
 
26
  def forward(self, websites_string: str):
27
 
28
+ # Initialize the FirecrawlApp with the API key
29
+ app = FirecrawlApp(api_key = api_key)
30
 
31
+ # Convert the websites string to a list
32
+ # Split by commas, newlines, or spaces and strip whitespace
33
+ websites_list = [
34
+ website.strip()
35
+ for website in websites_string.replace(',', ' ').replace('\n', ' ').split()
36
+ if website.strip()
37
+ ]
38
 
39
+ # Define the extraction schema
40
+ class ExtractSchema(BaseModel):
41
+ company_name: str
42
+ website_purpose: str
43
 
44
+ prompt_string = 'Extract the website purpose and company name.'
45
 
46
+ # Execute the API call
47
+ data = app.extract(
48
+ websites_list,
49
+ {
50
+ 'prompt': prompt_string,
51
+ 'schema': ExtractSchema.model_json_schema(),
52
+ }
53
+ )
54
 
55
+ return data