<commit_before>import json

import requests

from .cache import Cache
from .exception import *


class Api(object):
    def __init__(self, username: str, password: str, host_ip: str, host_port: str, token_cache: Cache):
        self.username = username
        self.password = password
        self.host_ip = host_ip
        self.host_port = host_port
        self._cache = token_cache
        self.root_url = 'http://{}:{}'.format(self.host_ip, self.host_port)

    @property
    def current_token(self):
        if self.token:
            return self.token
        else:
            return self._cache.get_token(self.host_ip, self.host_port)

    def _create_token(self):
        response = requests.get(
            '{}/token/create?username={}&password={}'.format(self.root_url, self.username, self.password))
        if response.status_code == 200:<commit_msg>修改bug<commit_after>import json

import requests

from .cache import Cache
from .exception import *


class Api(object):
    def __init__(self, username: str, password: str, host_ip: str, host_port: str, token_cache: Cache):
        self.username = username
        self.password = password
        self.host_ip = host_ip
        self.host_port = host_port
        self._cache = token_cache
        self.token = None
        self.root_url = 'http://{}:{}'.format(self.host_ip, self.host_port)

    @property
    def current_token(self):
        if self.token:
            return self.token
        else:
            return self._cache.get_token(self.host_ip, self.host_port)

    def _create_token(self):
        response = requests.get(
            '{}/token/create?username={}&password={}'.format(self.root_url, self.username, self.password))
        if response.status_code == 200:
{'fraction_non_alphanumeric': 0.11327231121281464, 'fraction_numerical': 0.003432494279176201, 'mean_word_length': 2.6666666666666665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2681596', 'n_tokens_mistral': 532, 'n_tokens_neox': 524, 'n_words': 119}