Jaward commited on
Commit
903627b
·
verified ·
1 Parent(s): 9686ede

fixed serpapi bug

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -111,6 +111,11 @@ def search_web(query: str, serpapi_key: str) -> str:
111
  logger.error("Unexpected error during search: %s", str(e))
112
  return None
113
 
 
 
 
 
 
114
  # Custom renderer for slides - Markdown to HTML
115
  def render_md_to_html(md_content: str) -> str:
116
  try:
@@ -406,6 +411,8 @@ def get_gradio_file_url(local_path):
406
 
407
  # Async generate lecture materials and audio
408
  async def on_generate(api_service, api_key, serpapi_key, title, lecture_content_description, lecture_type, lecture_style, speaker_audio, num_slides):
 
 
409
  model_client = get_model_client(api_service, api_key)
410
 
411
  # Get the speaker from the speaker_audio path
@@ -440,7 +447,7 @@ async def on_generate(api_service, api_key, serpapi_key, title, lecture_content_
440
  model_client=model_client,
441
  handoffs=["slide_agent"],
442
  system_message="You are a Research Agent. Use the search_web tool to gather information on the topic and keywords from the initial message. Summarize the findings concisely in a single message, then use the handoff_to_slide_agent tool to pass the task to the Slide Agent. Do not produce any other output.",
443
- tools=[search_web]
444
  )
445
  slide_agent = AssistantAgent(
446
  name="slide_agent",
 
111
  logger.error("Unexpected error during search: %s", str(e))
112
  return None
113
 
114
+ def create_search_web_with_key(serpapi_key: str):
115
+ def search_web_with_key(query: str) -> str:
116
+ return search_web(query, serpapi_key)
117
+ return search_web_with_key
118
+
119
  # Custom renderer for slides - Markdown to HTML
120
  def render_md_to_html(md_content: str) -> str:
121
  try:
 
411
 
412
  # Async generate lecture materials and audio
413
  async def on_generate(api_service, api_key, serpapi_key, title, lecture_content_description, lecture_type, lecture_style, speaker_audio, num_slides):
414
+ print(f"Received serpapi_key: '{serpapi_key}' (type: {type(serpapi_key)}, length: {len(serpapi_key) if serpapi_key else 0})")
415
+
416
  model_client = get_model_client(api_service, api_key)
417
 
418
  # Get the speaker from the speaker_audio path
 
447
  model_client=model_client,
448
  handoffs=["slide_agent"],
449
  system_message="You are a Research Agent. Use the search_web tool to gather information on the topic and keywords from the initial message. Summarize the findings concisely in a single message, then use the handoff_to_slide_agent tool to pass the task to the Slide Agent. Do not produce any other output.",
450
+ tools=[create_search_web_with_key(serpapi_key)]
451
  )
452
  slide_agent = AssistantAgent(
453
  name="slide_agent",