Skip to content

Commit 63e072a

Browse files
committed
feat: added agentkit test and update protos
1 parent afcefa1 commit 63e072a

40 files changed

Lines changed: 390 additions & 325 deletions

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,3 @@ pip install --upgrade rapida-python
8686
## Conclusion
8787

8888
The Rapida Python SDK provides everything necessary to integrate seamlessly with Rapida AI services, offering flexible configuration and authentication options. With the examples provided, you should be able to get started quickly and make advanced API calls as needed.
89-

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "rapida-python"
7-
version = "0.1.25"
7+
version = "0.1.26"
88
description = "RapidaAI SDK to integrate rapida.ai APIs"
99
readme = "README.md"
1010
authors = [{name = "RapidaAI", email = "code@rapida.ai"}]
@@ -58,4 +58,4 @@ packages = [
5858
"rapida.clients.protos" = ["*.py"]
5959

6060
[tool.setuptools.exclude-package-data]
61-
"*" = ["tests", "examples"]
61+
"*" = ["tests", "examples"]

rapida/agentkit/__init__.py

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def Talk(self, request_iterator, context):
7272
import os
7373
from concurrent import futures
7474
from dataclasses import dataclass
75-
from typing import Any, Callable, Dict, Iterator, Optional
75+
from typing import Any, Callable, Dict, Optional
7676

7777
import grpc
7878
from grpc import ServerInterceptor
@@ -176,6 +176,7 @@ def abort(ignored_request, context):
176176
context.abort(
177177
grpc.StatusCode.UNAUTHENTICATED, "Invalid authorization token"
178178
)
179+
179180
return grpc.unary_unary_rpc_method_handler(abort)
180181

181182

@@ -223,9 +224,7 @@ def Talk(self, request_iterator, context):
223224
# RESPONSE BUILDERS - Send data back to Rapida
224225
# ========================================================================
225226

226-
def response(
227-
self, code: int = 200, success: bool = True, **kwargs
228-
) -> TalkOutput:
227+
def response(self, code: int = 200, success: bool = True, **kwargs) -> TalkOutput:
229228
"""
230229
Build a generic response to send back to Rapida.
231230
@@ -338,13 +337,12 @@ def tool_call(
338337
for k, v in (args or {}).items():
339338
_args[str(k)] = string_to_any(str(v))
340339

341-
return self.response(tool=ConversationToolCall(
342-
id=str(msg_id),
343-
toolId=str(tool_id),
344-
name=str(name),
345-
args=_args
346-
))
347-
340+
return self.response(
341+
tool=ConversationToolCall(
342+
id=str(msg_id), toolId=str(tool_id), name=str(name), args=_args
343+
)
344+
)
345+
348346
def tool_call_result(
349347
self, msg_id: str, tool_id: str, name: str, result: Any, success: bool = True
350348
) -> TalkOutput:
@@ -373,17 +371,17 @@ def tool_call_result(
373371
# For non-dict results, store under "result" key
374372
_args["result"] = string_to_any(str(result))
375373

376-
return self.response(toolResult=ConversationToolResult(
377-
id=str(msg_id),
378-
toolId=str(tool_id),
379-
name=str(name),
380-
success=bool(success),
381-
args=_args
382-
))
374+
return self.response(
375+
toolResult=ConversationToolResult(
376+
id=str(msg_id),
377+
toolId=str(tool_id),
378+
name=str(name),
379+
success=bool(success),
380+
args=_args,
381+
)
382+
)
383383

384-
def transfer_call(
385-
self, msg_id: str, args: Dict[str, Any]
386-
) -> TalkOutput:
384+
def transfer_call(self, msg_id: str, args: Dict[str, Any]) -> TalkOutput:
387385
"""
388386
Send a transfer call directive back to Rapida.
389387
@@ -399,15 +397,15 @@ def transfer_call(
399397
for k, v in (args or {}).items():
400398
_args[str(k)] = string_to_any(str(v))
401399

402-
return self.response(directive=ConversationDirective(
403-
id=str(msg_id),
404-
type=ConversationDirective.TRANSFER_CONVERSATION,
405-
args=_args
406-
))
400+
return self.response(
401+
directive=ConversationDirective(
402+
id=str(msg_id),
403+
type=ConversationDirective.TRANSFER_CONVERSATION,
404+
args=_args,
405+
)
406+
)
407407

408-
def terminate_call(
409-
self, msg_id: str, args: Dict[str, Any]
410-
) -> TalkOutput:
408+
def terminate_call(self, msg_id: str, args: Dict[str, Any]) -> TalkOutput:
411409
"""
412410
Send a tool call that ends the conversation back to Rapida.
413411
@@ -424,11 +422,12 @@ def terminate_call(
424422
# Set map fields with Any values after construction
425423
for k, v in (args or {}).items():
426424
_arg[str(k)] = string_to_any(str(v))
427-
428-
return self.response(directive=ConversationDirective(
429-
id=str(msg_id),
430-
type=ConversationDirective.END_CONVERSATION,
431-
args=_arg))
425+
426+
return self.response(
427+
directive=ConversationDirective(
428+
id=str(msg_id), type=ConversationDirective.END_CONVERSATION, args=_arg
429+
)
430+
)
432431

433432
# ========================================================================
434433
# REQUEST HELPERS - Receive data from Rapida
@@ -486,7 +485,9 @@ def get_assistant_id(self, request: TalkInput) -> Optional[int]:
486485
Returns:
487486
Assistant ID, or None if not an initialization request or assistant is unset
488487
"""
489-
if request.HasField("initialization") and request.initialization.HasField("assistant"):
488+
if request.HasField("initialization") and request.initialization.HasField(
489+
"assistant"
490+
):
490491
return request.initialization.assistant.assistantId
491492
return None
492493

@@ -504,17 +505,11 @@ def is_message_request(self, request: TalkInput) -> bool:
504505

505506
def is_text_message(self, request: TalkInput) -> bool:
506507
"""Check if request is a text message."""
507-
return (
508-
request.HasField("message")
509-
and request.message.HasField("text")
510-
)
508+
return request.HasField("message") and request.message.HasField("text")
511509

512510
def is_audio_message(self, request: TalkInput) -> bool:
513511
"""Check if request is an audio message."""
514-
return (
515-
request.HasField("message")
516-
and request.message.HasField("audio")
517-
)
512+
return request.HasField("message") and request.message.HasField("audio")
518513

519514

520515
# ============================================================================

rapida/clients/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
# THE SOFTWARE.
2020
#
21-
# Author: Prashant <prashant@rapida.ai>
21+
# Author: Prashant <prashant@rapida.ai>

rapida/clients/protos/agentkit_pb2_grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import rapida.clients.protos.agentkit_pb2 as agentkit__pb2
77

8-
GRPC_GENERATED_VERSION = '1.78.1'
8+
GRPC_GENERATED_VERSION = '1.78.0'
99
GRPC_VERSION = grpc.__version__
1010
_version_not_supported = False
1111

rapida/clients/protos/artifacts

rapida/clients/protos/assistant_analysis_pb2_grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import warnings
55

66

7-
GRPC_GENERATED_VERSION = '1.78.1'
7+
GRPC_GENERATED_VERSION = '1.78.0'
88
GRPC_VERSION = grpc.__version__
99
_version_not_supported = False
1010

rapida/clients/protos/assistant_api_pb2.py

Lines changed: 47 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rapida/clients/protos/assistant_api_pb2.pyi

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,61 @@ class GetAllAssistantTelemetryRequest(_message.Message):
152152
assistant: _common_pb2.AssistantDefinition
153153
def __init__(self, paginate: _Optional[_Union[_common_pb2.Paginate, _Mapping]] = ..., criterias: _Optional[_Iterable[_Union[_common_pb2.Criteria, _Mapping]]] = ..., assistant: _Optional[_Union[_common_pb2.AssistantDefinition, _Mapping]] = ...) -> None: ...
154154

155+
class TelemetryEvent(_message.Message):
156+
__slots__ = ("messageId", "assistantId", "assistantConversationId", "projectId", "organizationId", "name", "data", "time")
157+
class DataEntry(_message.Message):
158+
__slots__ = ("key", "value")
159+
KEY_FIELD_NUMBER: _ClassVar[int]
160+
VALUE_FIELD_NUMBER: _ClassVar[int]
161+
key: str
162+
value: str
163+
def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
164+
MESSAGEID_FIELD_NUMBER: _ClassVar[int]
165+
ASSISTANTID_FIELD_NUMBER: _ClassVar[int]
166+
ASSISTANTCONVERSATIONID_FIELD_NUMBER: _ClassVar[int]
167+
PROJECTID_FIELD_NUMBER: _ClassVar[int]
168+
ORGANIZATIONID_FIELD_NUMBER: _ClassVar[int]
169+
NAME_FIELD_NUMBER: _ClassVar[int]
170+
DATA_FIELD_NUMBER: _ClassVar[int]
171+
TIME_FIELD_NUMBER: _ClassVar[int]
172+
messageId: str
173+
assistantId: int
174+
assistantConversationId: int
175+
projectId: int
176+
organizationId: int
177+
name: str
178+
data: _containers.ScalarMap[str, str]
179+
time: _timestamp_pb2.Timestamp
180+
def __init__(self, messageId: _Optional[str] = ..., assistantId: _Optional[int] = ..., assistantConversationId: _Optional[int] = ..., projectId: _Optional[int] = ..., organizationId: _Optional[int] = ..., name: _Optional[str] = ..., data: _Optional[_Mapping[str, str]] = ..., time: _Optional[_Union[datetime.datetime, _timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ...
181+
182+
class TelemetryMetric(_message.Message):
183+
__slots__ = ("contextId", "assistantId", "assistantConversationId", "projectId", "organizationId", "scope", "metrics", "time")
184+
CONTEXTID_FIELD_NUMBER: _ClassVar[int]
185+
ASSISTANTID_FIELD_NUMBER: _ClassVar[int]
186+
ASSISTANTCONVERSATIONID_FIELD_NUMBER: _ClassVar[int]
187+
PROJECTID_FIELD_NUMBER: _ClassVar[int]
188+
ORGANIZATIONID_FIELD_NUMBER: _ClassVar[int]
189+
SCOPE_FIELD_NUMBER: _ClassVar[int]
190+
METRICS_FIELD_NUMBER: _ClassVar[int]
191+
TIME_FIELD_NUMBER: _ClassVar[int]
192+
contextId: str
193+
assistantId: int
194+
assistantConversationId: int
195+
projectId: int
196+
organizationId: int
197+
scope: str
198+
metrics: _containers.RepeatedCompositeFieldContainer[_common_pb2.Metric]
199+
time: _timestamp_pb2.Timestamp
200+
def __init__(self, contextId: _Optional[str] = ..., assistantId: _Optional[int] = ..., assistantConversationId: _Optional[int] = ..., projectId: _Optional[int] = ..., organizationId: _Optional[int] = ..., scope: _Optional[str] = ..., metrics: _Optional[_Iterable[_Union[_common_pb2.Metric, _Mapping]]] = ..., time: _Optional[_Union[datetime.datetime, _timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ...
201+
202+
class TelemetryRecord(_message.Message):
203+
__slots__ = ("event", "metric")
204+
EVENT_FIELD_NUMBER: _ClassVar[int]
205+
METRIC_FIELD_NUMBER: _ClassVar[int]
206+
event: TelemetryEvent
207+
metric: TelemetryMetric
208+
def __init__(self, event: _Optional[_Union[TelemetryEvent, _Mapping]] = ..., metric: _Optional[_Union[TelemetryMetric, _Mapping]] = ...) -> None: ...
209+
155210
class GetAllAssistantTelemetryResponse(_message.Message):
156211
__slots__ = ("code", "success", "data", "error", "paginated")
157212
CODE_FIELD_NUMBER: _ClassVar[int]
@@ -161,10 +216,10 @@ class GetAllAssistantTelemetryResponse(_message.Message):
161216
PAGINATED_FIELD_NUMBER: _ClassVar[int]
162217
code: int
163218
success: bool
164-
data: _containers.RepeatedCompositeFieldContainer[_common_pb2.Telemetry]
219+
data: _containers.RepeatedCompositeFieldContainer[TelemetryRecord]
165220
error: _common_pb2.Error
166221
paginated: _common_pb2.Paginated
167-
def __init__(self, code: _Optional[int] = ..., success: bool = ..., data: _Optional[_Iterable[_Union[_common_pb2.Telemetry, _Mapping]]] = ..., error: _Optional[_Union[_common_pb2.Error, _Mapping]] = ..., paginated: _Optional[_Union[_common_pb2.Paginated, _Mapping]] = ...) -> None: ...
222+
def __init__(self, code: _Optional[int] = ..., success: bool = ..., data: _Optional[_Iterable[_Union[TelemetryRecord, _Mapping]]] = ..., error: _Optional[_Union[_common_pb2.Error, _Mapping]] = ..., paginated: _Optional[_Union[_common_pb2.Paginated, _Mapping]] = ...) -> None: ...
168223

169224
class GetAllAssistantResponse(_message.Message):
170225
__slots__ = ("code", "success", "data", "error", "paginated")

rapida/clients/protos/assistant_api_pb2_grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import rapida.clients.protos.assistant_webhook_pb2 as assistant__webhook__pb2
1212
import rapida.clients.protos.common_pb2 as common__pb2
1313

14-
GRPC_GENERATED_VERSION = '1.78.1'
14+
GRPC_GENERATED_VERSION = '1.78.0'
1515
GRPC_VERSION = grpc.__version__
1616
_version_not_supported = False
1717

0 commit comments

Comments
 (0)