File size: 2,187 Bytes
c74b98b
0a59f74
 
 
 
 
0692fa7
0a59f74
 
 
ce852a8
 
0a59f74
fa457a1
 
0a59f74
0692fa7
78dbb2b
0692fa7
 
 
b096a92
 
 
0692fa7
 
 
 
 
 
b096a92
0692fa7
 
 
 
b096a92
 
 
 
0692fa7
 
b096a92
0692fa7
 
 
bb19c62
0692fa7
 
 
 
1fd8fc3
 
0692fa7
53461bc
1fd8fc3
 
0692fa7
 
 
 
 
 
 
 
 
 
 
 
 
0a59f74
5222849
0a59f74
5222849
57e6576
810697b
 
0692fa7
 
810697b
f849132
0a59f74
 
 
dbd6994
 
4007358
 
 
 
 
 
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import os
import json
import arxiv

# import packages that are used in our tools
import requests
from typing import Tuple
from bs4 import BeautifulSoup
from huggingface_hub import HfApi
from pypdf import PdfReader
# from models import HfApiModel
from smolagents import CodeAgent, tool, GradioUI, HfApiModel

from smolagents.monitoring import LogLevel


@tool
def process_file_transfer_result(job_id: str) -> Tuple:
    """
    This function processes the logs sent by the server.
    Args:
        job_id: The job identifier of the initated file transfer
    Returns:
        True if the transfer suceeded and the corresponding message if an error occured.        
    """

    return True, ''
    

@tool
def request_file_transfer(file_path: str, server: str) -> str:
    """
    This function sends a request for a file transfer initiation.
    Args:
        file_path: The path to the source file.
        server: identifier of the file transfer server
    Returns:
        The job identifier of the initated file transfer
    
    """

    return 'trans001'


@tool
def encrypt_file(file_path: str) -> bool:
    """
    This function encrypts the source file.
    Args:
        file_path: The path to the source file.
    Returns:
        True if encryption went well
    """
    print(f'File {file_path} encrypted')

    return True
    
@tool
def validate_file(file_path: str) -> str:
    """
    This function validates that the source file exists.
    Args:
        file_path: The path to the source file.
    Returns:
        A boolean value indicateing the existance of a file.
    """

    return True

model_id = "Qwen/Qwen2.5-Coder-32B-Instruct"
hf_token = os.environ["HF_TOKEN"]


model = HfApiModel()
agent = CodeAgent(tools=[process_file_transfer_result,
                         validate_file,
                         encrypt_file,
                         request_file_transfer,
                         ],
                  verbosity_level=LogLevel.DEBUG,
                  model=model,
                  add_base_tools=True)

agent.visualize()


#agent.run(
#    "Summarize today's top paper on Hugging Face daily papers by reading it.",
#)

GradioUI(agent).launch()