AhsanRazi commited on
Commit
460f2c3
·
verified ·
1 Parent(s): 8958b4b

Update blog_content_generator.py

Browse files
Files changed (1) hide show
  1. blog_content_generator.py +5 -0
blog_content_generator.py CHANGED
@@ -16,6 +16,7 @@ def blog_content_agent(llm, state):
16
  print(topic)
17
 
18
  # tool
 
19
  def tavily_search(query: str) -> str:
20
  """
21
  Performs a search on Tavily using the provided query.
@@ -26,6 +27,7 @@ def blog_content_agent(llm, state):
26
  Returns:
27
  str: The result of the search query.
28
  """
 
29
  current_year = date.today().strftime("%Y")
30
 
31
  tavily = TavilySearchResults(
@@ -33,6 +35,7 @@ def blog_content_agent(llm, state):
33
  search_depth="advanced",
34
  include_answer=True,
35
  include_raw_content=True,
 
36
  )
37
 
38
  text = tavily.invoke({"query": f"Search this in UK: {query} After: {current_year}"})
@@ -41,6 +44,7 @@ def blog_content_agent(llm, state):
41
  return text
42
 
43
  tool = [tavily_search]
 
44
  llm_with_tools = llm.bind_tools(tool)
45
 
46
 
@@ -186,4 +190,5 @@ Output Format:
186
 
187
  message = [HumanMessage(content=f"Search this query: {topic}")]
188
  messages = react_graph.invoke({"messages": message})
 
189
  return {"blog_content": messages['messages'][-1].content}
 
16
  print(topic)
17
 
18
  # tool
19
+
20
  def tavily_search(query: str) -> str:
21
  """
22
  Performs a search on Tavily using the provided query.
 
27
  Returns:
28
  str: The result of the search query.
29
  """
30
+
31
  current_year = date.today().strftime("%Y")
32
 
33
  tavily = TavilySearchResults(
 
35
  search_depth="advanced",
36
  include_answer=True,
37
  include_raw_content=True,
38
+ api_key=tavily_api_key, # type: ignore
39
  )
40
 
41
  text = tavily.invoke({"query": f"Search this in UK: {query} After: {current_year}"})
 
44
  return text
45
 
46
  tool = [tavily_search]
47
+ # llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash-exp", api_key = gemini_api_key)
48
  llm_with_tools = llm.bind_tools(tool)
49
 
50
 
 
190
 
191
  message = [HumanMessage(content=f"Search this query: {topic}")]
192
  messages = react_graph.invoke({"messages": message})
193
+ # print(messages['messages'][-1].content)
194
  return {"blog_content": messages['messages'][-1].content}