lethaq commited on
Commit
42550f4
·
verified ·
1 Parent(s): e305cd8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -14
app.py CHANGED
@@ -35,20 +35,32 @@ def get_current_time_in_timezone(timezone: str) -> str:
35
 
36
 
37
  @tool
38
- def get_something_to_read(user_tip:str) -> str:
39
- fiction_books = ["To Kill a Mockingbird", "1984", "Pride and Prejudice"]
40
- history_books = ["Sapiens: A Brief History of Humankind", "The Guns of August", "Guns, Germs, and Steel"]
41
- romance_books = ["Jane Eyre", "Wuthering Heights", "Outlander"]
42
-
43
- if "fiction" in user_tip.lower():
44
- return random.choice(fiction_books)
45
- elif "history" in user_tip.lower():
46
- return random.choice(history_books)
47
- elif "romance" in user_tip.lower():
48
- return random.choice(romance_books)
49
- else:
50
- all_books: List[str] = fiction_books + history_books + romance_books
51
- return random.choice(all_books)
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
 
54
 
 
35
 
36
 
37
  @tool
38
+ import random
39
+ from typing import List
40
+
41
+
42
+ @tool
43
+ def get_something_to_read(user_tip: str) -> str:
44
+ """
45
+ 该工具根据用户提示随机推荐书籍。
46
+ Args:
47
+ user_tip: 一个字符串,代表用户提供的书籍推荐偏好或关键词,例如'fiction'(小说)、'history'(历史)、'romance'(浪漫)等。
48
+ Returns:
49
+ 一个字符串,代表随机推荐的书籍名称。
50
+ """
51
+ fiction_books = ["To Kill a Mockingbird", "1984", "Pride and Prejudice"]
52
+ history_books = ["Sapiens: A Brief History of Humankind", "The Guns of August", "Guns, Germs, and Steel"]
53
+ romance_books = ["Jane Eyre", "Wuthering Heights", "Outlander"]
54
+
55
+ if "fiction" in user_tip.lower():
56
+ return random.choice(fiction_books)
57
+ elif "history" in user_tip.lower():
58
+ return random.choice(history_books)
59
+ elif "romance" in user_tip.lower():
60
+ return random.choice(romance_books)
61
+ else:
62
+ all_books: List[str] = fiction_books + history_books + romance_books
63
+ return random.choice(all_books)
64
 
65
 
66