Playing with ChatGPT API

Search for a command to run...

No comments yet. Be the first to comment.
https://github.com/withlang-dev/with/releases/latesthttps://discord.gg/f7u2MRuPSahttps://www.reddit.com/r/withlang/ I'm Eric Hartford, creator of the Dolphin and Samantha open source AI models. After
When the MI300X was launched in December 2023, there was a lot of optimism. We were desperate for an alternative to nVidia’s expensive and scarce H100s, especially one that provided 192gb of VRAM per GPU compared to the H100’s 80gb. And the MI300X wa...

How NIST Turned Open Science into a Security Scare

With the recent update to OpenAI's Terms of Use on October 23, 2024, there’s been a flurry of online discussions around what these terms mean for developers, businesses, and everyday users of AI tools like ChatGPT. Much of the conversation, especiall...

Gratitude to https://tensorwave.com/ for giving me access to their excellent servers! Few have tried this and fewer have succeeded. I've been marginally successful after a significant amount of effort, so it deserves a blog post. Know that you are in...

Quixi AI
20 posts
Applied AI Researcher I make AI models like Dolphin and Samantha https://ko-fi.com/erichartford BTC 3ENBV6zdwyqieAXzZP2i3EjeZtVwEmAuo4 ETH 0xcac74542A7fF51E2fb03229A5d9D0717cB6d70C9 https://quixi.ai
I thought I would try out ChatGPT's new API, so I decided to write a command line interface. My code is located here:
I wanted it to be conversational, so it will remember your conversation history as you type.
Similar to chatgpt-wrapper. https://github.com/mmabrouk/chatgpt-wrapper but in Node.
I wanted it to use TypeScript, and I wanted it to use Node's new native fetch api (which was officially promoted from "experimental" as of 18.13.0)
Example output:
I found that it's not that simple to bootstrap a TypeScript CLI. No "create" scripts here. I used ts-node so I can run it without building, like this:
I had to work around the fact that @types/node has no types for Node's native fetch library. (drop a note here if you would like to ask @types/node to add support for Node's native fetch, or contribute a pull request)
Then I had to add the typings in my tsconfig.json:
Then, it's a while loop that takes input, appends it to the history, and sends a request to the completions api, and appends the response to the history as well as displaying it.
You can find my code here:
I find this personally useful because it's much cheaper than ChatGPT Plus, and also it works even when ChatGPT is down.
Feel free to make a PR if you want to fix anything or add anything. I promise I'll review it!