V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
inkuku
V2EX  ›  分享创造

用 Rust 写了一个免费使用 ChatGPT 的命令行工具

  •  
  •   inkuku ·
    shenjinti · 13 天前 · 1644 次点击

    Rust写了一个免费使用 ChatGPT 的命令行工具

    代码在 https://github.com/shenjinti/fgpt 🙏 star

    提供了 mac 和 linux 的二进制包. 可以到 github 上自行下载

    不得不说,Rust写 cli 工具还是真的好用,不管是readline或者tokioreqwest都大大减少代码量

    功能:

    • 完全命令行操作,支持各种管道
    • 支持交互模式,能重置会话
    • 内置支持代理配置,也可以用全局的https_proxy变量
    • 支持 OpenAI 的OpenAPI模式,无限使用

    看看简单用法

    
    fgpt "How to get a domain's MX record on linux shell?"
    
    # Output plain code -c/--code
    fgpt -c "Write python code to reverse a string"
    
    # With pipe
    git diff | fgpt "Write a git commit bief with follow diff"
    
    # With stdin
    fgpt "Convert the follow csv data to json, without any description" < contacts.csv
    
    
    16 条回复    2024-04-22 17:36:38 +08:00
    amorphobia
        1
    amorphobia  
       13 天前
    linux 可以编译 musl libc 吗?想在某些古老的系统上使用
    Vogan
        2
    Vogan  
       13 天前
    能支持代码 markdown 的高亮嘛? shell-gpt 支持
    inkuku
        3
    inkuku  
    OP
       12 天前
    @amorphobia 可以的,我研究一下
    inkuku
        4
    inkuku  
    OP
       12 天前
    @Vogan 安排,今天支持哈哈
    molezznet
        5
    molezznet  
       12 天前
    fgpt "hello"
    Error: Reqwest("builder error")
    怎么排查 ……
    inkuku
        6
    inkuku  
    OP
       12 天前
    @molezznet 抱歉抱歉,我们看看啥情况了这是
    你 fgpt --log-level debug 看看?
    macy
        7
    macy  
       12 天前
    能否支持自己配置 url 和 key 呢,这样就能对接到其他兼容的大模型或者企业内部私有的模型了
    molezznet
        8
    molezznet  
       12 天前
    fgpt --log-level debug "hi"
    2024-04-19 10:45:02 [DEBUG] cli.rs:141 - Message { role: "user", content: "hi", content_type: "text" }
    Error: Reqwest("builder error")
    inkuku
        9
    inkuku  
    OP
       12 天前
    @macy 暂时不支持配置 api key ,后续可以考虑支持 ollama
    inkuku
        10
    inkuku  
    OP
       12 天前
    @molezznet 私信你了,➕微信我看看,看起来应该是你的 proxy 设置我们不支持
    inkuku
        11
    inkuku  
    OP
       12 天前
    @molezznet 这里好像不能 DM ,加我 jinti2000 哈哈哈哈
    molezznet
        12
    molezznet  
       12 天前
    @inkuku 嗯 没事啊, 我在 github issues 提吧, 方便贴东西
    inkuku
        13
    inkuku  
    OP
       12 天前
    @molezznet hahah ,看到了,多谢,确认是 reqwest 没有启用 socks5 导致的,我已经修复了,可以测试看看哈哈
    molezznet
        14
    molezznet  
       12 天前
    @inkuku 行了
    >> 含有“笑”的词语
    当然,以下是一些含有“笑”的词语:

    1. 笑容 (xiào róng) - smile
    2. 笑话 (xiào huà) - joke
    3. 笑声 (xiào shēng) - laughter
    4. 笑脸 (xiào liǎn) - smiling face
    5. 笑眼 (xiào yǎn) - laughing eyes
    6. 笑嘻嘻 (xiào xī xī) - smilingly
    7. 笑到肚子疼 (xiào dào dù zi téng) - laughing till one's stomach hurts
    8. 笑而不语 (xiào ér bù yǔ) - smile without saying a word

    希望你喜欢这些词语!
    royalknight
        15
    royalknight  
       9 天前
    这个会封号吗,哈哈
    inkuku
        16
    inkuku  
    OP
       9 天前
    @royalknight 不会,因为没有登录注册账号的逻辑,但是需要自己翻墙
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   811 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 20:16 · PVG 04:16 · LAX 13:16 · JFK 16:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.