Skip to content

Commit

Permalink
updated contributing file
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulDey12 committed Jun 9, 2024
1 parent 7b92120 commit 199a5c2
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/.editorconfig export-ignore
/UPGRADING.md export-ignore
/.styleci.yml export-ignore
/README.md export-ignore
/rector.php export-ignore
53 changes: 53 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Contributing to tiktoken-php

Thank you for considering contributing to tiktoken-php!

## How to Contribute

### Suggesting Enhancements

Create an issue on GitHub with:
- A clear title
- Detailed description
- Relevant use cases

### Submitting Pull Requests

1. **Fork the repository** to your GitHub account.
2. **Clone your fork**: `git clone https://github.com/YOUR-USERNAME/tiktoken-php.git`
3. **Create a branch**: `git checkout -b feature/your-feature-name`
4. **Make your changes**, following the project’s coding standards.
5. **Refactor your code**: `composer refactor`
6. **Push to your fork**: `git push origin feature/your-feature-name`
7. **Open a pull request** with a clear description and reference any related issues.

## Guidelines

- Ensure your code follows the project’s coding style by running `composer lint`.
- Send a coherent commit history, making sure each individual commit in your pull request is meaningful.
- You may need to [rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) to avoid merge conflicts.
- Remember that we follow [Semantic Versioning (SemVer)](http://semver.org/).

## Tests

Run all tests:
```bash
composer test
```

Check code quality:
```bash
composer test:refactor
```

Check types:
```bash
composer test:types
```

Unit tests:
```bash
composer test:unit
```

Thank you for contributing to tiktoken-php!
18 changes: 17 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"psr/http-client": "^1.0",
"psr/http-client-implementation": "^1.0",
"psr/http-factory-implementation": "*",
"psr/http-message": "^2.0",
"psr/http-message": "^1.0|^2.0",
"symfony/cache": "^6.1|^7.0",
"symfony/filesystem": "^6.1|^7.0"
},
Expand Down Expand Up @@ -45,5 +45,21 @@
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"scripts": {
"lint": "pint -v",
"refactor": "rector --debug",
"test:lint": "pint --test -v",
"test:refactor": "rector --dry-run",
"test:types": "phpstan analyse --ansi",
"test:type-coverage": "pest --type-coverage --min=100",
"test:unit": "pest --colors=always",
"test": [
"@test:lint",
"@test:refactor",
"@test:types",
"@test:type-coverage",
"@test:unit"
]
}
}
2 changes: 1 addition & 1 deletion src/Loaders/TiktokenLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function load(string $bpeFile, ?string $expectedHash = null): array
$result[base64_decode($token)] = intval($rank);
}

if (count($result) === 0) {
if ($result === []) {
throw new \Exception('Invalid tiktoken');
}

Expand Down
6 changes: 1 addition & 5 deletions src/Readers/HttpReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ public static function create(?ClientInterface $client = null): HttpReader

public function read(string|RequestInterface $location): string
{
if (is_string($location)) {
$request = (new Psr17Factory())->createRequest('GET', $location);
} else {
$request = $location;
}
$request = is_string($location) ? (new Psr17Factory())->createRequest('GET', $location) : $location;

$response = $this->client->sendRequest($request);

Expand Down

0 comments on commit 199a5c2

Please sign in to comment.