mohan260851 commited on
Commit
d7c7805
·
verified ·
1 Parent(s): 8fe31af

Delete tools/social_media_search.py

Browse files
Files changed (1) hide show
  1. tools/social_media_search.py +0 -37
tools/social_media_search.py DELETED
@@ -1,37 +0,0 @@
1
- from duckduckgo_search import DDGS
2
- from smolagents.tools import Tool
3
- from typing import List, Dict
4
- import re
5
-
6
-
7
- class SocialMediaSearchTool(Tool):
8
- name = "social_media_search"
9
- description = "Performs a duckduckgo web search based on your query (think a Google search) then returns the top search results."
10
- inputs = {'query': {'type': 'string', 'description': 'The url of the social account webpage to visit.'}}
11
- output_type = "string"
12
- def __init__(self, **kwargs):
13
- super().__init__()
14
- self.ddgs = DDGS(**kwargs)
15
- self.platforms = {
16
- "LinkedIn": r"linkedin\.com/in/",
17
- "GitHub": r"github\.com/",
18
- "Twitter": r"twitter\.com/",
19
- "HuggingFace": r"huggingface\.co/",
20
- "Facebook": r"facebook\.com/",
21
- "Instagram": r"instagram\.com/"
22
- }
23
-
24
- def forward(self, name: str, platform: str) -> Dict:
25
- query = f"{name} {platform}"
26
- results = self.ddgs.text(query, max_results=5)
27
- postprocessed_results = []
28
- for result in results:
29
- if re.search(self.platforms[platform], result["href"]):
30
- postprocessed_results += [f"(platform: {platform})\n[{result['title']}]({result['href']})\n{result['body']}" for result in results]
31
- return {
32
- "platform": platform,
33
- "url": result["href"],
34
- "title": result["title"],
35
- "description": result["body"]
36
- }
37
- return "platform "+platform+" error:"+" No profile found"