Spaces:
Runtime error
Runtime error
Upload gpt_analyze.py
Browse files- gpt_analyze.py +2 -2
gpt_analyze.py
CHANGED
|
@@ -29,7 +29,7 @@ def summary_text(text, api_key=None):
|
|
| 29 |
try:
|
| 30 |
|
| 31 |
# 初始化文本分割器,指定每个块的大小为2000。
|
| 32 |
-
text_splitter = RecursiveCharacterTextSplitter(chunk_size=
|
| 33 |
# 切分文本
|
| 34 |
texts = text_splitter.split_text(text)
|
| 35 |
# 使用 Document 类创建文档对象
|
|
@@ -57,7 +57,7 @@ def summary_text(text, api_key=None):
|
|
| 57 |
openai_api_key = api_key
|
| 58 |
else:
|
| 59 |
openai_api_key = os.getenv('OPENAI_API_KEY')
|
| 60 |
-
llm = OpenAI(temperature=0, model_name="gpt-3.5-turbo", openai_api_key=openai_api_key)
|
| 61 |
|
| 62 |
# 加载总结和完善模型链,并向其提供刚才定义的两个模板字符串作为问题和细化问题的提示。
|
| 63 |
chain = load_summarize_chain(llm, chain_type="refine", return_intermediate_steps=True,
|
|
|
|
| 29 |
try:
|
| 30 |
|
| 31 |
# 初始化文本分割器,指定每个块的大小为2000。
|
| 32 |
+
text_splitter = RecursiveCharacterTextSplitter(chunk_size=8000, chunk_overlap=0)
|
| 33 |
# 切分文本
|
| 34 |
texts = text_splitter.split_text(text)
|
| 35 |
# 使用 Document 类创建文档对象
|
|
|
|
| 57 |
openai_api_key = api_key
|
| 58 |
else:
|
| 59 |
openai_api_key = os.getenv('OPENAI_API_KEY')
|
| 60 |
+
llm = OpenAI(temperature=0, model_name="gpt-3.5-turbo-16k", openai_api_key=openai_api_key)
|
| 61 |
|
| 62 |
# 加载总结和完善模型链,并向其提供刚才定义的两个模板字符串作为问题和细化问题的提示。
|
| 63 |
chain = load_summarize_chain(llm, chain_type="refine", return_intermediate_steps=True,
|