hadadrjt commited on
Commit
2a85ae5
·
1 Parent(s): bcca9d9

SearchGPT: Enhance. #3

Browse files
config.py CHANGED
@@ -8,6 +8,8 @@
8
 
9
  MODEL = "gpt-4.1-nano"
10
 
 
 
11
  SEARXNG_ENDPOINT = "https://searx.stream/search" # See the endpoint list at https://searx.space
12
  BAIDU_ENDPOINT = "https://www.baidu.com/s"
13
  READER_ENDPOINT = "https://r.jina.ai/"
@@ -240,7 +242,7 @@ REASONING_STEPS = {
240
 
241
  REASONING_DEFAULT = "I'm processing the tool execution request..."
242
 
243
- REASONING_DELAY = 0.15 # 150 ms
244
 
245
  OS = [
246
  "Windows NT 10.0; Win64; x64",
 
8
 
9
  MODEL = "gpt-4.1-nano"
10
 
11
+ MAX_TOKENS = 131072
12
+
13
  SEARXNG_ENDPOINT = "https://searx.stream/search" # See the endpoint list at https://searx.space
14
  BAIDU_ENDPOINT = "https://www.baidu.com/s"
15
  READER_ENDPOINT = "https://r.jina.ai/"
 
242
 
243
  REASONING_DEFAULT = "I'm processing the tool execution request..."
244
 
245
+ REASONING_DELAY = 0.01 # 10 ms
246
 
247
  OS = [
248
  "Windows NT 10.0; Win64; x64",
src/processor/reasoning/interface.py CHANGED
@@ -5,5 +5,14 @@
5
 
6
  def reasoning_interfaces(text, current_length=0):
7
  if current_length < len(text):
8
- return text[:current_length]
 
 
 
 
 
 
 
 
 
9
  return text
 
5
 
6
  def reasoning_interfaces(text, current_length=0):
7
  if current_length < len(text):
8
+ reasoning_steps = text[:current_length]
9
+
10
+ if current_length > 0 and not reasoning_steps.endswith((
11
+ '<br>',
12
+ '<br><br>'
13
+ )):
14
+ reasoning_steps += '...'
15
+
16
+ return reasoning_steps
17
+
18
  return text
src/processor/response/generator.py CHANGED
@@ -4,7 +4,7 @@
4
  #
5
 
6
  import traceback
7
- from config import INSTRUCTIONS_END
8
 
9
  def generate_response(
10
  server,
@@ -28,6 +28,7 @@ def generate_response(
28
  messages=conversation_messages,
29
  tools=tool_definitions if not tools_done else None,
30
  tool_choice="none",
 
31
  temperature=0.75,
32
  stream=True
33
  )
 
4
  #
5
 
6
  import traceback
7
+ from config import MAX_TOKENS, INSTRUCTIONS_END
8
 
9
  def generate_response(
10
  server,
 
28
  messages=conversation_messages,
29
  tools=tool_definitions if not tools_done else None,
30
  tool_choice="none",
31
+ max_tokens=MAX_TOKENS,
32
  temperature=0.75,
33
  stream=True
34
  )
src/processor/tools/interaction.py CHANGED
@@ -10,7 +10,7 @@ from ..reasoning.interface import reasoning_interfaces
10
  from ..reasoning.tool_reasoning import tool_reasoning
11
  from .parser import extract_tool_parameters
12
  from .executor import invoke_tool_function
13
- from config import REASONING_DELAY
14
 
15
  def process_tool_interactions(server, model_name, conversation_messages, tool_definitions, search_engine):
16
  maximum_iterations = 1
@@ -24,6 +24,7 @@ def process_tool_interactions(server, model_name, conversation_messages, tool_de
24
  messages=conversation_messages,
25
  tools=tool_definitions,
26
  tool_choice="auto",
 
27
  temperature=0.6
28
  )
29
  except Exception:
@@ -55,7 +56,7 @@ def process_tool_interactions(server, model_name, conversation_messages, tool_de
55
 
56
  if extraction_error:
57
  error_reasoning = tool_reasoning(tool_name, None, "error", error=extraction_error)
58
- for i in range(0, len(error_reasoning), 50):
59
  logs_generator = styles(reasoning_interfaces(error_reasoning, i), expanded=True)
60
  yield logs_generator
61
  time.sleep(REASONING_DELAY)
@@ -64,13 +65,13 @@ def process_tool_interactions(server, model_name, conversation_messages, tool_de
64
  tool_execution_result = extraction_error
65
  else:
66
  reasoning_status = tool_reasoning(tool_name, extracted_arguments, "parsing")
67
- for i in range(0, len(reasoning_status), 50):
68
  logs_generator = styles(reasoning_interfaces(reasoning_status, i), expanded=True)
69
  yield logs_generator
70
  time.sleep(REASONING_DELAY)
71
 
72
  reasoning_start = tool_reasoning(tool_name, extracted_arguments, "executing")
73
- for i in range(0, len(reasoning_start), 50):
74
  logs_generator = styles(reasoning_interfaces(reasoning_start, i), expanded=True)
75
  yield logs_generator
76
  time.sleep(REASONING_DELAY)
@@ -88,7 +89,7 @@ def process_tool_interactions(server, model_name, conversation_messages, tool_de
88
  })
89
 
90
  reasoning_done = tool_reasoning(tool_name, extracted_arguments, "completed", result=tool_execution_result)
91
- for i in range(0, len(reasoning_done), 50):
92
  logs_generator = styles(reasoning_interfaces(reasoning_done, i), expanded=True)
93
  yield logs_generator
94
  time.sleep(REASONING_DELAY)
@@ -97,7 +98,7 @@ def process_tool_interactions(server, model_name, conversation_messages, tool_de
97
 
98
  except Exception as tool_error:
99
  error_reasoning = tool_reasoning(tool_name, extracted_arguments, "error", error=str(tool_error))
100
- for i in range(0, len(error_reasoning), 50):
101
  logs_generator = styles(reasoning_interfaces(error_reasoning, i), expanded=True)
102
  yield logs_generator
103
  time.sleep(REASONING_DELAY)
 
10
  from ..reasoning.tool_reasoning import tool_reasoning
11
  from .parser import extract_tool_parameters
12
  from .executor import invoke_tool_function
13
+ from config import MAX_TOKENS, REASONING_DELAY
14
 
15
  def process_tool_interactions(server, model_name, conversation_messages, tool_definitions, search_engine):
16
  maximum_iterations = 1
 
24
  messages=conversation_messages,
25
  tools=tool_definitions,
26
  tool_choice="auto",
27
+ max_tokens=MAX_TOKENS,
28
  temperature=0.6
29
  )
30
  except Exception:
 
56
 
57
  if extraction_error:
58
  error_reasoning = tool_reasoning(tool_name, None, "error", error=extraction_error)
59
+ for i in range(0, len(error_reasoning), 5):
60
  logs_generator = styles(reasoning_interfaces(error_reasoning, i), expanded=True)
61
  yield logs_generator
62
  time.sleep(REASONING_DELAY)
 
65
  tool_execution_result = extraction_error
66
  else:
67
  reasoning_status = tool_reasoning(tool_name, extracted_arguments, "parsing")
68
+ for i in range(0, len(reasoning_status), 5):
69
  logs_generator = styles(reasoning_interfaces(reasoning_status, i), expanded=True)
70
  yield logs_generator
71
  time.sleep(REASONING_DELAY)
72
 
73
  reasoning_start = tool_reasoning(tool_name, extracted_arguments, "executing")
74
+ for i in range(0, len(reasoning_start), 5):
75
  logs_generator = styles(reasoning_interfaces(reasoning_start, i), expanded=True)
76
  yield logs_generator
77
  time.sleep(REASONING_DELAY)
 
89
  })
90
 
91
  reasoning_done = tool_reasoning(tool_name, extracted_arguments, "completed", result=tool_execution_result)
92
+ for i in range(0, len(reasoning_done), 5):
93
  logs_generator = styles(reasoning_interfaces(reasoning_done, i), expanded=True)
94
  yield logs_generator
95
  time.sleep(REASONING_DELAY)
 
98
 
99
  except Exception as tool_error:
100
  error_reasoning = tool_reasoning(tool_name, extracted_arguments, "error", error=str(tool_error))
101
+ for i in range(0, len(error_reasoning), 5):
102
  logs_generator = styles(reasoning_interfaces(error_reasoning, i), expanded=True)
103
  yield logs_generator
104
  time.sleep(REASONING_DELAY)