Skip to content

Commit

Permalink
[FEAT][swarms_cloud]
Browse files Browse the repository at this point in the history
  • Loading branch information
Kye committed Feb 25, 2024
1 parent 5a5b49f commit ecf2bf9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "swarms-cloud"
version = "0.1.2"
version = "0.1.3"
description = "Swarms Cloud - Pytorch"
license = "MIT"
authors = ["Kye Gomez <[email protected]>"]
Expand All @@ -29,7 +29,7 @@ skypilot = "*"
torch = "*"
einops = "*"
pydantic = "*"

stripe = "*"

[tool.poetry.group.lint.dependencies]
ruff = "^0.1.6"
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ einops
tiktoken
uvicorn
loguru
pydantic
pydantic
stripe
4 changes: 1 addition & 3 deletions servers/cogvlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,7 @@ def generate_stream_cogvlm(
else:
torch_type = torch.float16

print(
f"========Use torch type as:{torch_type} with device:{DEVICE}========\n\n"
)
print(f"========Use torch type as:{torch_type} with device:{DEVICE}========\n\n")

if "cuda" in DEVICE:
if QUANT_ENABLED:
Expand Down
2 changes: 1 addition & 1 deletion swarms_cloud/calculate_pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def calculate_pricing(
rate_img: float = 0.003,
):
"""
Calculates the pricing for a given list of texts based on the number of tokens, sentences, words, characters, and paragraphs.
leCalctuple containingg for otal number of texts based on the number of tokens, sentences, words, characters, and paragraphs.
Args:
texts (list): A list of texts to calculate pricing for.
Expand Down
29 changes: 29 additions & 0 deletions swarms_cloud/stripe_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import logging

import stripe
from pydantic import BaseModel

stripe.api_key = "your_stripe_api_key"


class StripeInterface(BaseModel):
customer_id: str
amount: float
description: str


def bill_customer(customer_id: str, amount: float, description: str):
try:
stripe.Charge.create(
customer=customer_id,
amount=amount, # in cents
currency="usd",
description=description,
)
logging.info("Payment successful")
except stripe.error.StripeError as e:
logging.error(f"Payment failed: {str(e)}")


# Usage:
# bill_customer("429232323", 1000, "1,000 tokens")

0 comments on commit ecf2bf9

Please sign in to comment.