hyperforge-external 1.0.0.post90__tar.gz → 1.0.0.post93__tar.gz

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.
Files changed (14) hide show
  1. {hyperforge_external-1.0.0.post90 → hyperforge_external-1.0.0.post93}/PKG-INFO +1 -1
  2. {hyperforge_external-1.0.0.post90 → hyperforge_external-1.0.0.post93}/pyproject.toml +1 -1
  3. {hyperforge_external-1.0.0.post90 → hyperforge_external-1.0.0.post93}/src/hyperforge_external/agent.py +3 -1
  4. {hyperforge_external-1.0.0.post90 → hyperforge_external-1.0.0.post93}/src/hyperforge_external.egg-info/PKG-INFO +1 -1
  5. {hyperforge_external-1.0.0.post90 → hyperforge_external-1.0.0.post93}/tests/test_external.py +53 -2
  6. {hyperforge_external-1.0.0.post90 → hyperforge_external-1.0.0.post93}/README.md +0 -0
  7. {hyperforge_external-1.0.0.post90 → hyperforge_external-1.0.0.post93}/setup.cfg +0 -0
  8. {hyperforge_external-1.0.0.post90 → hyperforge_external-1.0.0.post93}/src/hyperforge_external/__init__.py +0 -0
  9. {hyperforge_external-1.0.0.post90 → hyperforge_external-1.0.0.post93}/src/hyperforge_external/config.py +0 -0
  10. {hyperforge_external-1.0.0.post90 → hyperforge_external-1.0.0.post93}/src/hyperforge_external/py.typed +0 -0
  11. {hyperforge_external-1.0.0.post90 → hyperforge_external-1.0.0.post93}/src/hyperforge_external.egg-info/SOURCES.txt +0 -0
  12. {hyperforge_external-1.0.0.post90 → hyperforge_external-1.0.0.post93}/src/hyperforge_external.egg-info/dependency_links.txt +0 -0
  13. {hyperforge_external-1.0.0.post90 → hyperforge_external-1.0.0.post93}/src/hyperforge_external.egg-info/requires.txt +0 -0
  14. {hyperforge_external-1.0.0.post90 → hyperforge_external-1.0.0.post93}/src/hyperforge_external.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyperforge_external
3
- Version: 1.0.0.post90
3
+ Version: 1.0.0.post93
4
4
  Summary: External Hyperforge agent
5
5
  Author-email: Nuclia <nucliadb@nuclia.com>
6
6
  License-Expression: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hyperforge_external"
7
- version = "1.0.0.post90"
7
+ version = "1.0.0.post93"
8
8
  license = "Apache-2.0"
9
9
  description = "External Hyperforge agent"
10
10
  authors = [{ name = "Nuclia", email = "nucliadb@nuclia.com" }]
@@ -94,7 +94,9 @@ class ExternalCallAgent(Agent[ExternalCallAgentConfig]):
94
94
  request = client.build_request(
95
95
  method=self.config.method.value,
96
96
  url=self.config.url,
97
- json=memory.contexts,
97
+ json=[
98
+ context.model_dump(mode="json") for context in memory.contexts
99
+ ],
98
100
  headers=self.config.headers,
99
101
  )
100
102
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyperforge_external
3
- Version: 1.0.0.post90
3
+ Version: 1.0.0.post93
4
4
  Summary: External Hyperforge agent
5
5
  Author-email: Nuclia <nucliadb@nuclia.com>
6
6
  License-Expression: Apache-2.0
@@ -1,10 +1,16 @@
1
+ import json
1
2
  import os
2
- from unittest.mock import AsyncMock
3
+ from types import SimpleNamespace
4
+ from unittest.mock import AsyncMock, MagicMock
3
5
 
4
6
  import httpx
5
7
  import pytest
6
8
  from hyperforge.engine import main as arag_main
7
9
  from hyperforge.minimal_fixtures import cassette_nua_key
10
+ from hyperforge.models import Context
11
+
12
+ from hyperforge_external.agent import ExternalCallAgent
13
+ from hyperforge_external.config import ExternalCallAgentConfig
8
14
 
9
15
  NUA_KEY = os.environ.get(
10
16
  "NUA_KEY",
@@ -66,7 +72,7 @@ async def test_external(mocker):
66
72
  mock_client.__aexit__ = AsyncMock(return_value=None)
67
73
 
68
74
  mocker.patch(
69
- "hyperforge.utils.http.safe_http_client",
75
+ "hyperforge_external.agent.safe_http_client",
70
76
  return_value=mock_client,
71
77
  )
72
78
 
@@ -89,3 +95,48 @@ async def test_external(mocker):
89
95
  or "Peugeot" in question_memory.steps[-2].reason
90
96
  )
91
97
  assert mock_client.send.called
98
+
99
+
100
+ @pytest.mark.asyncio
101
+ async def test_external_with_context_payload(mocker):
102
+ config = ExternalCallAgentConfig(
103
+ context=True,
104
+ url="https://example.com/aaa",
105
+ )
106
+ external_agent = ExternalCallAgent(config)
107
+ memory = SimpleNamespace(
108
+ original_question="Question",
109
+ final_answer="Answer",
110
+ contexts=[
111
+ Context(
112
+ original_question_uuid=None,
113
+ actual_question_uuid=None,
114
+ question="Question",
115
+ source="static",
116
+ agent="static",
117
+ )
118
+ ],
119
+ contexts_minimal=lambda: "Context",
120
+ add_step=AsyncMock(),
121
+ )
122
+
123
+ mock_response = httpx.Response(
124
+ 200,
125
+ content=b"oki doki",
126
+ request=httpx.Request("POST", config.url),
127
+ )
128
+ mock_client = MagicMock()
129
+ mock_client.build_request.side_effect = httpx.Request
130
+ mock_client.send = AsyncMock(return_value=mock_response)
131
+ mock_client.__aenter__ = AsyncMock(return_value=mock_client)
132
+ mock_client.__aexit__ = AsyncMock(return_value=None)
133
+ mocker.patch(
134
+ "hyperforge_external.agent.safe_http_client",
135
+ return_value=mock_client,
136
+ )
137
+
138
+ await external_agent(memory, manager=None)
139
+
140
+ request = mock_client.send.call_args.args[0]
141
+ assert request.headers["content-type"] == "application/json"
142
+ assert json.loads(request.content)[0]["source"] == "static"