MCPcopy Create free account
hub / github.com/Alibaba-NLP/DeepResearch / call_resum_server

Function call_resum_server

WebAgent/WebResummer/src/summary_utils.py:13–47  ·  view source on GitHub ↗
(query, max_retries=10)

Source from the content-addressed store, hash-verified

11
12
13def call_resum_server(query, max_retries=10):
14 data = {
15 "model": RESUM_TOOL_NAME,
16 "messages": [{ "role": "user", "content": query}],
17 "max_tokens": 4096,
18 "temperature": 0.6,
19 "top_p": 0.95,
20 }
21 header = {
22 "Content-Type": "application/json",
23 "Authorization": ""
24 }
25
26 for _ in range(max_retries):
27 try:
28 response = requests.post(RESUM_TOOL_URL, headers=header, json=data, timeout=360)
29 response.raise_for_status()
30 content = response.json()["choices"][0]["message"]["content"]
31 # print(content)
32 if content:
33 pattern = r'<think>.*?</think>'
34 content = re.sub(pattern, '', content, flags=re.DOTALL).strip()
35 try:
36 content = content.split("<summary>")[1].split("</summary>")[0]
37 except:
38 content = content
39 return "<summary>" + content + "</summary>"
40 else:
41 return ""
42 except Exception as e:
43 time.sleep(0.2)
44 if _ == max_retries - 1:
45 print(f"[Summary Tool] Server attempt {_+1}/{max_retries} failed: {str(e)}")
46 return ""
47 return ""
48
49
50def summarize_conversation(question, recent_history_messages, last_summary, max_retries=10):

Callers 2

summarize_conversationFunction · 0.85
summary_utils.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected