File size: 3,234 Bytes
b93edd8
328a89d
a3c94e6
f80715b
b93edd8
 
328a89d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40fd95f
a3c94e6
 
 
 
 
f80715b
 
 
 
 
 
 
23a3758
40fd95f
 
5c817d1
 
40fd95f
 
5c817d1
 
40fd95f
5c817d1
 
 
 
 
 
40fd95f
 
5c817d1
 
40fd95f
 
5c817d1
 
40fd95f
 
 
 
328a89d
 
40fd95f
 
a3c94e6
40fd95f
 
 
 
a3c94e6
40fd95f
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import gradio as gr
from utils.bgg import get_game_details, get_hot_games, get_similar_games_v2, search
from utils.wikipedia_tools import search_wiki, summary_wiki, page_wiki, random_wiki
from utils.imdb_tools import search_imdb


search_bgg = gr.Interface(
    fn=search,
    inputs=["text"],
    outputs="json",
    title="Board game geek search",
    description="Search for the board games from Board Game Geek"
)

game_details = gr.Interface(
    fn=get_game_details,
    inputs=["text"],
    outputs="json",
    title="Game Details",
    description="Get detailed information for board games (comma-separated IDs)"
)

hot_games = gr.Interface(
    fn=get_hot_games,
    inputs=[],
    outputs="json",
    title="Hot Games",
    description="Get the list of the top 50 trending games today on Board Game Geek"
)

recommend_games = gr.Interface(
    fn=get_similar_games_v2,
    inputs=["text"],
    outputs="json",
    title="Recommend Games",
    description="Get a list of similar games based on a given game ID"
)

# ----- Wikipedia Interfaces -----
wiki_search = gr.Interface(fn=search_wiki, inputs=["text", "text"], outputs="json", title="Wikipedia Search", description="Search Wikipedia and return summaries")
wiki_summary = gr.Interface(fn=summary_wiki, inputs=["text", "text"], outputs="text", title="Summary", description="Get a summary of a Wikipedia topic")
wiki_page = gr.Interface(fn=page_wiki, inputs=["text", "text"], outputs="text", title="Full Page", description="Get full content of a topic")
wiki_random = gr.Interface(fn=random_wiki, inputs=["text"], outputs="text", title="Random Page", description="Get a random Wikipedia article")

imdb_interface = gr.Interface(
    fn=search_imdb,
    inputs="text",
    outputs="json",
    title="IMDb Movie Search",
    description="Search IMDb for movie details."
)

# ----- Twitch Chat Interface -----
def get_twitch_chat(channel_name):
    if not channel_name:
        return "Please enter a channel name."
    # Using parent=localhost for local development. 
    # In production, this needs to match the domain where the app is hosted.
    html_content = f"""
    <iframe id="twitch-chat-embed"
        src="https://www.twitch.tv/embed/{channel_name}/chat?parent=localhost"
        height="500"
        width="100%">
    </iframe>
    """
    return html_content

twitch_interface = gr.Interface(
    fn=get_twitch_chat,
    inputs=gr.Textbox(label="Channel Name", placeholder="e.g., riotgames"),
    outputs=gr.HTML(label="Twitch Chat"),
    title="Twitch Chat",
    description="View Twitch chat for a specific channel."
)

# ----- Combine All Tabs -----
combined_tools = gr.TabbedInterface(
    [search_bgg, game_details, hot_games, recommend_games, wiki_search, wiki_summary, wiki_page, wiki_random, imdb_interface, twitch_interface],
    ["Search BGG", "Details", "Hot Games", "Recommend", "Wiki Search", "Wiki Summary", "Wiki Page", "Wiki Random", "IMDb Search", "Twitch Chat"]
)

# ----- Launch MCP-enabled Gradio Server -----
combined_tools.launch(mcp_server=True)

#bgg_tools = gr.TabbedInterface(
    #[search_bgg, game_details, hot_games, recommend_games],
    #["Search", "Details", "Hot Games", "Recommend Games"]
#)

#bgg_tools.launch(mcp_server=True)