sunholo 0.143.7__py3-none-any.whl → 0.143.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sunholo/agents/flask/vac_routes.py +47 -48
- sunholo/mcp/vac_mcp_server.py +25 -12
- sunholo/streaming/streaming.py +8 -8
- {sunholo-0.143.7.dist-info → sunholo-0.143.9.dist-info}/METADATA +1 -1
- {sunholo-0.143.7.dist-info → sunholo-0.143.9.dist-info}/RECORD +9 -9
- {sunholo-0.143.7.dist-info → sunholo-0.143.9.dist-info}/WHEEL +0 -0
- {sunholo-0.143.7.dist-info → sunholo-0.143.9.dist-info}/entry_points.txt +0 -0
- {sunholo-0.143.7.dist-info → sunholo-0.143.9.dist-info}/licenses/LICENSE.txt +0 -0
- {sunholo-0.143.7.dist-info → sunholo-0.143.9.dist-info}/top_level.txt +0 -0
@@ -1026,58 +1026,57 @@ if __name__ == "__main__":
|
|
1026
1026
|
|
1027
1027
|
# Create an async handler for the request
|
1028
1028
|
async def process_request():
|
1029
|
-
#
|
1030
|
-
|
1031
|
-
|
1029
|
+
# Handle JSON-RPC requests directly
|
1030
|
+
if not isinstance(data, dict) or "method" not in data:
|
1031
|
+
raise ValueError("Invalid JSON-RPC request")
|
1032
1032
|
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
# Create read queue with the request
|
1037
|
-
read_queue = asyncio.Queue()
|
1038
|
-
await read_queue.put(request_str.encode())
|
1039
|
-
await read_queue.put(None) # EOF signal
|
1040
|
-
|
1041
|
-
# Create write queue for response
|
1042
|
-
write_queue = asyncio.Queue()
|
1043
|
-
|
1044
|
-
# Create async iterators
|
1045
|
-
async def read_messages():
|
1046
|
-
while True:
|
1047
|
-
msg = await read_queue.get()
|
1048
|
-
if msg is None:
|
1049
|
-
break
|
1050
|
-
yield msg
|
1051
|
-
|
1052
|
-
responses = []
|
1053
|
-
async def write_messages():
|
1054
|
-
async for msg in write_queue:
|
1055
|
-
if msg is None:
|
1056
|
-
break
|
1057
|
-
responses.append(msg.decode())
|
1058
|
-
|
1059
|
-
# Run the server with these streams
|
1060
|
-
server = self.vac_mcp_server.get_server()
|
1061
|
-
|
1062
|
-
# Start write handler
|
1063
|
-
write_task = asyncio.create_task(write_messages())
|
1033
|
+
method = data["method"]
|
1034
|
+
params = data.get("params", {})
|
1035
|
+
request_id = data.get("id")
|
1064
1036
|
|
1065
1037
|
try:
|
1066
|
-
#
|
1067
|
-
|
1068
|
-
|
1038
|
+
# Handle different MCP methods
|
1039
|
+
if method == "tools/list":
|
1040
|
+
# Get the server and call list_tools handler
|
1041
|
+
server = self.vac_mcp_server.get_server()
|
1042
|
+
tools = await server._request_handlers["tools/list"]()
|
1043
|
+
|
1044
|
+
return {
|
1045
|
+
"jsonrpc": "2.0",
|
1046
|
+
"result": {"tools": [tool.model_dump() for tool in tools]},
|
1047
|
+
"id": request_id
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
elif method == "tools/call":
|
1051
|
+
# Handle tool calls
|
1052
|
+
tool_name = params.get("name")
|
1053
|
+
arguments = params.get("arguments", {})
|
1054
|
+
|
1055
|
+
if not tool_name:
|
1056
|
+
raise ValueError("Missing tool name")
|
1057
|
+
|
1058
|
+
server = self.vac_mcp_server.get_server()
|
1059
|
+
result = await server._request_handlers["tools/call"](tool_name, arguments)
|
1060
|
+
|
1061
|
+
return {
|
1062
|
+
"jsonrpc": "2.0",
|
1063
|
+
"result": {"content": [item.model_dump() for item in result]},
|
1064
|
+
"id": request_id
|
1065
|
+
}
|
1066
|
+
|
1067
|
+
else:
|
1068
|
+
raise ValueError(f"Unknown method: {method}")
|
1069
|
+
|
1069
1070
|
except Exception as e:
|
1070
|
-
log.error(f"Error
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
# Return collected responses
|
1080
|
-
return responses
|
1071
|
+
log.error(f"Error handling MCP method {method}: {e}")
|
1072
|
+
return {
|
1073
|
+
"jsonrpc": "2.0",
|
1074
|
+
"error": {
|
1075
|
+
"code": -32603,
|
1076
|
+
"message": str(e)
|
1077
|
+
},
|
1078
|
+
"id": request_id
|
1079
|
+
}
|
1081
1080
|
|
1082
1081
|
# Run the async handler
|
1083
1082
|
loop = asyncio.new_event_loop()
|
sunholo/mcp/vac_mcp_server.py
CHANGED
@@ -166,18 +166,31 @@ class VACMCPServer:
|
|
166
166
|
# Collect streaming responses
|
167
167
|
full_response = ""
|
168
168
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
169
|
+
# Check if stream_interpreter is async
|
170
|
+
if asyncio.iscoroutinefunction(self.stream_interpreter):
|
171
|
+
async for chunk in start_streaming_chat_async(
|
172
|
+
question=user_input,
|
173
|
+
vector_name=vector_name,
|
174
|
+
qna_func_async=self.stream_interpreter,
|
175
|
+
chat_history=chat_history,
|
176
|
+
wait_time=stream_wait_time,
|
177
|
+
timeout=stream_timeout
|
178
|
+
):
|
179
|
+
if isinstance(chunk, dict) and 'answer' in chunk:
|
180
|
+
full_response = chunk['answer']
|
181
|
+
elif isinstance(chunk, str):
|
182
|
+
full_response += chunk
|
183
|
+
else:
|
184
|
+
# Fall back to sync version for non-async interpreters
|
185
|
+
result = self.stream_interpreter(
|
186
|
+
question=user_input,
|
187
|
+
vector_name=vector_name,
|
188
|
+
chat_history=chat_history
|
189
|
+
)
|
190
|
+
if isinstance(result, dict):
|
191
|
+
full_response = result.get("answer", str(result))
|
192
|
+
else:
|
193
|
+
full_response = str(result)
|
181
194
|
|
182
195
|
return [
|
183
196
|
TextContent(
|
sunholo/streaming/streaming.py
CHANGED
@@ -167,16 +167,16 @@ async def start_streaming_chat_async(question, vector_name, qna_func_async, chat
|
|
167
167
|
content_buffer = ContentBuffer()
|
168
168
|
chat_callback_handler = BufferStreamingStdOutCallbackHandlerAsync(content_buffer=content_buffer, tokens=".!?\n")
|
169
169
|
|
170
|
-
result_queue = Queue()
|
171
|
-
exception_queue = Queue()
|
172
|
-
stop_event = Event()
|
170
|
+
result_queue = asyncio.Queue()
|
171
|
+
exception_queue = asyncio.Queue()
|
172
|
+
stop_event = asyncio.Event()
|
173
173
|
|
174
174
|
async def start_chat():
|
175
175
|
try:
|
176
176
|
final_result = await qna_func_async(question, vector_name, chat_history, callback=chat_callback_handler, **kwargs)
|
177
|
-
result_queue.put(final_result)
|
177
|
+
await result_queue.put(final_result)
|
178
178
|
except Exception as e:
|
179
|
-
exception_queue.put(e)
|
179
|
+
await exception_queue.put(e)
|
180
180
|
|
181
181
|
# Run start_chat asynchronously
|
182
182
|
chat_task = asyncio.create_task(start_chat())
|
@@ -222,10 +222,10 @@ async def start_streaming_chat_async(question, vector_name, qna_func_async, chat
|
|
222
222
|
final_yield = ""
|
223
223
|
else:
|
224
224
|
log.info("Sending final full message plus sources...")
|
225
|
-
|
226
|
-
final_result = result_queue.
|
225
|
+
try:
|
226
|
+
final_result = result_queue.get_nowait()
|
227
227
|
final_yield = parse_output(final_result)
|
228
|
-
|
228
|
+
except asyncio.QueueEmpty:
|
229
229
|
final_yield = ""
|
230
230
|
|
231
231
|
# Match the non-async behavior - yield the parsed output directly, not as JSON
|
@@ -18,7 +18,7 @@ sunholo/agents/fastapi/base.py,sha256=W-cyF8ZDUH40rc-c-Apw3-_8IIi2e4Y9qRtnoVnsc1
|
|
18
18
|
sunholo/agents/fastapi/qna_routes.py,sha256=lKHkXPmwltu9EH3RMwmD153-J6pE7kWQ4BhBlV3to-s,3864
|
19
19
|
sunholo/agents/flask/__init__.py,sha256=dEoByI3gDNUOjpX1uVKP7uPjhfFHJubbiaAv3xLopnk,63
|
20
20
|
sunholo/agents/flask/base.py,sha256=vnpxFEOnCmt9humqj-jYPLfJcdwzsop9NorgkJ-tSaU,1756
|
21
|
-
sunholo/agents/flask/vac_routes.py,sha256=
|
21
|
+
sunholo/agents/flask/vac_routes.py,sha256=WfE9ga_EZq_dpW4S5aYyj7i8r59VO5FpDFdtVtqKVKI,53604
|
22
22
|
sunholo/archive/__init__.py,sha256=qNHWm5rGPVOlxZBZCpA1wTYPbalizRT7f8X4rs2t290,31
|
23
23
|
sunholo/archive/archive.py,sha256=PxVfDtO2_2ZEEbnhXSCbXLdeoHoQVImo4y3Jr2XkCFY,1204
|
24
24
|
sunholo/auth/__init__.py,sha256=TeP-OY0XGxYV_8AQcVGoh35bvyWhNUcMRfhuD5l44Sk,91
|
@@ -117,7 +117,7 @@ sunholo/lookup/model_lookup.yaml,sha256=O7o-jP53MLA06C8pI-ILwERShO-xf6z_258wtpZB
|
|
117
117
|
sunholo/mcp/__init__.py,sha256=Bi0ZYMvWuf1AL_QSrMAREVVdTZFiIokGwrytBXKBJyc,1028
|
118
118
|
sunholo/mcp/cli.py,sha256=d24nnVzhZYz4AWgTqmN-qjKG4rPbf8RhdmEOHZkBHy8,10570
|
119
119
|
sunholo/mcp/mcp_manager.py,sha256=g75vv6XvM24U7uz366slE-p76Qs4AvVcsarHSF9qIvE,5061
|
120
|
-
sunholo/mcp/vac_mcp_server.py,sha256=
|
120
|
+
sunholo/mcp/vac_mcp_server.py,sha256=WcFOgN2_lyp1vfn-KcW4GewrBidkRYDx9gzEORV6rV8,10611
|
121
121
|
sunholo/ollama/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
122
122
|
sunholo/ollama/ollama_images.py,sha256=H2cpcNu88R4TwyfL_nnqkQhdvBQ2FPCAy4Ok__0yQmo,2351
|
123
123
|
sunholo/pubsub/__init__.py,sha256=DfTEk4zmCfqn6gFxRrqDO0pOrvXTDqH-medpgYO4PGw,117
|
@@ -132,7 +132,7 @@ sunholo/streaming/__init__.py,sha256=MpbydI2UYo_adttPQFkxNM33b-QRyNEbrKJx0C2AGPc
|
|
132
132
|
sunholo/streaming/content_buffer.py,sha256=bqPta3Q1tXI88Ngyj1kgPC-v4phhGm1nZURcuqQSGIQ,12537
|
133
133
|
sunholo/streaming/langserve.py,sha256=hi7q8WY8DPKrALl9m_dOMxWOdE-iEuk7YW05SVDFIX8,6514
|
134
134
|
sunholo/streaming/stream_lookup.py,sha256=hYg1DbdSE_QNJ8ZB-ynXJlWgvFjrGvwoUsGJu_E0pRQ,360
|
135
|
-
sunholo/streaming/streaming.py,sha256=
|
135
|
+
sunholo/streaming/streaming.py,sha256=2KgiiCZl0nGZQDF1oO7gti3e3_cPlomLRkQGGMNj0qQ,17203
|
136
136
|
sunholo/summarise/__init__.py,sha256=MZk3dblUMODcPb1crq4v-Z508NrFIpkSWNf9FIO8BcU,38
|
137
137
|
sunholo/summarise/summarise.py,sha256=UnycBVLLEXK1HitCOG2zW3XIyxMrw47xoVf6e2OC9A0,4150
|
138
138
|
sunholo/templates/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -175,9 +175,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
|
|
175
175
|
sunholo/vertex/memory_tools.py,sha256=tBZxqVZ4InTmdBvLlOYwoSEWu4-kGquc-gxDwZCC4FA,7667
|
176
176
|
sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
|
177
177
|
sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
|
178
|
-
sunholo-0.143.
|
179
|
-
sunholo-0.143.
|
180
|
-
sunholo-0.143.
|
181
|
-
sunholo-0.143.
|
182
|
-
sunholo-0.143.
|
183
|
-
sunholo-0.143.
|
178
|
+
sunholo-0.143.9.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
|
179
|
+
sunholo-0.143.9.dist-info/METADATA,sha256=6kw6sOw6kpW1voU10qdRDCRp82VXiZX57ul2z3ghuSI,18413
|
180
|
+
sunholo-0.143.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
181
|
+
sunholo-0.143.9.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
|
182
|
+
sunholo-0.143.9.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
|
183
|
+
sunholo-0.143.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|