TranscriptTool / smolagent_example /example_smolagent.py
maguid28's picture
Implemented smolagent tool
13d3de7
from smolagents import CodeAgent, HfApiModel
from transcription_tool import TranscriptTool
from huggingface_hub import login
from config import HUGGINGFACE_API_KEY
login(HUGGINGFACE_API_KEY)
#model = HfApiModel("deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B")
#model = HfApiModel("deepseek-ai/DeepSeek-R1-Zero")
#model = HfApiModel("deepseek-ai/DeepSeek-R1-Distill-Qwen-7B")
#model = HfApiModel("deepseek-ai/deepseek-llm-7b-chat")
model = HfApiModel("HuggingFaceH4/zephyr-7b-alpha")
# Smolagent transcription tool
transcript_tool = TranscriptTool()
agent = CodeAgent(
tools=[transcript_tool],
model=model,
additional_authorized_imports=["string", "subprocess", "librosa", "os", "unicodedata", "datetime", "math", "time", "collections", "random", "itertools"],
)
task = """You are a Python assistant that can use preloaded tools to complete tasks.
A tool named `TranscriptTool` is available for transcription tasks.
To transcribe an audio file:
- Call `TranscriptTool.
- Do not attempt to import or initialize any other class or module for transcription.
do not add any imports
the video file is example_video.mp4
the audio file is example_audio.opus
compare the transcript strings tell me if they are the same
last line of code: final_answer(f"Are transcriptions the same? {video_transcription==audio_transcription}! Video transcription: {video_transcription}, Audio transcription: {audio_transcription}")
"""
result = agent.run(task)
print("Agent Result:", result)