FrancescaScipioni commited on
Commit
93e8ab1
·
verified ·
1 Parent(s): 75b0936

fixed error in generating company description

Browse files
Files changed (1) hide show
  1. app.py +18 -6
app.py CHANGED
@@ -9,6 +9,9 @@ from io import BytesIO
9
 
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.
@@ -39,18 +42,27 @@ def company_logos(company_name: str) -> Image.Image:
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
 
 
9
 
10
  from Gradio_UI import GradioUI
11
 
12
+ # Load the text generation pipeline for LLM
13
+ llm = pipeline("text-generation", model="Qwen/Qwen2.5-Coder-32B-Instruct")
14
+
15
  @tool
16
  def company_logos(company_name: str) -> Image.Image:
17
  """A tool that retrieves the logo of a given company using the Clearbit Logo API.
 
42
 
43
  @tool
44
  def company_description(company_name: str) -> str:
45
+ """Generates a short company description using an LLM.
46
+
47
  Args:
48
  company_name: The name of the company.
49
 
50
  Returns:
51
+ A short description of the company.
52
  """
53
 
54
+ prompt = (
55
+ f"Provide a short summary about {company_name}. Include:\n"
56
+ "- One sentence describing the company's main product or service.\n"
57
+ "- Two sentences summarizing the company's history.\n"
58
+ "- One sentence about the latest news related to the company."
59
+ )
60
+
61
+ try:
62
+ response = llm(prompt, max_length=150, do_sample=True)
63
+ return response[0]["generated_text"]
64
+ except Exception as e:
65
+ return f"Error generating description for {company_name}: {str(e)}"
66
 
67
  final_answer = FinalAnswerTool()
68