Update app.py
Browse files
app.py
CHANGED
@@ -31,12 +31,12 @@ llm = HuggingFaceHub(repo_id=repo_id, # for StarChat
|
|
31 |
|
32 |
chain = load_summarize_chain(llm, chain_type="refine")
|
33 |
|
34 |
-
text_splitter_rcs = RecursiveCharacterTextSplitter(
|
35 |
-
#separator = "\n", #TypeError: TextSplitter.__init__() got an unexpected keyword argument 'separator'
|
36 |
-
chunk_size = 500,
|
37 |
-
chunk_overlap = 100, #striding over the text
|
38 |
-
length_function = len,
|
39 |
-
)
|
40 |
|
41 |
#llm = ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo-16k")
|
42 |
|
@@ -49,11 +49,11 @@ if url !="" and not url.strip().isspace() and not url == "" and not url.strip()
|
|
49 |
print("Website to Chat: "+url)
|
50 |
loader = WebBaseLoader(url)
|
51 |
docs = loader.load()
|
52 |
-
split_docs = text_splitter_rcs.split_documents(docs)
|
53 |
-
print(split_docs)
|
54 |
print()
|
55 |
-
|
56 |
-
result=chain.run(split_docs) #找到之前总是POST Error的原因:chain.run(docs)的结果,格式不是str,导致程序错误
|
57 |
result=str(result)
|
58 |
cleaned_initial_ai_response = remove_context(result)
|
59 |
print(cleaned_initial_ai_response)
|
|
|
31 |
|
32 |
chain = load_summarize_chain(llm, chain_type="refine")
|
33 |
|
34 |
+
#text_splitter_rcs = RecursiveCharacterTextSplitter(
|
35 |
+
# #separator = "\n", #TypeError: TextSplitter.__init__() got an unexpected keyword argument 'separator'
|
36 |
+
# chunk_size = 500,
|
37 |
+
# chunk_overlap = 100, #striding over the text
|
38 |
+
# length_function = len,
|
39 |
+
# )
|
40 |
|
41 |
#llm = ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo-16k")
|
42 |
|
|
|
49 |
print("Website to Chat: "+url)
|
50 |
loader = WebBaseLoader(url)
|
51 |
docs = loader.load()
|
52 |
+
#split_docs = text_splitter_rcs.split_documents(docs)
|
53 |
+
#print(split_docs)
|
54 |
print()
|
55 |
+
result=chain.run(docs) #这个result的格式比较特殊,可以直接print,但不可以和其他字符串联合print输出 - this step errors!
|
56 |
+
#result=chain.run(split_docs) #找到之前总是POST Error的原因:chain.run(docs)的结果,格式不是str,导致程序错误
|
57 |
result=str(result)
|
58 |
cleaned_initial_ai_response = remove_context(result)
|
59 |
print(cleaned_initial_ai_response)
|