Spaces:
Sleeping
Sleeping
gera
commited on
Commit
·
3a09f3c
1
Parent(s):
3db66b4
increased limit a bit, and added total letters
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ import fitz
|
|
| 8 |
|
| 9 |
MODEL = 'gpt-4-turbo'
|
| 10 |
PRICE_PER_M = 10.00
|
| 11 |
-
LIMIT =
|
| 12 |
|
| 13 |
api_key = os_getenv("OPENAI_APIKEY")
|
| 14 |
client = OpenAI(api_key=api_key)
|
|
@@ -83,18 +83,19 @@ def files_ready(filenames):
|
|
| 83 |
|
| 84 |
if tokens > LIMIT:
|
| 85 |
raise gr.Error(f"Book is too long. It's {tokens} tokens long and can't be more than {LIMIT}.")
|
| 86 |
-
return tokens, f"${cost}", [[prompt, None]]
|
| 87 |
|
| 88 |
def files_changed(filenames):
|
| 89 |
if filenames:
|
| 90 |
return "-", "-"
|
| 91 |
else:
|
| 92 |
-
return 0, "$0"
|
| 93 |
|
| 94 |
with gr.Blocks(title="Book summarization and more") as demo:
|
| 95 |
with gr.Row():
|
| 96 |
files = gr.Files(file_types=["txt","doc","docx","pdf"] )
|
| 97 |
with gr.Column():
|
|
|
|
| 98 |
tokens = gr.Text("0", label="Tokens")
|
| 99 |
cost = gr.Text("0", label="Cost")
|
| 100 |
|
|
@@ -105,8 +106,8 @@ with gr.Blocks(title="Book summarization and more") as demo:
|
|
| 105 |
multimodal=False)
|
| 106 |
|
| 107 |
other = gr.Button(interactive=False)
|
| 108 |
-
files.upload(files_ready, [files], [tokens, cost, chat.chatbot_state])
|
| 109 |
-
files.change(files_changed, files, [tokens, cost])
|
| 110 |
|
| 111 |
|
| 112 |
auth=os_getenv("APP_USERS", "null")
|
|
|
|
| 8 |
|
| 9 |
MODEL = 'gpt-4-turbo'
|
| 10 |
PRICE_PER_M = 10.00
|
| 11 |
+
LIMIT = 125000 # some space for answer
|
| 12 |
|
| 13 |
api_key = os_getenv("OPENAI_APIKEY")
|
| 14 |
client = OpenAI(api_key=api_key)
|
|
|
|
| 83 |
|
| 84 |
if tokens > LIMIT:
|
| 85 |
raise gr.Error(f"Book is too long. It's {tokens} tokens long and can't be more than {LIMIT}.")
|
| 86 |
+
return len(prompt), tokens, f"${cost}", [[prompt, None]]
|
| 87 |
|
| 88 |
def files_changed(filenames):
|
| 89 |
if filenames:
|
| 90 |
return "-", "-"
|
| 91 |
else:
|
| 92 |
+
return 0, 0, "$0"
|
| 93 |
|
| 94 |
with gr.Blocks(title="Book summarization and more") as demo:
|
| 95 |
with gr.Row():
|
| 96 |
files = gr.Files(file_types=["txt","doc","docx","pdf"] )
|
| 97 |
with gr.Column():
|
| 98 |
+
letters = gr.Text("0", label="Letters (with spaces)")
|
| 99 |
tokens = gr.Text("0", label="Tokens")
|
| 100 |
cost = gr.Text("0", label="Cost")
|
| 101 |
|
|
|
|
| 106 |
multimodal=False)
|
| 107 |
|
| 108 |
other = gr.Button(interactive=False)
|
| 109 |
+
files.upload(files_ready, [files], [letters, tokens, cost, chat.chatbot_state])
|
| 110 |
+
files.change(files_changed, files, [letters, tokens, cost])
|
| 111 |
|
| 112 |
|
| 113 |
auth=os_getenv("APP_USERS", "null")
|