Add File
Browse files
app.py
CHANGED
|
@@ -3,10 +3,10 @@
|
|
| 3 |
import gradio as gr
|
| 4 |
import openai
|
| 5 |
import os
|
| 6 |
-
import tiktoken
|
| 7 |
|
| 8 |
openai.api_key = os.environ.get("OPENAI_API_KEY")
|
| 9 |
-
encoding = tiktoken.get_encoding("p50k_base")
|
| 10 |
|
| 11 |
class Conversation:
|
| 12 |
def __init__(self, prompt, num_of_round):
|
|
@@ -16,7 +16,8 @@ class Conversation:
|
|
| 16 |
self.messages.append(self.prompt)
|
| 17 |
|
| 18 |
def ask(self, question):
|
| 19 |
-
if len(encoding.encode(
|
|
|
|
| 20 |
return "输入的文字过长,请精简后再提问"
|
| 21 |
|
| 22 |
try:
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
import openai
|
| 5 |
import os
|
| 6 |
+
#import tiktoken
|
| 7 |
|
| 8 |
openai.api_key = os.environ.get("OPENAI_API_KEY")
|
| 9 |
+
#encoding = tiktoken.get_encoding("p50k_base")
|
| 10 |
|
| 11 |
class Conversation:
|
| 12 |
def __init__(self, prompt, num_of_round):
|
|
|
|
| 16 |
self.messages.append(self.prompt)
|
| 17 |
|
| 18 |
def ask(self, question):
|
| 19 |
+
#if len(encoding.encode(question)) > 512:
|
| 20 |
+
if len(question) > 512:
|
| 21 |
return "输入的文字过长,请精简后再提问"
|
| 22 |
|
| 23 |
try:
|