nora-lib-impl 1.0.0__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 (31) hide show
  1. nora_lib_impl-1.0.0/PKG-INFO +20 -0
  2. nora_lib_impl-1.0.0/README.md +14 -0
  3. nora_lib_impl-1.0.0/pyproject.toml +3 -0
  4. nora_lib_impl-1.0.0/setup.cfg +4 -0
  5. nora_lib_impl-1.0.0/setup.py +26 -0
  6. nora_lib_impl-1.0.0/src/nora_lib/__init__.py +0 -0
  7. nora_lib_impl-1.0.0/src/nora_lib/impl/__init__.py +0 -0
  8. nora_lib_impl-1.0.0/src/nora_lib/impl/context/__init__.py +0 -0
  9. nora_lib_impl-1.0.0/src/nora_lib/impl/context/agent_context.py +43 -0
  10. nora_lib_impl-1.0.0/src/nora_lib/impl/context/context_service.py +33 -0
  11. nora_lib_impl-1.0.0/src/nora_lib/impl/context/models.py +11 -0
  12. nora_lib_impl-1.0.0/src/nora_lib/impl/interactions/__init__.py +0 -0
  13. nora_lib_impl-1.0.0/src/nora_lib/impl/interactions/interactions_service.py +561 -0
  14. nora_lib_impl-1.0.0/src/nora_lib/impl/interactions/models.py +414 -0
  15. nora_lib_impl-1.0.0/src/nora_lib/impl/interactions/step_progress.py +69 -0
  16. nora_lib_impl-1.0.0/src/nora_lib/impl/pubsub.py +140 -0
  17. nora_lib_impl-1.0.0/src/nora_lib/impl/tasks/__init__.py +0 -0
  18. nora_lib_impl-1.0.0/src/nora_lib/impl/tasks/state.py +156 -0
  19. nora_lib_impl-1.0.0/src/nora_lib/progress/__init__.py +0 -0
  20. nora_lib_impl-1.0.0/src/nora_lib/progress/models.py +47 -0
  21. nora_lib_impl-1.0.0/src/nora_lib/progress/reporter.py +122 -0
  22. nora_lib_impl-1.0.0/src/nora_lib/py.typed +0 -0
  23. nora_lib_impl-1.0.0/src/nora_lib/serializers.py +10 -0
  24. nora_lib_impl-1.0.0/src/nora_lib/tasks/__init__.py +0 -0
  25. nora_lib_impl-1.0.0/src/nora_lib/tasks/models.py +25 -0
  26. nora_lib_impl-1.0.0/src/nora_lib/tasks/state.py +71 -0
  27. nora_lib_impl-1.0.0/src/nora_lib_impl.egg-info/PKG-INFO +20 -0
  28. nora_lib_impl-1.0.0/src/nora_lib_impl.egg-info/SOURCES.txt +29 -0
  29. nora_lib_impl-1.0.0/src/nora_lib_impl.egg-info/dependency_links.txt +1 -0
  30. nora_lib_impl-1.0.0/src/nora_lib_impl.egg-info/requires.txt +10 -0
  31. nora_lib_impl-1.0.0/src/nora_lib_impl.egg-info/top_level.txt +1 -0
@@ -0,0 +1,20 @@
1
+ Metadata-Version: 2.2
2
+ Name: nora_lib-impl
3
+ Version: 1.0.0
4
+ Summary: For making and coordinating agents and tools
5
+ Home-page: https://github.com/allenai/nora_lib/impl
6
+ Requires-Python: >=3.9
7
+ Requires-Dist: pydantic<3,>=2
8
+ Requires-Dist: requests
9
+ Requires-Dist: boto3
10
+ Requires-Dist: aws_requests_auth
11
+ Provides-Extra: dev
12
+ Requires-Dist: mypy; extra == "dev"
13
+ Requires-Dist: pytest; extra == "dev"
14
+ Requires-Dist: black; extra == "dev"
15
+ Requires-Dist: types-requests; extra == "dev"
16
+ Dynamic: home-page
17
+ Dynamic: provides-extra
18
+ Dynamic: requires-dist
19
+ Dynamic: requires-python
20
+ Dynamic: summary
@@ -0,0 +1,14 @@
1
+ #nora_lib impl
2
+
3
+ Contains implementations of `nora_lib` interfaces using the Nora platform
4
+
5
+ Publishes the `nora_lib-impl` package
6
+
7
+ # Development
8
+
9
+ Verify changes using
10
+
11
+ ```
12
+ make verify
13
+ ```
14
+
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools", "wheel"]
3
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,26 @@
1
+ import os
2
+ import setuptools
3
+
4
+ runtime_requirements = ["pydantic>=2,<3", "requests", "boto3", "aws_requests_auth"]
5
+
6
+ # For running tests, linting, etc
7
+ dev_requirements = ["mypy", "pytest", "black", "types-requests"]
8
+
9
+ version = os.environ["NORA_LIB_VERSION"]
10
+
11
+ setuptools.setup(
12
+ name="nora_lib-impl",
13
+ version=version,
14
+ description="For making and coordinating agents and tools",
15
+ url="https://github.com/allenai/nora_lib/impl",
16
+ package_dir={"": "src"},
17
+ packages=setuptools.find_packages(where="src", include=["nora_lib*"],),
18
+ install_requires=runtime_requirements,
19
+ package_data={
20
+ "nora_lib": ["py.typed"],
21
+ },
22
+ extras_require={
23
+ "dev": dev_requirements,
24
+ },
25
+ python_requires=">=3.9",
26
+ )
File without changes
File without changes
@@ -0,0 +1,43 @@
1
+ from typing import Optional
2
+
3
+ from nora_lib.impl.interactions.models import Surface
4
+ from pydantic import BaseModel
5
+
6
+
7
+ class MessageAgentContext(BaseModel):
8
+ """
9
+ Identifiers for the triggering user message
10
+ """
11
+
12
+ message_id: str
13
+ thread_id: str
14
+ channel_id: str
15
+ surface: Surface
16
+
17
+
18
+ class PubsubAgentContext(BaseModel):
19
+ """
20
+ The pubsub namespace in which the Handler is running
21
+ """
22
+
23
+ base_url: str
24
+ namespace: str
25
+
26
+
27
+ class ToolConfigAgentContext(BaseModel):
28
+ """
29
+ The name of the tool config being used by the handler (dev, prod, demo, etc.)
30
+ """
31
+
32
+ env: str
33
+
34
+
35
+ class AgentContext(BaseModel):
36
+ """
37
+ Information that needs to be passed from the Handler to tool agents
38
+ """
39
+
40
+ message: MessageAgentContext
41
+ pubsub: PubsubAgentContext
42
+ tool_config: ToolConfigAgentContext
43
+ step_id: Optional[str] = None
@@ -0,0 +1,33 @@
1
+ from typing import Optional
2
+
3
+ from nora_lib.impl.interactions.interactions_service import InteractionsService
4
+ from nora_lib.impl.interactions.models import ReturnedMessage
5
+
6
+
7
+ class ContextService:
8
+ """
9
+ Save and retrieve task agent context from interaction store
10
+ """
11
+
12
+ def __init__(
13
+ self,
14
+ agent_actor_id: str, # uuid representing this agent in interaction store
15
+ interactions_base_url: str,
16
+ interactions_bearer_token: Optional[str],
17
+ timeout: int = 30,
18
+ ):
19
+ # If no config is provided, load the configuration based on the environment
20
+ self.interactions_service = self._get_interactions_service(
21
+ interactions_base_url, interactions_bearer_token, timeout
22
+ )
23
+ self.agent_actor_id = agent_actor_id
24
+
25
+ def _get_interactions_service(self, url, token, timeout) -> InteractionsService:
26
+ return InteractionsService(url, timeout, token)
27
+
28
+ def get_message(self, message_id: str) -> str:
29
+ message: ReturnedMessage = self.interactions_service.get_message(message_id)
30
+ if message.annotated_text:
31
+ return message.annotated_text
32
+ else:
33
+ return message.text
@@ -0,0 +1,11 @@
1
+ from typing import Optional
2
+ from pydantic import BaseModel, Field
3
+
4
+
5
+ class WrappedTaskObject(BaseModel):
6
+ """Encloses request or response object with additional metadata"""
7
+
8
+ message_id: str = Field(
9
+ description="id of originating message; key for istore retrieval"
10
+ )
11
+ data: dict = Field(description="Tool-defined request or response")