Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -65,21 +65,22 @@ def asoiaf_book(query: str) -> str:
|
|
| 65 |
@tool
|
| 66 |
def asoiaf_character(query: str) -> str:
|
| 67 |
"""Resolve questions about characters. Returns JSON with: {name, aliases, titles, actor, house, error}
|
| 68 |
-
|
| 69 |
-
Args:
|
| 70 |
-
query
|
| 71 |
-
"""
|
| 72 |
try:
|
| 73 |
clean_query = normalize_input(query)
|
| 74 |
name_keywords = ["who is", "plays", "actor for", "information about"]
|
| 75 |
-
name = next((clean_query.split(kw)[-1].strip() for kw in name_keywords
|
| 76 |
-
|
| 77 |
-
|
| 78 |
response = requests.get(
|
| 79 |
"https://anapioficeandfire.com/api/characters",
|
| 80 |
params={"name": name},
|
| 81 |
timeout=5
|
| 82 |
)
|
|
|
|
| 83 |
|
| 84 |
if response.status_code == 200:
|
| 85 |
chars = response.json()
|
|
@@ -108,12 +109,12 @@ def asoiaf_character(query: str) -> str:
|
|
| 108 |
return json.dumps({"error": f"Search failed: {str(e)}"})
|
| 109 |
|
| 110 |
|
| 111 |
-
@tool
|
| 112 |
def asoiaf_house(query: str) -> str:
|
| 113 |
"""Resolve house-related queries. Returns JSON with {name, region, words, members}
|
| 114 |
-
|
| 115 |
Args:
|
| 116 |
-
query
|
| 117 |
"""
|
| 118 |
try:
|
| 119 |
response = requests.get(
|
|
|
|
| 65 |
@tool
|
| 66 |
def asoiaf_character(query: str) -> str:
|
| 67 |
"""Resolve questions about characters. Returns JSON with: {name, aliases, titles, actor, house, error}
|
| 68 |
+
|
| 69 |
+
Args: # <--- Important: Args section needs to be present
|
| 70 |
+
query: The character name or description (e.g., 'Mother of Dragons'). <-- Corrected!
|
| 71 |
+
"""
|
| 72 |
try:
|
| 73 |
clean_query = normalize_input(query)
|
| 74 |
name_keywords = ["who is", "plays", "actor for", "information about"]
|
| 75 |
+
name = next((clean_query.split(kw)[-1].strip() for kw in name_keywords
|
| 76 |
+
if kw in clean_query), clean_query)
|
| 77 |
+
|
| 78 |
response = requests.get(
|
| 79 |
"https://anapioficeandfire.com/api/characters",
|
| 80 |
params={"name": name},
|
| 81 |
timeout=5
|
| 82 |
)
|
| 83 |
+
|
| 84 |
|
| 85 |
if response.status_code == 200:
|
| 86 |
chars = response.json()
|
|
|
|
| 109 |
return json.dumps({"error": f"Search failed: {str(e)}"})
|
| 110 |
|
| 111 |
|
| 112 |
+
@tool
|
| 113 |
def asoiaf_house(query: str) -> str:
|
| 114 |
"""Resolve house-related queries. Returns JSON with {name, region, words, members}
|
| 115 |
+
|
| 116 |
Args:
|
| 117 |
+
query: The region or house name (e.g., 'The North', 'Stark').
|
| 118 |
"""
|
| 119 |
try:
|
| 120 |
response = requests.get(
|