{"id":20744210,"url":"https://github.com/021-projects/xenforo-chatgpt-framework","last_synced_at":"2025-03-11T12:41:15.093Z","repository":{"id":259526773,"uuid":"878120282","full_name":"021-projects/xenforo-chatgpt-framework","owner":"021-projects","description":"XenForo Framework that Simplifies Working with ChatGPT","archived":false,"fork":false,"pushed_at":"2024-11-24T09:50:46.000Z","size":178,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T02:27:36.543Z","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/021-projects.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":"2024-10-24T20:16:39.000Z","updated_at":"2024-11-24T09:50:49.000Z","dependencies_parsed_at":"2024-10-26T07:56:49.505Z","dependency_job_id":"d2c7b7a0-cf2f-4bad-a396-0d61818691c7","html_url":"https://github.com/021-projects/xenforo-chatgpt-framework","commit_stats":null,"previous_names":["021-projects/xenforo-chatgpt-framework"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/021-projects%2Fxenforo-chatgpt-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/021-projects%2Fxenforo-chatgpt-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/021-projects%2Fxenforo-chatgpt-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/021-projects%2Fxenforo-chatgpt-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/021-projects","download_url":"https://codeload.github.com/021-projects/xenforo-chatgpt-framework/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243039573,"owners_count":20226130,"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":[],"created_at":"2024-11-17T07:14:42.798Z","updated_at":"2025-03-11T12:41:15.069Z","avatar_url":"https://github.com/021-projects.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Getting started\n\n## Obtain Your OpenAI API Key\nTo use the ChatGPT API Framework, you need an API key from OpenAI. Register at [OpenAI](https://platform.openai.com/signup/) to obtain your key.\n\n## Initialize the OpenAI API\nThe ChatGPT API Framework simplifies the initialization of the OpenAI API. Use the following code snippet to get started:\n```php\nuse \\BS\\ChatGPTFramework\\Consts;\n\n/** \\Orhanerday\\OpenAi\\OpenAi $api */\n$api = \\XF::app()-\u003econtainer(Consts::API_CONTAINER_KEY);\n```\n\n## Get message from ChatGPT\nTo retrieve a reply from ChatGPT, utilize the `\\BS\\ChatGPTFramework\\Service\\API\\ChatWrapper` service. Here's an example:\n```php\nuse BS\\ChatGPTFramework\\Service\\API\\ChatWrapper;\nuse BS\\ChatGPTFramework\\DTO\\MessagesDTO;\nuse BS\\ChatGPTFramework\\DTO\\MessageDTO;\n\n/** @var ChatWrapper $wrapper */\n$wrapper = \\XF::service(ChatWrapper::class);\n\n$messages = new MessagesDTO(\n    new MessageDTO('Hello!')\n);\n$query = [\n    'model'             =\u003e 'gpt-4o-mini',\n    'messages'          =\u003e $messages-\u003etoArray(),\n    'temperature'       =\u003e 1.0,\n    'max_tokens'        =\u003e 420,\n    'frequency_penalty' =\u003e 0,\n    'presence_penalty'  =\u003e 0,\n];\n\n/** @var \\BS\\ChatGPTFramework\\DTO\\GPTResponse\\MessageDTO $message */\n$message = $wrapper-\u003egetMessage($query, mustHasContent: true);\n/** @var \\BS\\ChatGPTFramework\\DTO\\GPTResponse\\ToolCallsDTO $toolCalls */\n$toolCalls = $message-\u003etoolCalls;\n```\n\n## Stream message from ChatGPT\n```php\nuse BS\\ChatGPTFramework\\Service\\API\\ChatWrapper;\nuse BS\\ChatGPTFramework\\DTO\\MessagesDTO;\nuse BS\\ChatGPTFramework\\DTO\\MessageDTO;\nuse BS\\ChatGPTFramework\\DTO\\GPTResponse\\StreamChunkDTO;\n\n/** @var ChatWrapper $wrapper */\n$wrapper = \\XF::service(ChatWrapper::class);\n\n$messages = new MessagesDTO(\n    new MessageDTO('Hello!')\n);\n$query = [\n    'model'             =\u003e 'gpt-4o-mini',\n    'messages'          =\u003e $messages-\u003etoArray(),\n    'temperature'       =\u003e 1.0,\n    'max_tokens'        =\u003e 420,\n    'frequency_penalty' =\u003e 0,\n    'presence_penalty'  =\u003e 0,\n];\n\n$outputMessage = '';\n\n$wrapper-\u003estreamMessage($query, function (StreamChunkDTO $chunkDTO) use (\u0026$outputMessage) {\n    if (! $chunkDTO-\u003ehasContent()) {\n        return;\n    }\n    $outputMessage .= $chunkDTO-\u003econtent;\n});\n```\n\n## Other Features\nThe add-on also allows generating MessagesDTO from different XenForo contexts.\nPlease check the `BS\\ChatGPTFramework\\Repository\\Message` class for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F021-projects%2Fxenforo-chatgpt-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F021-projects%2Fxenforo-chatgpt-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F021-projects%2Fxenforo-chatgpt-framework/lists"}