Spaces:
Sleeping
Sleeping
remove unused imports
Browse files
hackaprompt/completers.py
CHANGED
|
@@ -2,10 +2,8 @@ import logging
|
|
| 2 |
import os
|
| 3 |
from abc import ABC, abstractmethod
|
| 4 |
|
| 5 |
-
import openai
|
| 6 |
import tiktoken
|
| 7 |
from gradio_client import Client
|
| 8 |
-
from transformers import T5Tokenizer
|
| 9 |
|
| 10 |
|
| 11 |
from openai import OpenAI
|
|
@@ -88,10 +86,12 @@ class ChatGPTCompletor(TextCompletion):
|
|
| 88 |
|
| 89 |
class FlanT5Completor(TextCompletion):
|
| 90 |
def __init__(self, model: str):
|
|
|
|
| 91 |
self.model = model
|
| 92 |
self.client = Client(src=FLAN_HF_SPACE, hf_token=HUB_TOKEN)
|
| 93 |
|
| 94 |
def get_token_count(self, prompt: str) -> int:
|
|
|
|
| 95 |
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xxl")
|
| 96 |
|
| 97 |
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
|
|
|
|
| 2 |
import os
|
| 3 |
from abc import ABC, abstractmethod
|
| 4 |
|
|
|
|
| 5 |
import tiktoken
|
| 6 |
from gradio_client import Client
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
from openai import OpenAI
|
|
|
|
| 86 |
|
| 87 |
class FlanT5Completor(TextCompletion):
|
| 88 |
def __init__(self, model: str):
|
| 89 |
+
|
| 90 |
self.model = model
|
| 91 |
self.client = Client(src=FLAN_HF_SPACE, hf_token=HUB_TOKEN)
|
| 92 |
|
| 93 |
def get_token_count(self, prompt: str) -> int:
|
| 94 |
+
from transformers import T5Tokenizer
|
| 95 |
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xxl")
|
| 96 |
|
| 97 |
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
|