dianamclean commited on
Commit
227c812
·
verified ·
1 Parent(s): 3b8ff54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -66,7 +66,21 @@ def my_ai_joke (arg1:str, arg2:int)-> str: #it's import to specify the return ty
66
  arg1: The topic of the joke.
67
  arg2: The temperature for joke generation (higher values = more creative, typically 0-10).
68
  """
69
- #model.temperature = arg2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  # joke = joke(arg1, model.temperature) #return a joke about arg1
71
 
72
  return joke
 
66
  arg1: The topic of the joke.
67
  arg2: The temperature for joke generation (higher values = more creative, typically 0-10).
68
  """
69
+ try:
70
+ search_tool = DuckDuckGoSearchTool(arg1)
71
+ results = search_tool.forward(
72
+ f"Get a {joke} "
73
+ )
74
+
75
+ if results:
76
+ top_result = results[0] # Assuming results is a list
77
+ return top_result
78
+ else:
79
+ return "No results found."
80
+ except requests.exceptions.RequestException as e:
81
+ return f"Error: Failed to connect to the search. Details: {str(e)}"
82
+ except Exception as e:
83
+ return f"Error: An unexpected error occurred. Details: {str(e)}"#model.temperature = arg2
84
  # joke = joke(arg1, model.temperature) #return a joke about arg1
85
 
86
  return joke