WanIrfan commited on
Commit
d375ef2
·
verified ·
1 Parent(s): 932a4c8

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +117 -0
  2. requirements.txt +4 -0
  3. witcher_swarm.py +95 -0
app.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from witcher_swarm import run_swarm
3
+
4
+ # Custom CSS for Skellige Ice Theme
5
+ SKELLIGE_CSS = """
6
+ body {
7
+ background: linear-gradient(to bottom, #0d1b2a, #1b263b, #415a77);
8
+ color: white !important;
9
+ }
10
+
11
+ .gradio-container {
12
+ background: transparent !important;
13
+ }
14
+
15
+ /* Title */
16
+ h1 {
17
+ text-align: center;
18
+ font-family: 'Cinzel', serif;
19
+ color: #cfe3ff;
20
+ font-size: 3em;
21
+ letter-spacing: 2px;
22
+ margin-bottom: 5px;
23
+ text-shadow: 0 0 10px #6ba6ff;
24
+ }
25
+
26
+ /* Description */
27
+ p {
28
+ text-align: center;
29
+ color: #d7e9ff;
30
+ font-size: 1.2em;
31
+ }
32
+
33
+ /* Chatbox */
34
+ .gr-chatbot {
35
+ background: rgba(255, 255, 255, 0.05) !important;
36
+ border: 1px solid rgba(255, 255, 255, 0.15) !important;
37
+ backdrop-filter: blur(6px);
38
+ border-radius: 12px !important;
39
+ }
40
+
41
+ /* User message */
42
+ .message.user {
43
+ background: rgba(120, 180, 255, 0.2) !important;
44
+ border: 1px solid rgba(120, 180, 255, 0.3) !important;
45
+ color: #e6f1ff !important;
46
+ }
47
+
48
+ /* Bot message */
49
+ .message.bot {
50
+ background: rgba(255, 255, 255, 0.07) !important;
51
+ border: 1px solid rgba(255, 255, 255, 0.15) !important;
52
+ color: #f2f7ff !important;
53
+ }
54
+
55
+ /* Input box */
56
+ textarea {
57
+ background: rgba(255, 255, 255, 0.08) !important;
58
+ border: 1px solid rgba(255, 255, 255, 0.18) !important;
59
+ color: white !important;
60
+ }
61
+
62
+ /* Button style */
63
+ button {
64
+ background: #1e3d5a !important;
65
+ color: #d8e6f8 !important;
66
+ border-radius: 10px !important;
67
+ border: 1px solid #345b80 !important;
68
+ }
69
+
70
+ button:hover {
71
+ background: #274b6f !important;
72
+ }
73
+
74
+ /* Scrollbar */
75
+ ::-webkit-scrollbar {
76
+ width: 10px;
77
+ }
78
+ ::-webkit-scrollbar-track {
79
+ background: rgba(255, 255, 255, 0.05);
80
+ }
81
+ ::-webkit-scrollbar-thumb {
82
+ background: #5c8dbc;
83
+ border-radius: 5px;
84
+ }
85
+ """
86
+
87
+ # Response function using multi-agent Swarm
88
+ def respond(message, history):
89
+ response = run_swarm(message)
90
+ history = history + [(message, response)]
91
+ return history, ""
92
+
93
+
94
+ # -------------------------
95
+ # GRADIO UI
96
+ # -------------------------
97
+ with gr.Blocks(css=SKELLIGE_CSS, theme="soft") as demo:
98
+ gr.Markdown("# ❄️ Skellige Oracle — Multi-Agent Witcher 3 Expert")
99
+ gr.Markdown("Ask anything about quests, story, builds, bosses, loot, Gwent, endings, or DLC — handled by **3 specialized agents**.")
100
+
101
+ chatbot = gr.Chatbot(
102
+ label="Witcher 3 Knowledge Chat",
103
+ bubble_full_width=False,
104
+ height=500
105
+ )
106
+
107
+ user_input = gr.Textbox(
108
+ label="Your Question",
109
+ placeholder="Ask about quests, builds, enemies, loot... e.g. 'Best armor early game?'"
110
+ )
111
+
112
+ submit = gr.Button("⚔️ Ask the Oracle")
113
+
114
+ submit.click(respond, [user_input, chatbot], [chatbot, user_input])
115
+ user_input.submit(respond, [user_input, chatbot], [chatbot, user_input])
116
+
117
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ swarms
3
+ python-dotenv
4
+ google-generativeai
witcher_swarm.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from swarms import Agent, SwarmRouter
2
+ import os
3
+ from dotenv import load_dotenv
4
+
5
+ load_dotenv()
6
+ gemini_api_key = os.getenv("GEMINI_API_KEY")
7
+ os.environ["GEMINI_API_KEY"] = gemini_api_key
8
+
9
+ model = "gemini/gemini-2.5-flash"
10
+
11
+ # -------------------------
12
+ # AGENT DEFINITIONS
13
+ # -------------------------
14
+
15
+ lore_agent = Agent(
16
+ agent_name="Witcher Lore Master",
17
+ agent_description="Expert in story, quests, endings, characters, world lore.",
18
+ system_prompt="""
19
+ You are a lore expert on The Witcher 3.
20
+ Specialize in:
21
+ - story, quests, choices, endings
22
+ - lore connections (books → game)
23
+ - characters, motivations, worldbuilding
24
+ Provide detailed but friendly explanations.
25
+ """,
26
+ model_name=model,
27
+ dynamic_temperature_enabled=True,
28
+ )
29
+
30
+ combat_agent = Agent(
31
+ agent_name="Combat & Build Specialist",
32
+ agent_description="Expert in combat, builds, boss strategies.",
33
+ system_prompt="""
34
+ You are a master Witcher combat instructor.
35
+ Specialize in:
36
+ - best builds for any level
37
+ - weapons, armor sets, signs, alchemy
38
+ - boss fights and monster weaknesses
39
+ Keep answers practical and step-by-step.
40
+ """,
41
+ model_name=model,
42
+ dynamic_temperature_enabled=True,
43
+ )
44
+
45
+ loot_agent = Agent(
46
+ agent_name="Exploration & Loot Expert",
47
+ agent_description="Expert in loot, crafting, secrets, hidden locations.",
48
+ system_prompt="""
49
+ You are a Witcher treasure hunter.
50
+ Specialize in:
51
+ - best early/mid/late game loot
52
+ - rare diagrams and their locations
53
+ - Skellige, Novigrad, Toussaint exploration tips
54
+ """,
55
+ model_name=model,
56
+ dynamic_temperature_enabled=True,
57
+ )
58
+
59
+ # -------------------------
60
+ # ROUTER AGENT
61
+ # -------------------------
62
+
63
+ router = SwarmRouter(
64
+ agents=[lore_agent, combat_agent, loot_agent],
65
+ model_name=model,
66
+ system_prompt="""
67
+ You are the router.
68
+ Decide which agent is best for answering the user's query.
69
+
70
+ Rules:
71
+ - If question is about quests, story, characters → send to Lore Master.
72
+ - If question is about combat, builds, damage, signs → send to Combat Specialist.
73
+ - If question is about loot, exploration, locations → send to Loot Expert.
74
+ - Default: Lore Master.
75
+ Return only the AGENT NAME as the routing output.
76
+ """
77
+ )
78
+
79
+ # -------------------------
80
+ # ENTRY FUNCTION
81
+ # -------------------------
82
+
83
+ def run_swarm(user_message: str):
84
+ """
85
+ Router picks the best agent,
86
+ then we forward the message to that agent.
87
+ """
88
+ chosen_agent_name = router.route(user_message)
89
+
90
+ if "Combat" in chosen_agent_name:
91
+ return combat_agent.run(user_message)
92
+ elif "Loot" in chosen_agent_name:
93
+ return loot_agent.run(user_message)
94
+ else:
95
+ return lore_agent.run(user_message)