{"id":15064336,"url":"https://github.com/jacoblincool/chatgpt-agent","last_synced_at":"2025-04-10T11:51:26.795Z","repository":{"id":64354112,"uuid":"574239533","full_name":"JacobLinCool/ChatGPT-Agent","owner":"JacobLinCool","description":"Deprecated! Library, CLI, and Discord bot for the unofficial ChatGPT API with progressive responses and more.","archived":false,"fork":false,"pushed_at":"2023-12-15T05:39:17.000Z","size":177,"stargazers_count":11,"open_issues_count":2,"forks_count":2,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-04-23T14:05:27.334Z","etag":null,"topics":["bot","chatgpt","discord"],"latest_commit_sha":null,"homepage":"https://discord.com/oauth2/authorize?client_id=1049030945832972389\u0026permissions=274877975552\u0026scope=bot","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JacobLinCool.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-04T21:00:29.000Z","updated_at":"2023-10-12T18:13:36.000Z","dependencies_parsed_at":"2023-12-15T06:49:03.722Z","dependency_job_id":null,"html_url":"https://github.com/JacobLinCool/ChatGPT-Agent","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2FChatGPT-Agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2FChatGPT-Agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2FChatGPT-Agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2FChatGPT-Agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JacobLinCool","download_url":"https://codeload.github.com/JacobLinCool/ChatGPT-Agent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248215191,"owners_count":21066619,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","chatgpt","discord"],"created_at":"2024-09-25T00:15:34.405Z","updated_at":"2025-04-10T11:51:26.775Z","avatar_url":"https://github.com/JacobLinCool.png","language":"TypeScript","readme":"# ChatGPT Agent\n\nThis is a library, a CLI, and a Discord bot for the unofficial [ChatGPT](https://chat.openai.com/chat) API with progressive responses and more.\n\nYou can find READMEs for the library, CLI, and Discord bot in their respective folders in `packages/`.\n\nThe library documentation is available at [https://jacoblincool.github.io/ChatGPT-Agent/](https://jacoblincool.github.io/ChatGPT-Agent/).\n\nThe CLI is available on [npm](https://www.npmjs.com/package/chatgpt-cli).\n\nAnd you can invite the Discord bot to your server with [this link](https://discord.com/oauth2/authorize?client_id=1049030945832972389\u0026permissions=274877975552\u0026scope=bot). (Or host it by yourself: clone the repo, setup `.env`, and run `docker compose up`.)\n\n## The Library\n\n[Features](#features) | [Usage](#usage) | [Configuration](#configuration)\n\n### Features\n\n- Progressive responses\n- Multiple sessions\n- Conversation history\n- Automatic token refresh\n- Request timeout\n- Request retry\n\n### Usage\n\n```ts\n// refresh_token is optional\nconst agent = new Agent(token, refresh_token);\n\n// multiple sessions can be created\nconst session = agent.session();\n\nconst first_conv = session.talk(\"Hello\");\nfirst_conv.on(\"partial\", partial);\nconsole.log(\"completed\", await first_conv.response);\nfirst_conv.off(\"partial\", partial);\n\nconst second_conv = session.talk(\"Tell me a joke\");\nsecond_conv.on(\"partial\", partial);\nconsole.log(\"completed\", await second_conv.response);\nsecond_conv.off(\"partial\", partial);\n\nconsole.log(\"history\", session.history);\n```\n\n`Agent` is the main class for the library. It represents a single user, and handles the token (and refresh token), and can create multiple sessions.\n\n`Session` is a class that represents a single context just like the new ChatGPT tab you opened in the browser. It can be created with `Agent.session()`. It has a `history` property that is an array of messages, and a `talk` method that takes a message and returns a `Conversation` object.\n\n`Conversation` is a class that represents a single conversation. It has a `response` property that is a promise that resolves to the full response, and an `on` method that takes an event name and a callback. You can listen to `partial` events, which are fired when the response is updated, and `complete` events, which are fired when the response is complete. Also, `error` events are fired when an error occurs.\n\n### Configuration\n\nYou can configure the backend URL and the request timeout for the agent.\n\n```ts\nconst agent = new Agent(token, refresh_token, {\n  backend: \"https://chat.openai.com/backend-api\",\n  timeout: 60_000,\n});\n```\n\nThe default backend URL is `https://chat.openai.com/backend-api`, and the default timeout is 60 seconds.\n\nYou can also configure them using environment variables.\n\n```sh\nCHATGPT_BACKEND=\"https://chat.openai.com/backend-api\"\nCHATGPT_TIMEOUT=60000\nCHATGPT_RETRY=1\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacoblincool%2Fchatgpt-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacoblincool%2Fchatgpt-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacoblincool%2Fchatgpt-agent/lists"}