首页 > 其他分享 >LlamaFS自组织文件管理器

LlamaFS自组织文件管理器

时间:2024-05-29 22:35:14浏览次数:18  
标签:文件 管理器 src LlamaFS dst LLM path

LlamaFS是一个自组织文件管理器。它可以基于文件内容和修改时间等属性自动重命名和组织您的文件。它能让你不把时间花在对文件的复制、粘贴、重命名、拷贝、排序等简单操作上。有幸在Github上看到LlamaFS这个repo,感慨万千。

技术简介

LlamaFS以批处理模式和监视模式两种模式运行。在批处理模式下,您可以向LlamaFS发送目录,它将返回建议的文件结构并组织您的文件。在监视模式下,LlamaFS启动一个监视目录的守护进程。它拦截所有文件系统操作,使用您最近的修改记录来重命名文件。

从源码上看,LlamaFS像一个Agent,通过prompt使LLM输出指定格式的json,再根据LLM生成的json进行文件处理操作。给的prompt像这样:

You will be provided with list of source files and a summary of their contents. For each file, propose a new path and filename, using a directory structure that optimally organizes the files using known conventions and best practices.

If the file is already named well or matches a known convention, set the destination path to the same as the source path.

Your response must be a JSON object with the following schema:
```json
{
    "files": [
        {
            "src_path": "original file path",
            "dst_path": "new file path under proposed directory structure with proposed file name"
        }
    ]
}

比如移动文件的功能,是这样实现的,下面函数的request参数就是模型返回的json:

@app.post("/commit")
async def commit(request: CommitRequest):
    src = os.path.join(request.base_path, request.src_path)
    dst = os.path.join(request.base_path, request.dst_path)

    if not os.path.exists(src):
        raise HTTPException(
            status_code=400, detail="Source path does not exist in filesystem"
        )

    # Ensure the destination directory exists
    dst_directory = os.path.dirname(dst)
    os.makedirs(dst_directory, exist_ok=True)

    try:
        # If src is a file and dst is a directory, move the file into dst with the original filename.
        if os.path.isfile(src) and os.path.isdir(dst):
            shutil.move(src, os.path.join(dst, os.path.basename(src)))
        else:
            shutil.move(src, dst)
    except Exception as e:
        raise HTTPException(
            status_code=500,
            detail=f"An error occurred while moving the resource: {e}"
        )

    return {"message": "Commit successful"}

感觉LlamaFS像一个“中间件”,只负责发HTTP Request给LLM server获取Respose并采取对应的行动

标签:文件,管理器,src,LlamaFS,dst,LLM,path
From: https://www.cnblogs.com/xiangcaoacao/p/18199698

相关文章

  • linux 查看csv文件,按指定列聚合 排序
    在Linux中,你可以使用awk工具来查看CSV文件的内容,并按照指定的列进行聚合。awk是一种强大的文本处理工具,它可以处理文本文件中的数据,并根据条件执行相应的操作。以下是一个示例,假设你有一个名为data.csv的CSV文件,其中包含三列数据:姓名、年龄和性别,内容如下:姓名,年龄,性别张......
  • python数据集制作中的npz文件为何保存后为空文件?
    importosimportnumpyasnpfromPILimportImagedefreadData(txt_path):print('Loadingimages........')list_file=open(txt_path,'r')content=list_file.readlines()#使用readlines()方法将文件内容读取到一个列表content中,每一行作为列......
  • Linux查找文件内容
    从文件内容查找匹配指定字符串的行:$grep"被查找的字符串"文件名例子:在当前目录里第一级文件夹中寻找包含指定字符串的.in文件$grep"thermcontact"*/*.in从文件内容查找与正则表达式匹配的行:$grep–e“正则表达式”文件名查找时不区分大小写:$grep–i"......
  • 【Azure App Service】.NET应用读取静态文件时遇见了404错误的解决方法
    问题描述使用.NET8开发应用,部署到AzureAppService后,需要直接访问一些静态图片/视频文件,但是直接通过相对路径获取文件时,遇见404错误........ 问题解答在网上搜索“.NET应用读取静态文件”关键字,找到了问题原因。在IIS部署应用时代(.NETCore之前),是通过IIS服务来匹配文件......
  • (附nuclei yaml文件)泛微E-office 10 atuh-filephar反序列化命令执行漏洞复现(QVD-2024-1
    (附nucleiyaml文件)泛微E-office10atuh-filephar反序列化命令执行漏洞复现(QVD-2024-11354)声明本文仅用于技术交流,请勿用于非法用途由于传播、利用此文所提供的信息而造成的任何直接或者间接的后果及损失,均由使用者本人负责,文章作者不为此承担任何责任。1、漏洞简介泛......
  • WEB入门 - 文件上传
    WEB入门-文件上传参考文章https://fushuling.com/index.php/2023/08/20/ctfshow刷题记录持续更新中/https://www.cnblogs.com/sen-y/p/15579078.htmlhttp://i0921.cn/blog/5dc52b0aba304f6314a9229f/662062c9ed9f76063b6ceb80web151<buttontype="button"class="layui......
  • HarmonyOS实战开发:@ohos.pluginComponent (插件组件管理器)
    用于给插件组件的使用者请求组件与数据,使用者发送组件模板和数据。如需实现插件模板的显示,请参考PluginComponent。说明:本模块首批接口从APIVersion8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。导入模块importpluginComponentManagerfrom......
  • 使用shell脚本替换csv文件中的数据
    [observer@xxx-grey-openrestytest]$catfile.csvbeijing,beijing,lisi,10shanxi,xian,tom,6shanghai,shanghai,xiaoming,3guangdong,guangzhou,wangwu,8sichuan,chengdu,cat,5[observer@xxx-grey-openrestytest]$awk-F,-vOFS=,'$4>5{$4=3}{print......
  • 文件轻松按数量分组,管理更灵活便捷!
    在网络信息数据中,文件是我们知识的宝藏,也是我们工作的伙伴,陪伴着我们向前。可是,当这些文件数量繁多时,曾经的管理方法便显露出了不足,耗时长效率低等等一系列的问题,让我们难以有效地管理和利用这些宝贵的资源。面对这些问题,小编有一个方案可以让我们快速、准确、有效的进行管理,接......
  • 【ubuntu】使用split切割大的日志文件
    1、问题场景  太慢了  2、命令split-b500mtest.DEBUG.BAKtest.DEBUG.BAK_ 3、命令帮助$split--help用法:split[选项]...[文件[前缀]]将<文件>拆分并输出到"前缀aa"、"前缀ab"等文件;默认以1000行为拆分单位,默认<前缀>为"x"。如果没有指定......