quraite 0.0.2__py3-none-any.whl → 0.1.0__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.
Files changed (48) hide show
  1. quraite/__init__.py +3 -3
  2. quraite/adapters/__init__.py +134 -134
  3. quraite/adapters/agno_adapter.py +159 -159
  4. quraite/adapters/base.py +123 -123
  5. quraite/adapters/bedrock_agents_adapter.py +343 -343
  6. quraite/adapters/flowise_adapter.py +275 -275
  7. quraite/adapters/google_adk_adapter.py +209 -209
  8. quraite/adapters/http_adapter.py +239 -239
  9. quraite/adapters/langflow_adapter.py +192 -192
  10. quraite/adapters/langgraph_adapter.py +304 -304
  11. quraite/adapters/langgraph_server_adapter.py +252 -252
  12. quraite/adapters/n8n_adapter.py +220 -220
  13. quraite/adapters/openai_agents_adapter.py +269 -269
  14. quraite/adapters/pydantic_ai_adapter.py +312 -312
  15. quraite/adapters/smolagents_adapter.py +152 -152
  16. quraite/logger.py +61 -64
  17. quraite/schema/message.py +91 -54
  18. quraite/schema/response.py +16 -16
  19. quraite/serve/__init__.py +1 -1
  20. quraite/serve/cloudflared.py +210 -210
  21. quraite/serve/local_agent.py +360 -360
  22. quraite/tracing/__init__.py +24 -24
  23. quraite/tracing/constants.py +16 -16
  24. quraite/tracing/span_exporter.py +115 -115
  25. quraite/tracing/span_processor.py +49 -49
  26. quraite/tracing/tool_extractors.py +290 -290
  27. quraite/tracing/trace.py +564 -494
  28. quraite/tracing/types.py +179 -179
  29. quraite/tracing/utils.py +170 -170
  30. quraite/utils/json_utils.py +269 -269
  31. {quraite-0.0.2.dist-info → quraite-0.1.0.dist-info}/METADATA +9 -9
  32. quraite-0.1.0.dist-info/RECORD +35 -0
  33. {quraite-0.0.2.dist-info → quraite-0.1.0.dist-info}/WHEEL +1 -1
  34. quraite/traces/traces_adk_openinference.json +0 -379
  35. quraite/traces/traces_agno_multi_agent.json +0 -669
  36. quraite/traces/traces_agno_openinference.json +0 -321
  37. quraite/traces/traces_crewai_openinference.json +0 -155
  38. quraite/traces/traces_langgraph_openinference.json +0 -349
  39. quraite/traces/traces_langgraph_openinference_multi_agent.json +0 -2705
  40. quraite/traces/traces_langgraph_traceloop.json +0 -510
  41. quraite/traces/traces_openai_agents_multi_agent_1.json +0 -402
  42. quraite/traces/traces_openai_agents_openinference.json +0 -341
  43. quraite/traces/traces_pydantic_openinference.json +0 -286
  44. quraite/traces/traces_pydantic_openinference_multi_agent_1.json +0 -399
  45. quraite/traces/traces_pydantic_openinference_multi_agent_2.json +0 -398
  46. quraite/traces/traces_smol_agents_openinference.json +0 -397
  47. quraite/traces/traces_smol_agents_tool_calling_openinference.json +0 -704
  48. quraite-0.0.2.dist-info/RECORD +0 -49
quraite/adapters/base.py CHANGED
@@ -1,123 +1,123 @@
1
- from abc import ABC, abstractmethod
2
- from typing import Any, List, Optional, Union
3
-
4
- from opentelemetry.trace import TracerProvider
5
-
6
- from quraite.schema.message import AgentMessage, AssistantMessage, MessageContentText
7
- from quraite.schema.response import AgentInvocationResponse
8
- from quraite.tracing.constants import QURAITE_TRACER_NAME
9
- from quraite.tracing.span_exporter import QuraiteInMemorySpanExporter
10
- from quraite.tracing.span_processor import QuraiteSimpleSpanProcessor
11
-
12
-
13
- class BaseAdapter(ABC):
14
- """
15
- Abstract base class for all adapter providers.
16
-
17
- Subclasses must implement the asynchronous adapter method,
18
- which take List[Message] and return agent Message outputs.
19
-
20
- Methods:
21
- ainvoke: Asynchronously invoke an agent call for the provided input.
22
- """
23
-
24
- tracer_provider: Optional[TracerProvider] = None
25
- tracer: Optional[Any] = None
26
- quraite_span_exporter: Optional[QuraiteInMemorySpanExporter] = None
27
-
28
- def _init_tracing(
29
- self,
30
- tracer_provider: Optional[TracerProvider],
31
- required: bool = False,
32
- ) -> None:
33
- """
34
- Initialize tracing components from a TracerProvider.
35
-
36
- Args:
37
- tracer_provider: TracerProvider for tracing
38
- span_exporter: SpanExporter for exporting spans
39
- required: If True, raises ValueError when tracer_provider is None
40
- """
41
- if tracer_provider is None:
42
- if required:
43
- raise ValueError(
44
- "tracer_provider is required. "
45
- "Please provide a TracerProvider instance."
46
- )
47
- return
48
-
49
- self.tracer_provider = tracer_provider
50
- self.tracer = tracer_provider.get_tracer(QURAITE_TRACER_NAME)
51
-
52
- # Find Quraite span exporter
53
- quraite_span_exporter = next(
54
- (
55
- processor.span_exporter
56
- for processor in tracer_provider._active_span_processor._span_processors
57
- if isinstance(processor, QuraiteSimpleSpanProcessor)
58
- ),
59
- None,
60
- )
61
-
62
- if quraite_span_exporter is None:
63
- raise ValueError(
64
- "Quraite span exporter not found. "
65
- "Please ensure QuraiteSimpleSpanProcessor is used in the tracer provider."
66
- )
67
-
68
- self.quraite_span_exporter = quraite_span_exporter
69
-
70
- @abstractmethod
71
- async def ainvoke(
72
- self,
73
- input: List[AgentMessage],
74
- session_id: Union[str, None],
75
- ) -> AgentInvocationResponse:
76
- """
77
- Asynchronously invoke the agent with the given input.
78
-
79
- Args:
80
- input (List[AgentMessage]): List of AgentMessage objects.
81
- session_id (str or None): ID for conversation thread/context.
82
-
83
- Returns:
84
- AgentInvocationResponse: Response containing agent trace, trajectory, and final response.
85
-
86
- Raises:
87
- NotImplementedError: If not implemented by subclass.
88
- """
89
- raise NotImplementedError("Not implemented")
90
-
91
-
92
- class DummyAdapter(BaseAdapter):
93
- """
94
- A dummy implementation of BaseAdapter, used mainly for testing and scaffolding.
95
- Always returns a fixed dummy response.
96
-
97
- Methods:
98
- ainvoke: Returns a static assistant message asynchronously.
99
- """
100
-
101
- async def ainvoke(
102
- self,
103
- input: Any,
104
- session_id: Union[str, None],
105
- ) -> AgentInvocationResponse:
106
- """
107
- Asynchronously returns a dummy assistant response.
108
-
109
- Args:
110
- input: Ignored.
111
- session_id: Ignored.
112
-
113
- Returns:
114
- AgentInvocationResponse: Response containing agent trace, trajectory, and final response.
115
- """
116
-
117
- return AgentInvocationResponse(
118
- agent_trajectory=[
119
- AssistantMessage(
120
- content=[MessageContentText(text="Dummy response")],
121
- )
122
- ]
123
- )
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any, List, Optional, Union
3
+
4
+ from opentelemetry.trace import TracerProvider
5
+
6
+ from quraite.schema.message import AgentMessage, AssistantMessage, MessageContentText
7
+ from quraite.schema.response import AgentInvocationResponse
8
+ from quraite.tracing.constants import QURAITE_TRACER_NAME
9
+ from quraite.tracing.span_exporter import QuraiteInMemorySpanExporter
10
+ from quraite.tracing.span_processor import QuraiteSimpleSpanProcessor
11
+
12
+
13
+ class BaseAdapter(ABC):
14
+ """
15
+ Abstract base class for all adapter providers.
16
+
17
+ Subclasses must implement the asynchronous adapter method,
18
+ which take List[Message] and return agent Message outputs.
19
+
20
+ Methods:
21
+ ainvoke: Asynchronously invoke an agent call for the provided input.
22
+ """
23
+
24
+ tracer_provider: Optional[TracerProvider] = None
25
+ tracer: Optional[Any] = None
26
+ quraite_span_exporter: Optional[QuraiteInMemorySpanExporter] = None
27
+
28
+ def _init_tracing(
29
+ self,
30
+ tracer_provider: Optional[TracerProvider],
31
+ required: bool = False,
32
+ ) -> None:
33
+ """
34
+ Initialize tracing components from a TracerProvider.
35
+
36
+ Args:
37
+ tracer_provider: TracerProvider for tracing
38
+ span_exporter: SpanExporter for exporting spans
39
+ required: If True, raises ValueError when tracer_provider is None
40
+ """
41
+ if tracer_provider is None:
42
+ if required:
43
+ raise ValueError(
44
+ "tracer_provider is required. "
45
+ "Please provide a TracerProvider instance."
46
+ )
47
+ return
48
+
49
+ self.tracer_provider = tracer_provider
50
+ self.tracer = tracer_provider.get_tracer(QURAITE_TRACER_NAME)
51
+
52
+ # Find Quraite span exporter
53
+ quraite_span_exporter = next(
54
+ (
55
+ processor.span_exporter
56
+ for processor in tracer_provider._active_span_processor._span_processors
57
+ if isinstance(processor, QuraiteSimpleSpanProcessor)
58
+ ),
59
+ None,
60
+ )
61
+
62
+ if quraite_span_exporter is None:
63
+ raise ValueError(
64
+ "Quraite span exporter not found. "
65
+ "Please ensure QuraiteSimpleSpanProcessor is used in the tracer provider."
66
+ )
67
+
68
+ self.quraite_span_exporter = quraite_span_exporter
69
+
70
+ @abstractmethod
71
+ async def ainvoke(
72
+ self,
73
+ input: List[AgentMessage],
74
+ session_id: Union[str, None],
75
+ ) -> AgentInvocationResponse:
76
+ """
77
+ Asynchronously invoke the agent with the given input.
78
+
79
+ Args:
80
+ input (List[AgentMessage]): List of AgentMessage objects.
81
+ session_id (str or None): ID for conversation thread/context.
82
+
83
+ Returns:
84
+ AgentInvocationResponse: Response containing agent trace, trajectory, and final response.
85
+
86
+ Raises:
87
+ NotImplementedError: If not implemented by subclass.
88
+ """
89
+ raise NotImplementedError("Not implemented")
90
+
91
+
92
+ class DummyAdapter(BaseAdapter):
93
+ """
94
+ A dummy implementation of BaseAdapter, used mainly for testing and scaffolding.
95
+ Always returns a fixed dummy response.
96
+
97
+ Methods:
98
+ ainvoke: Returns a static assistant message asynchronously.
99
+ """
100
+
101
+ async def ainvoke(
102
+ self,
103
+ input: Any,
104
+ session_id: Union[str, None],
105
+ ) -> AgentInvocationResponse:
106
+ """
107
+ Asynchronously returns a dummy assistant response.
108
+
109
+ Args:
110
+ input: Ignored.
111
+ session_id: Ignored.
112
+
113
+ Returns:
114
+ AgentInvocationResponse: Response containing agent trace, trajectory, and final response.
115
+ """
116
+
117
+ return AgentInvocationResponse(
118
+ agent_trajectory=[
119
+ AssistantMessage(
120
+ content=[MessageContentText(text="Dummy response")],
121
+ )
122
+ ]
123
+ )