Spaces:
Runtime error
Runtime error
File size: 1,329 Bytes
4ff5af2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
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.hf_blog_post_id_list import SimpleTool as HfBlogPostIdList
from tools.get_blog_post import SimpleTool as GetBlogPost
from tools.summarize_blog_post import SimpleTool as SummarizeBlogPost
from tools.format_blog_post import SimpleTool as FormatBlogPost
from tools.final_answer import FinalAnswerTool as FinalAnswer
model = HfApiModel(
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
)
hf_blog_post_id_list = HfBlogPostIdList()
get_blog_post = GetBlogPost()
summarize_blog_post = SummarizeBlogPost()
format_blog_post = FormatBlogPost()
final_answer = FinalAnswer()
with open(os.path.join(CURRENT_DIR, "prompts.yaml"), 'r') as stream:
prompt_templates = yaml.safe_load(stream)
agent = CodeAgent(
model=model,
tools=[hf_blog_post_id_list, get_blog_post, summarize_blog_post, format_blog_post],
managed_agents=[],
class='CodeAgent',
max_steps=10,
verbosity_level=2,
grammar=None,
planning_interval=5,
name=None,
description=None,
executor_type='local',
executor_kwargs={},
max_print_outputs_length=None,
prompt_templates=prompt_templates
)
if __name__ == "__main__":
GradioUI(agent).launch()
|