FrancescaScipioni commited on
Commit
75b0936
·
verified ·
1 Parent(s): 00c6dfa

added company_description

Browse files

Here’s the updated company_description function using an LLM to generate a short company description. This method is preferred over Wikipedia API because companies may have variations in their names (e.g., “Inc.”, “Corp.”, “Platforms”), making direct Wikipedia lookups unreliable.

Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -10,12 +10,11 @@ from io import BytesIO
10
  from Gradio_UI import GradioUI
11
 
12
  @tool
13
- def company_logos(company_name: str, _: int) -> str:
14
  """A tool that retrieves the logo of a given company using the Clearbit Logo API.
15
 
16
  Args:
17
  company_name: The name of the company.
18
- _: A placeholder argument (not used).
19
 
20
  Returns:
21
  The URL of the company's logo or an error message if retrieval fails.
@@ -38,7 +37,21 @@ def company_logos(company_name: str, _: int) -> str:
38
  except Exception as e:
39
  return f"Error fetching logo for {company_name}: {str(e)}"
40
 
 
 
 
 
 
 
41
 
 
 
 
 
 
 
 
 
42
  final_answer = FinalAnswerTool()
43
 
44
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
@@ -60,7 +73,7 @@ with open("prompts.yaml", 'r') as stream:
60
 
61
  agent = CodeAgent(
62
  model=model,
63
- tools=[final_answer, company_logos], ## add your tools here (don't remove final answer)
64
  max_steps=6,
65
  verbosity_level=1,
66
  grammar=None,
 
10
  from Gradio_UI import GradioUI
11
 
12
  @tool
13
+ def company_logos(company_name: str) -> Image.Image:
14
  """A tool that retrieves the logo of a given company using the Clearbit Logo API.
15
 
16
  Args:
17
  company_name: The name of the company.
 
18
 
19
  Returns:
20
  The URL of the company's logo or an error message if retrieval fails.
 
37
  except Exception as e:
38
  return f"Error fetching logo for {company_name}: {str(e)}"
39
 
40
+ @tool
41
+ def company_description(company_name: str) -> str:
42
+ """A tool that generates a short company description using an LLM..
43
+
44
+ Args:
45
+ company_name: The name of the company.
46
 
47
+ Returns:
48
+ A short description of the company
49
+ """
50
+
51
+ prompt = f"Write a short summary about the company {company_name}, inclding: one sentence for the company main product or service; two sentences for the company history; one sencence for the latests news about the company "
52
+ response = summarizer(prompt, max_length=150, do_sample=True)
53
+ return response[0]["generated_text"]
54
+
55
  final_answer = FinalAnswerTool()
56
 
57
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
 
73
 
74
  agent = CodeAgent(
75
  model=model,
76
+ tools=[final_answer, company_logos, company_description], ## add your tools here (don't remove final answer)
77
  max_steps=6,
78
  verbosity_level=1,
79
  grammar=None,