chatgpt-cli icon indicating copy to clipboard operation
chatgpt-cli copied to clipboard

feat: add anthropic

Open TiansuYu opened this issue 1 year ago • 4 comments

TiansuYu avatar Jul 06 '24 10:07 TiansuYu

stuck at error invalid API Key. To reproduce:

export CHAT_API_CLI=xxx <anthropic key> 
chatgpt-cli --model claude-3-5-sonnet-20240620 --supplier anthropic

TiansuYu avatar Jul 06 '24 10:07 TiansuYu

Warning: current state works for Anthropic, but somehow breaks the openai integration.

The mix between biz logic / config logic and networking logic makes scaling out this CLI kind of hard. Would recommend rewrite the logic before scaling out to other integrations.

TiansuYu avatar Jul 06 '24 14:07 TiansuYu

https://github.com/tadeasf/chatgpt-cli/tree/styling @TiansuYu pretty much rewrote it... using litellm sdk https://docs.litellm.ai/docs/ for scalling.. so now you should be able to use pretty much all the models

  • i have bug in /c -> struggling with tagging the blocks as copy
  • included saving history in markdown or json option.. i prefer markdown as I am dumping it to my obsidian vault and the grepping through ti - pretty neat
  • included budgetmanager from litellm as well, not production though so you are limited per session but i will fine tune it eventually as well
  • included /e -> opens the markdown output in your set $EDITOR so you can copy what you need in case of big output the prompt library is unable to handle
  • refactored it etc will need general cleanup it's not really 100% ready yet but all the core functions work and are built on top of litellm

after i do general cleanup and get time to update readme, setup.cfg, configs etc i will push "beta" or whatnot

before i do that I am thinking about implementing a few general budget friendly options e.g. using embeddings models to map up your repo/project/long scripts before sending it to the llm for output and shit like that

i wrote it mainly for myself but i am very much willing to incorporate any hints and tips you throw at me

tadeasf avatar Aug 12 '24 06:08 tadeasf

oh, i also included prompt completer for models (if you pick a wrong one which is validated through litellm) and then path completer cuz nobody likes to have typos in paths haha

tadeasf avatar Aug 12 '24 06:08 tadeasf

I streamlined the UI, updated readme, fixed a few bugs, included session-wide budget management in ~/.config/chatgpt-cli/cost_usage.json which you can set easily to monthly/daily stuff. tbh, i haven't expected to put so much time into it, but i wanted to try out tiangolo's AWESOME typer cli framework and here we are haha

https://github.com/user-attachments/assets/c3ba47f6-3c0a-4aa1-9413-a9a9dea275f2

tadeasf avatar Aug 13 '24 16:08 tadeasf

Hey @tadeasf That looks awesome! Cannot wait for this to get out!

TiansuYu avatar Aug 15 '24 07:08 TiansuYu

Hey @tadeasf That looks awesome! Cannot wait for this to get out!

feel free to go here follow the instructions in the rewritten readme and you should be able to install it via pip or you can build it via pdm

the big llm part is practically finished. now i am working on ollama support... so I think that maybe i will do a PR here and find out whether @marcolardera is okay with me raping his initial one-script based solution like this or whether I should kill the fork and spin up a whole new project alltogether :)

tadeasf avatar Aug 15 '24 08:08 tadeasf

@tadeasf I will give it try!

TiansuYu avatar Aug 24 '24 09:08 TiansuYu

Just tested against openai, look all good. Though I find adding this to the end of every chat, is a bit verbose:

ChatGPT CLI
Provider: openai
Model: gpt-4o
───────────────────────────────────
[Tokens: 1076] [Cost: $0.029787]

And what I am missing from the original code is a schema for the config file. I wish there could be a dataclass or something for me to quickly understand how to configure this thing.

Also there is no CLI override options, which I think could be improved.

Let me know if you want a lending hand, we could work this together.

TiansuYu avatar Aug 24 '24 10:08 TiansuYu

Which branch you tested? Main is behind do styling. Lending hand 100% appreciated I was trying to push it but doing too much open source at the moment so second sets of eyes are very lovely

tadeasf avatar Aug 24 '24 19:08 tadeasf

@TiansuYu

tadeasf avatar Aug 24 '24 19:08 tadeasf

Which branch you tested?

styling

TiansuYu avatar Aug 25 '24 17:08 TiansuYu

@marcolardera What do you think of this overhaul initiative? Would you consider this to be merged into repo? Or you prefer us working on something separately.

TiansuYu avatar Aug 26 '24 16:08 TiansuYu