binqiangliu commited on
Commit
60ab24b
·
1 Parent(s): 572c0de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -67,6 +67,19 @@ chain = load_qa_chain(llm=llm, chain_type="stuff", prompt=PROMPT)
67
  def generate_random_string(length):
68
  letters = string.ascii_lowercase
69
  return ''.join(random.choice(letters) for i in range(length))
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  url="https://www.usinoip.com"
72
  #url="https://www.usinoip.com/UpdatesAbroad/290.html"
 
67
  def generate_random_string(length):
68
  letters = string.ascii_lowercase
69
  return ''.join(random.choice(letters) for i in range(length))
70
+
71
+ print(f"定义处理多余的Context文本的函数")
72
+ def remove_context(text):
73
+ # 检查 'Context:' 是否存在
74
+ if 'Context:' in text:
75
+ # 找到第一个 '\n\n' 的位置
76
+ end_of_context = text.find('\n\n')
77
+ # 删除 'Context:' 到第一个 '\n\n' 之间的部分
78
+ return text[end_of_context + 2:] # '+2' 是为了跳过两个换行符
79
+ else:
80
+ # 如果 'Context:' 不存在,返回原始文本
81
+ return text
82
+ print(f"处理多余的Context文本函数定义结束")
83
 
84
  url="https://www.usinoip.com"
85
  #url="https://www.usinoip.com/UpdatesAbroad/290.html"