hyperforge-static 1.0.0.post20__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.
@@ -0,0 +1,3 @@
1
+ from .agent import StaticAgent
2
+
3
+ __all__ = ["StaticAgent"]
@@ -0,0 +1,96 @@
1
+ from time import time
2
+ from typing import Any, ClassVar, Dict, List, Optional, Tuple
3
+ from uuid import uuid4
4
+
5
+ from hyperforge.agent import Agent
6
+ from hyperforge.configure import agent
7
+ from hyperforge.context.agent import ContextAgent
8
+ from hyperforge.definition import FunctionDefinition
9
+ from hyperforge.manager import Manager
10
+ from hyperforge.memory.memory import Chunk, Context, QuestionMemory
11
+
12
+ from hyperforge_static.config import StaticAgentConfig
13
+
14
+
15
+ @agent(
16
+ id="static",
17
+ agent_type="context",
18
+ title="Static Context",
19
+ description="Provide static context to answer questions.",
20
+ config_schema=StaticAgentConfig,
21
+ )
22
+ class StaticAgent(ContextAgent, Agent[StaticAgentConfig]):
23
+ __published_functions__: ClassVar[Dict[str, FunctionDefinition]] = {
24
+ "static_context": FunctionDefinition(
25
+ name="static_context",
26
+ description="Provide static context to answer questions.",
27
+ parameters={},
28
+ )
29
+ }
30
+
31
+ async def static_context(
32
+ self,
33
+ memory: QuestionMemory,
34
+ manager: Manager,
35
+ question: Optional[str] = "",
36
+ question_uuid: Optional[str] = None,
37
+ ) -> Context:
38
+ if question_uuid is None:
39
+ question_uuid = uuid4().hex
40
+
41
+ context = Context(
42
+ agent_id=self.config.id if self.config.id else "static_context",
43
+ original_question_uuid=memory.original_question_uuid,
44
+ actual_question_uuid=question_uuid,
45
+ question=question,
46
+ source="static_context",
47
+ agent="static_context",
48
+ title=self.config.title if self.config.title else "Static Context",
49
+ )
50
+ if self.config.context:
51
+ context.chunks.append(
52
+ Chunk(
53
+ chunk_id=uuid4().hex,
54
+ text=self.config.context,
55
+ origin_agent=self.config.module,
56
+ )
57
+ )
58
+ if self.config.structured:
59
+ context.structured.append(self.config.structured)
60
+ return context
61
+
62
+ async def _get_question_context(
63
+ self,
64
+ memory: QuestionMemory,
65
+ manager: Manager,
66
+ question_uuid: str,
67
+ question: str,
68
+ flow_id: str,
69
+ extra_context: Optional[Dict[str, Any]] = None,
70
+ ) -> List[Tuple[str, str]]:
71
+ t0 = time()
72
+ error = None
73
+
74
+ context = await self.static_context(
75
+ memory=memory,
76
+ manager=manager,
77
+ )
78
+
79
+ await memory.add_step(
80
+ step_module=self.config.module,
81
+ step_title=self.step_title("Static context"),
82
+ step_agent_path=f"/context/{self.config.id if self.config.id else 'default'}",
83
+ step_value=" Static context retrieval",
84
+ timeit=time() - t0,
85
+ input_nuclia_tokens=0,
86
+ output_nuclia_tokens=0,
87
+ error=error,
88
+ )
89
+ missing = await self.save_ctx_and_return_missing(
90
+ context=context,
91
+ question=question,
92
+ memory=memory,
93
+ manager=manager,
94
+ flow_id=flow_id,
95
+ )
96
+ return [missing] if missing is not None else []
@@ -0,0 +1,33 @@
1
+ from typing import Literal, Optional, Tuple
2
+
3
+ from hyperforge.context.config import ContextAgentConfig
4
+ from hyperforge.utils import WidgetType
5
+ from pydantic import Field
6
+ from pydantic.config import ConfigDict
7
+
8
+
9
+ class StaticAgentConfig(ContextAgentConfig):
10
+ model_config = ConfigDict(title="Static data")
11
+ module: Literal["static"] = "static"
12
+ published_functions: Optional[Tuple[str, ...]] = Field(
13
+ default=("static_context",),
14
+ title="Published functions",
15
+ description="List of functions published by this agent to be used by other agents in the chain",
16
+ json_schema_extra={
17
+ "widget": WidgetType.NOT_SHOWN,
18
+ },
19
+ )
20
+ context: Optional[str] = Field(
21
+ None,
22
+ description="Static context to be used by the agent",
23
+ json_schema_extra={
24
+ "widget": WidgetType.EXPANDABLE_TEXTAREA,
25
+ },
26
+ )
27
+ structured: Optional[str] = Field(
28
+ None,
29
+ description="Structured data in JSON format to be used by the agent",
30
+ json_schema_extra={
31
+ "widget": WidgetType.EXPANDABLE_TEXTAREA,
32
+ },
33
+ )
@@ -0,0 +1,19 @@
1
+ Metadata-Version: 2.4
2
+ Name: hyperforge_static
3
+ Version: 1.0.0.post20
4
+ Summary: Static Context Hyperforge agent
5
+ Author-email: Nuclia <nucliadb@nuclia.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://progress.com
8
+ Project-URL: Repository, https://github.com/nuclia/forge
9
+ Classifier: Programming Language :: Python
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Requires-Python: <4,>=3.10
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: hyperforge
18
+
19
+ # Advanced Generation Hyperforge agents
@@ -0,0 +1,7 @@
1
+ hyperforge_static/__init__.py,sha256=2-rDONgRc7X_lQHVpnwTFZ-rzeLwMdstR-0EEBlUhiM,58
2
+ hyperforge_static/agent.py,sha256=TikdRAovoIeRu-UYNLViKYXGNuFCQefuF7cS4ZJ6QSc,3140
3
+ hyperforge_static/config.py,sha256=9T6f2LXQK6qJ_wAUYmyV9GP3eHV7ze-IiS4rOdL8pNE,1116
4
+ hyperforge_static-1.0.0.post20.dist-info/METADATA,sha256=1JzZlw9LoUtb027U_1xU7nzGoVML8aWgDKiL5DzPXy4,743
5
+ hyperforge_static-1.0.0.post20.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
6
+ hyperforge_static-1.0.0.post20.dist-info/top_level.txt,sha256=hYurTUYO8QayDbG8LU9ymAgLSYz8dZMsuyhrr31DI8c,18
7
+ hyperforge_static-1.0.0.post20.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ hyperforge_static