Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions ravendb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,8 @@
# AI Operations
from ravendb.documents.ai import (
AiOperations,
IAiConversationOperations,
AiConversation,
AiConversationResult,
AiAgentParametersBuilder,
IAiAgentParametersBuilder,
)
from ravendb.documents.operations.ai.agents import (
AiAgentConfiguration,
Expand All @@ -101,6 +98,7 @@
AiAgentActionRequest,
AiAgentActionResponse,
AiUsage,
AiConversationCreationOptions,
GetAiAgentOperation,
GetAiAgentsResponse,
AddOrUpdateAiAgentOperation,
Expand Down
8 changes: 3 additions & 5 deletions ravendb/documents/ai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from .ai_operations import AiOperations
from .ai_conversation_operations import IAiConversationOperations
from .ai_conversation import AiConversation
from .ai_conversation_result import AiConversationResult
from .ai_agent_parameters_builder import AiAgentParametersBuilder, IAiAgentParametersBuilder
from .ai_answer import AiAnswer, AiConversationStatus

__all__ = [
"AiOperations",
"IAiConversationOperations",
"AiConversation",
"AiConversationResult",
"AiAgentParametersBuilder",
"IAiAgentParametersBuilder",
"AiAnswer",
"AiConversationStatus",
]
77 changes: 0 additions & 77 deletions ravendb/documents/ai/ai_agent_parameters_builder.py

This file was deleted.

68 changes: 68 additions & 0 deletions ravendb/documents/ai/ai_answer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from __future__ import annotations
from typing import Optional, TypeVar, Generic, TYPE_CHECKING
from datetime import timedelta
import enum

if TYPE_CHECKING:
from ravendb.documents.operations.ai.agents import AiUsage

TAnswer = TypeVar("TAnswer")


class AiConversationStatus(enum.Enum):
"""
Represents the status of an AI conversation.
"""

DONE = "Done"
ACTION_REQUIRED = "ActionRequired"

def __str__(self):
return self.value


class AiAnswer(Generic[TAnswer]):
"""
Represents the answer from an AI conversation turn.

This class contains the AI's response, the conversation status,
token usage statistics, and timing information.
"""

def __init__(
self,
answer: Optional[TAnswer] = None,
status: AiConversationStatus = AiConversationStatus.DONE,
usage: Optional[AiUsage] = None,
elapsed: Optional[timedelta] = None,
):
"""
Initialize an AiAnswer instance.

Args:
answer: The answer content produced by the AI
status: The status of the conversation (Done or ActionRequired)
usage: Token usage reported by the model
elapsed: The total time elapsed to produce the answer
"""
self.answer = answer
self.status = status
self.usage = usage
self.elapsed = elapsed

def __str__(self) -> str:
"""String representation for debugging."""
return (
f"AiAnswer(status={self.status.value}, "
f"has_answer={self.answer is not None}, "
f"elapsed={self.elapsed})"
)

def __repr__(self) -> str:
"""Detailed representation for debugging."""
return (
f"AiAnswer(answer={self.answer!r}, "
f"status={self.status!r}, "
f"usage={self.usage!r}, "
f"elapsed={self.elapsed!r})"
)
Loading