nora-lib 0.0.5.dev1__tar.gz → 0.0.5.dev3__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.
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/PKG-INFO +1 -1
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/nora_lib/interactions/interactions_service.py +13 -1
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/nora_lib/interactions/models.py +17 -5
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/nora_lib.egg-info/PKG-INFO +1 -1
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/setup.py +1 -1
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/README.md +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/nora_lib/__init__.py +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/nora_lib/context/__init__.py +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/nora_lib/context/context_service.py +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/nora_lib/context/models.py +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/nora_lib/interactions/__init__.py +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/nora_lib/py.typed +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/nora_lib/tasks/__init__.py +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/nora_lib/tasks/models.py +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/nora_lib/tasks/state.py +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/nora_lib.egg-info/SOURCES.txt +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/nora_lib.egg-info/dependency_links.txt +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/nora_lib.egg-info/requires.txt +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/nora_lib.egg-info/top_level.txt +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/pyproject.toml +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/setup.cfg +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/tests/tasks/__init__.py +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/tests/tasks/test_state.py +0 -0
- {nora_lib-0.0.5.dev1 → nora_lib-0.0.5.dev3}/tests/test_placeholder.py +0 -0
|
@@ -4,6 +4,7 @@ import requests
|
|
|
4
4
|
from typing import List, Optional
|
|
5
5
|
|
|
6
6
|
from nora_lib.interactions.models import (
|
|
7
|
+
AnnotationBatch,
|
|
7
8
|
Event,
|
|
8
9
|
EventType,
|
|
9
10
|
Message,
|
|
@@ -45,6 +46,17 @@ class InteractionsService:
|
|
|
45
46
|
)
|
|
46
47
|
response.raise_for_status()
|
|
47
48
|
|
|
49
|
+
def save_annotation(self, annotation: AnnotationBatch) -> None:
|
|
50
|
+
"""Save an annotation to the Interactions API"""
|
|
51
|
+
annotation_url = f"{self.base_url}/interaction/v1/annotation"
|
|
52
|
+
response = requests.post(
|
|
53
|
+
annotation_url,
|
|
54
|
+
json=annotation.model_dump(),
|
|
55
|
+
headers=self.headers,
|
|
56
|
+
timeout=int(self.timeout),
|
|
57
|
+
)
|
|
58
|
+
response.raise_for_status()
|
|
59
|
+
|
|
48
60
|
def get_message(self, message_id: str) -> ReturnedMessage:
|
|
49
61
|
"""Fetch a message from the Interactions API"""
|
|
50
62
|
message_url = f"{self.base_url}/interaction/v1/search/message"
|
|
@@ -118,7 +130,7 @@ class InteractionsService:
|
|
|
118
130
|
e,
|
|
119
131
|
)
|
|
120
132
|
|
|
121
|
-
messages_with_events.sort(key=lambda x:
|
|
133
|
+
messages_with_events.sort(key=lambda x: x.ts)
|
|
122
134
|
return messages_with_events
|
|
123
135
|
|
|
124
136
|
def fetch_thread_messages_and_events_for_message(
|
|
@@ -25,6 +25,16 @@ class Annotation(BaseModel):
|
|
|
25
25
|
attributes: Optional[Dict[str, str]] = None
|
|
26
26
|
|
|
27
27
|
|
|
28
|
+
class AnnotationBatch(BaseModel):
|
|
29
|
+
actor_id: UUID
|
|
30
|
+
message_id: str
|
|
31
|
+
annotations: List[Annotation]
|
|
32
|
+
|
|
33
|
+
@field_serializer("actor_id")
|
|
34
|
+
def serialize_actor_id(self, actor_id: UUID):
|
|
35
|
+
return str(actor_id)
|
|
36
|
+
|
|
37
|
+
|
|
28
38
|
class Message(BaseModel):
|
|
29
39
|
message_id: str
|
|
30
40
|
actor_id: UUID
|
|
@@ -48,7 +58,9 @@ class EventType(str, Enum):
|
|
|
48
58
|
"""Event types for the interactions service"""
|
|
49
59
|
|
|
50
60
|
AGENT_CONTEXT = "agent:message_context"
|
|
61
|
+
S2_ANNOTATION = "s2_annotation"
|
|
51
62
|
THREAD_FORK = "thread_fork"
|
|
63
|
+
UI_INTERACTION = "ui_interaction"
|
|
52
64
|
|
|
53
65
|
|
|
54
66
|
class Event(BaseModel):
|
|
@@ -78,9 +90,9 @@ class ReturnedMessage(BaseModel):
|
|
|
78
90
|
"""Message format returned by interaction service"""
|
|
79
91
|
|
|
80
92
|
message_id: str
|
|
81
|
-
actor_id:
|
|
93
|
+
actor_id: UUID
|
|
82
94
|
text: str
|
|
83
|
-
ts:
|
|
95
|
+
ts: datetime
|
|
84
96
|
annotated_text: Optional[str] = None
|
|
85
97
|
events: List[Event] = Field(default_factory=list)
|
|
86
98
|
thread_id: Optional[str] = None
|
|
@@ -101,8 +113,8 @@ class AgentMessageData(BaseModel):
|
|
|
101
113
|
class ReturnedAgentContextEvent(BaseModel):
|
|
102
114
|
"""Event format returned by interaction service for agent context events"""
|
|
103
115
|
|
|
104
|
-
actor_id:
|
|
105
|
-
timestamp:
|
|
116
|
+
actor_id: UUID # agent that saved this context
|
|
117
|
+
timestamp: datetime
|
|
106
118
|
data: AgentMessageData
|
|
107
119
|
type: str
|
|
108
120
|
|
|
@@ -111,7 +123,7 @@ class ReturnedAgentContextMessage(BaseModel):
|
|
|
111
123
|
"""Message format returned by interaction service for search by thread"""
|
|
112
124
|
|
|
113
125
|
message_id: str
|
|
114
|
-
actor_id:
|
|
126
|
+
actor_id: UUID
|
|
115
127
|
text: str
|
|
116
128
|
ts: str
|
|
117
129
|
annotated_text: Optional[str] = None
|
|
@@ -7,7 +7,7 @@ dev_requirements = ["mypy", "pytest", "black", "types-requests"]
|
|
|
7
7
|
|
|
8
8
|
setuptools.setup(
|
|
9
9
|
name="nora_lib",
|
|
10
|
-
version="0.0.5.
|
|
10
|
+
version="0.0.5.dev3",
|
|
11
11
|
description="For making and coordinating agents and tools",
|
|
12
12
|
url="https://github.com/allenai/nora_lib",
|
|
13
13
|
packages=setuptools.find_packages(exclude=(["tests"])),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|