Merge branch 'main' into trisha

This commit is contained in:
Trisha Pan
2023-12-08 16:24:19 -05:00
committed by GitHub
2 changed files with 36 additions and 23 deletions

View File

@@ -1,41 +1,44 @@
TokenCost
# TokenCost
Overview
## Overview
TokenCost is a specialized tool designed for calculating the token count and associated cost of strings and messages used in Large Language Models (LLMs). This utility is particularly useful for developers and researchers working with language models, enabling them to estimate the computational resources required for processing various inputs.
Features
## Features
Token Counting: Accurately counts the number of tokens in a given string or message.
Cost Calculation: Computes the cost of processing based on the token count, considering the specific pricing model of the LLM in use.
Support for Multiple LLMs: Compatible with various Large Language Models.
Easy Integration: Simple API for integrating with existing projects or workflows.
- **Token Counting**: Accurately counts the number of tokens in a given string or message.
- **Cost Calculation**: Computes the cost of processing based on the token count, considering the specific pricing model of the LLM in use.
- **Support for Multiple LLMs**: Compatible with various Large Language Models.
- **Easy Integration**: Simple API for integrating with existing projects or workflows.
Installation
## Installation
To install TokenCost, use the following command:
```bash
git clone https://github.com/yourusername/tokencost.git
cd tokencost
pip install -r requirements.txt
```
Usage
## Usage
To use TokenCost, follow these steps:
1. Import the module:
1. Import the module:
```python
from tokencost import TokenCalculator
```
2. Initialize the calculator with your LLMs specifics:
calculator = TokenCalculator(model_name='gpt-3')
3. Calculate tokens and cost:
3. Calculate tokens and cost:
```python
text = "Your sample text here"
token_count, cost = calculator.calculate(text)
print(f"Token Count: {token_count}, Cost: {cost}")
```
To run tests, follow the below steps:
@@ -43,16 +46,11 @@ To run tests, follow the below steps:
1. `pytest tests` while in the `tokencost` folder to run the `tests` folder
Contributing
## Contributing
Contributions to TokenCost are welcome! Please refer to our Contribution Guidelines for more details.
License
## License
TokenCost is released under the MIT License.
Contact
For any queries or suggestions, please open an issue in the GitHub repository, or contact us directly at email.
Remember to replace placeholders like yourusername, your_email@example.com, and other specifics with your actual repository and contact information. Also, ensure that the installation and usage instructions match the actual implementation of your tool.