Skip to content

Commit

Permalink
[README]
Browse files Browse the repository at this point in the history
  • Loading branch information
Kye committed Feb 26, 2024
1 parent ecf2bf9 commit 47edf59
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1,016 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,37 @@ Base swarms code -> fastapi code is added to top and bottom -> agent is decorate
`pip install swarms-cloud`



## Calculate Pricing
```python
from transformers import AutoTokenizer
from swarms_cloud import calculate_pricing

# Initialize the tokenizer
tokenizer = AutoTokenizer.from_pretrained("gpt2")

# Define the example texts
texts = ["This is the first example text.", "This is the second example text."]

# Calculate pricing and retrieve the results
total_tokens, total_sentences, total_words, total_characters, total_paragraphs, cost = calculate_pricing(texts, tokenizer)

# Print the total tokens processed
print(f"Total tokens processed: {total_tokens}")

# Print the total cost
print(f"Total cost: ${cost:.5f}")
```


## Generate an API key
```python
from swarms_cloud.api_key_generator import generate_api_key

generate_api_key(prefix="sk", length=30)

```

# Stack
- Backend: FastAPI
- Skypilot for container management
Expand Down
1 change: 0 additions & 1 deletion swarms_cloud/api_key_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def generate_api_key(prefix: str = "sk-", length: int = 50, *args, **kwargs):
Example:
>>> from swarms_cloud.api_key_generator import generate_api_key
>>> generate_api_key()
>>> sk-9a7b8c5d6e7f8g9h0i1j2k3l4m5n6o7p8q9r0s1t2u3v4w5x6y7z8A9B0C1D2E3F4G5H6I7J8K9L0M1N2O3P4Q5R6S7T8U9V0W1X2Y3Z4
"""
if length <= len(prefix):
raise ValueError("Length must be greater than prefix length")
Expand Down
Loading

0 comments on commit 47edf59

Please sign in to comment.