Skip to content

Commit 4c295ef

Browse files
authored
Merge pull request #258 from poissoncorp/RDBC-934
RDBC-934 Sync to 7.1.3
2 parents b4ab23e + 38432e6 commit 4c295ef

24 files changed

+1066
-425
lines changed

ravendb/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,8 @@
8080
# AI Operations
8181
from ravendb.documents.ai import (
8282
AiOperations,
83-
IAiConversationOperations,
8483
AiConversation,
8584
AiConversationResult,
86-
AiAgentParametersBuilder,
87-
IAiAgentParametersBuilder,
8885
)
8986
from ravendb.documents.operations.ai.agents import (
9087
AiAgentConfiguration,
@@ -101,6 +98,7 @@
10198
AiAgentActionRequest,
10299
AiAgentActionResponse,
103100
AiUsage,
101+
AiConversationCreationOptions,
104102
GetAiAgentOperation,
105103
GetAiAgentsResponse,
106104
AddOrUpdateAiAgentOperation,

ravendb/documents/ai/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
from .ai_operations import AiOperations
2-
from .ai_conversation_operations import IAiConversationOperations
32
from .ai_conversation import AiConversation
43
from .ai_conversation_result import AiConversationResult
5-
from .ai_agent_parameters_builder import AiAgentParametersBuilder, IAiAgentParametersBuilder
4+
from .ai_answer import AiAnswer, AiConversationStatus
65

76
__all__ = [
87
"AiOperations",
9-
"IAiConversationOperations",
108
"AiConversation",
119
"AiConversationResult",
12-
"AiAgentParametersBuilder",
13-
"IAiAgentParametersBuilder",
10+
"AiAnswer",
11+
"AiConversationStatus",
1412
]

ravendb/documents/ai/ai_agent_parameters_builder.py

Lines changed: 0 additions & 77 deletions
This file was deleted.

ravendb/documents/ai/ai_answer.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from __future__ import annotations
2+
from typing import Optional, TypeVar, Generic, TYPE_CHECKING
3+
from datetime import timedelta
4+
import enum
5+
6+
if TYPE_CHECKING:
7+
from ravendb.documents.operations.ai.agents import AiUsage
8+
9+
TAnswer = TypeVar("TAnswer")
10+
11+
12+
class AiConversationStatus(enum.Enum):
13+
"""
14+
Represents the status of an AI conversation.
15+
"""
16+
17+
DONE = "Done"
18+
ACTION_REQUIRED = "ActionRequired"
19+
20+
def __str__(self):
21+
return self.value
22+
23+
24+
class AiAnswer(Generic[TAnswer]):
25+
"""
26+
Represents the answer from an AI conversation turn.
27+
28+
This class contains the AI's response, the conversation status,
29+
token usage statistics, and timing information.
30+
"""
31+
32+
def __init__(
33+
self,
34+
answer: Optional[TAnswer] = None,
35+
status: AiConversationStatus = AiConversationStatus.DONE,
36+
usage: Optional[AiUsage] = None,
37+
elapsed: Optional[timedelta] = None,
38+
):
39+
"""
40+
Initialize an AiAnswer instance.
41+
42+
Args:
43+
answer: The answer content produced by the AI
44+
status: The status of the conversation (Done or ActionRequired)
45+
usage: Token usage reported by the model
46+
elapsed: The total time elapsed to produce the answer
47+
"""
48+
self.answer = answer
49+
self.status = status
50+
self.usage = usage
51+
self.elapsed = elapsed
52+
53+
def __str__(self) -> str:
54+
"""String representation for debugging."""
55+
return (
56+
f"AiAnswer(status={self.status.value}, "
57+
f"has_answer={self.answer is not None}, "
58+
f"elapsed={self.elapsed})"
59+
)
60+
61+
def __repr__(self) -> str:
62+
"""Detailed representation for debugging."""
63+
return (
64+
f"AiAnswer(answer={self.answer!r}, "
65+
f"status={self.status!r}, "
66+
f"usage={self.usage!r}, "
67+
f"elapsed={self.elapsed!r})"
68+
)

0 commit comments

Comments
 (0)