{"id":18486143,"url":"https://github.com/mathsgod/openai-chat","last_synced_at":"2026-02-26T23:31:55.786Z","repository":{"id":178215070,"uuid":"654039846","full_name":"mathsgod/openai-chat","owner":"mathsgod","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-26T10:11:56.000Z","size":73,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-30T04:47:21.561Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/mathsgod.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":"2023-06-15T09:06:29.000Z","updated_at":"2024-06-26T10:10:06.000Z","dependencies_parsed_at":"2024-06-26T11:37:22.686Z","dependency_job_id":"95f32218-3d9e-49c5-8980-bef89c16e42e","html_url":"https://github.com/mathsgod/openai-chat","commit_stats":null,"previous_names":["mathsgod/openai-chat"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/mathsgod/openai-chat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Fopenai-chat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Fopenai-chat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Fopenai-chat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Fopenai-chat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathsgod","download_url":"https://codeload.github.com/mathsgod/openai-chat/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Fopenai-chat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29876935,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T22:37:10.609Z","status":"ssl_error","status_checked_at":"2026-02-26T22:37:09.019Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-06T12:47:58.194Z","updated_at":"2026-02-26T23:31:55.752Z","avatar_url":"https://github.com/mathsgod.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# openai-chat\n\n## Installation\n\n```bash\ncomposer require mathsgod/openai-chat\n```\n\n\n## Usage\n\nTo use the OpenAI chat, you need to create a new instance of the `System` class and pass the OpenAI API key as the first argument.\n\n```php\nuse OpenAI\\Chat\\System;\n\n$system = new System($_ENV['OPENAI_API_KEY']);\n\necho $system-\u003eask(\"Hello\");\n\n```\n\n### Add a tool\n\n```php\nuse OpenAI\\Chat\\Attributes\\Tool;\nuse OpenAI\\Chat\\Attributes\\Parameter;\n\n#[Tool(description: 'Get the release date of iphone')]\nfunction getIPhoneReleaseDate(#[Parameter(\"model of the phone\")] string $model)\n{\n    return [\"date\" =\u003e \"2022-09-14\", \"model\" =\u003e $model];\n}\n\n$system-\u003eaddTool(Closure::fromCallable(\"getIPhoneReleaseDate\"));\n\necho $system-\u003eask(\"When will iPhone 14 be released?\");\n```\n\n\n#### Add a tool from a class method\n\n```php\nclass Controller\n{\n    public $price = \"$799\";\n\n    #[Tool(description: 'Get the price of iphone')]\n    public function getIPhonePrice(#[Parameter(\"model of the phone\")] string $model)\n    {\n        return [\"price\" =\u003e $this-\u003eprice, \"model\" =\u003e $model];\n    }\n}\n\n$system-\u003eaddTool(Closure::fromCallable([new Controller(), \"getIPhonePrice\"]));\n\necho $system-\u003eask(\"What is the price and release date of iphone14?\");\n\n```\n\n### Get usage records\nAfter run the code above, you can get the usage records\n```php\n\nprint_r($system-\u003egetUsages());\n\n```\n\n### Streaming\n\n```php\n$stream = $system-\u003easkAsStream(\"What is the price and release date of iphone14?\");\n\n$stream-\u003eon('data', function ($data) {\n    echo $data;\n});\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathsgod%2Fopenai-chat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathsgod%2Fopenai-chat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathsgod%2Fopenai-chat/lists"}