Felix-Thin's picture
Update app.py
925b557 verified
import yaml
import os
from smolagents import GradioUI, CodeAgent, HfApiModel
# Get current directory path
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
from tools.fetch_lastest_news_tille_and_urls import SimpleTool as FetchLastestNewsTilleAndUrls
from tools.extract_news_article_content import SimpleTool as ExtractNewsArticleContent
from tools.summarize_news import SimpleTool as SummarizeNews
from tools.classify_topic import SimpleTool as ClassifyTopic
from tools.final_answer import FinalAnswerTool as FinalAnswer
model = HfApiModel(
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
)
fetch_lastest_news_tille_and_urls = FetchLastestNewsTilleAndUrls()
extract_news_article_content = ExtractNewsArticleContent()
summarize_news = SummarizeNews()
classify_topic = ClassifyTopic()
final_answer = FinalAnswer()
with open(os.path.join(CURRENT_DIR, "prompts.yaml"), 'r') as stream:
prompt_templates = yaml.safe_load(stream)
agent_VNExpress_Agents = CodeAgent(
model=model,
tools=[fetch_lastest_news_tille_and_urls, extract_news_article_content, summarize_news, classify_topic],
managed_agents=[],
max_steps=20,
verbosity_level=2,
grammar=None,
planning_interval=None,
name='VNExpress_Agents',
description=None,
executor_type='local',
executor_kwargs={},
max_print_outputs_length=None,
prompt_templates=prompt_templates
)
if __name__ == "__main__":
GradioUI(agent_VNExpress_Agents).launch()