Youssef-El-SaYed commited on
Commit
e72b75e
·
verified ·
1 Parent(s): cd44f7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -61,15 +61,19 @@ def search_wikipedia(search_term: str, results: int = 5) -> str:
61
  @tool
62
  def view_wikipedia(article_name: str) -> str:
63
  """
64
- Retrieve full text for a given Wikipedia article.
65
- """
66
- import wikipedia
67
- wikipedia_page = wikipedia.page(article_name)
68
- article_title = wikipedia_page.title
69
- article_text = wikipedia_page.content
70
- return f"### Title: {article_title} ### Text: {article_text}"
71
 
 
 
72
 
 
 
 
 
 
 
 
 
73
  # --- Initialize tools ---
74
  youtube_transcript_extractor = load_tool("Mightypeacock/tool-YoutubeTranscript", trust_remote_code=True)
75
  visit_webpage = VisitWebpageTool()
 
61
  @tool
62
  def view_wikipedia(article_name: str) -> str:
63
  """
64
+ View the content of a specific Wikipedia article.
 
 
 
 
 
 
65
 
66
+ Args:
67
+ article_name (str): The exact title of the Wikipedia article to view.
68
 
69
+ Returns:
70
+ str: The first 2000 characters of the article's content.
71
+ """
72
+ try:
73
+ page = wikipedia.page(article_name)
74
+ return page.content[:2000]
75
+ except Exception as e:
76
+ return f"Error fetching article '{article_name}': {e}"
77
  # --- Initialize tools ---
78
  youtube_transcript_extractor = load_tool("Mightypeacock/tool-YoutubeTranscript", trust_remote_code=True)
79
  visit_webpage = VisitWebpageTool()