Skip to content

Commit

Permalink
checkin progress
Browse files Browse the repository at this point in the history
  • Loading branch information
emrgnt-cmplxty committed Dec 13, 2024
1 parent b7cf5ea commit cf5e3aa
Show file tree
Hide file tree
Showing 129 changed files with 2,617 additions and 5,054 deletions.
9 changes: 2 additions & 7 deletions js/sdk/src/r2rClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1444,13 +1444,11 @@ export class r2rClient extends BaseClient {
@feature("getConversation")
async getConversation(
conversationId: string,
branchId?: string,
): Promise<Record<string, any>> {
this._ensureAuthenticated();
const queryParams = branchId ? `?branch_id=${branchId}` : "";
return this._makeRequest(
"GET",
`get_conversation/${conversationId}${queryParams}`,
`get_conversation/${conversationId}`,
);
}

Expand Down Expand Up @@ -1974,7 +1972,6 @@ export class r2rClient extends BaseClient {
* @param task_prompt_override Task prompt override.
* @param include_title_if_available Include title if available.
* @param conversation_id The ID of the conversation, if not a new conversation.
* @param branch_id The ID of the branch to use, if not a new branch.
* @returns A promise that resolves to the response from the server.
* @deprecated use `client.retrieval.agent` instead
*/
Expand All @@ -1987,7 +1984,6 @@ export class r2rClient extends BaseClient {
task_prompt_override?: string,
include_title_if_available?: boolean,
conversation_id?: string,
branch_id?: string,
): Promise<any | AsyncGenerator<string, void, unknown>> {
this._ensureAuthenticated();

Expand All @@ -1998,8 +1994,7 @@ export class r2rClient extends BaseClient {
rag_generation_config,
task_prompt_override,
include_title_if_available,
conversation_id,
branch_id,
conversation_id
};

Object.keys(json_data).forEach(
Expand Down
12 changes: 0 additions & 12 deletions js/sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,6 @@ export interface MessageResponse {
message: any;
metadata: Record<string, any>;
}

export interface BranchResponse {
branch_id: string;
branch_point_id?: string;
content?: string;
created_at: string;
user_id?: string;
name?: string;
}

// Document types
export interface DocumentResponse {
id: string;
Expand Down Expand Up @@ -344,8 +334,6 @@ export type WrappedMessageResponse = ResultsWrapper<MessageResponse>;
export type WrappedMessagesResponse = PaginatedResultsWrapper<
MessageResponse[]
>;
export type WrappedBranchResponse = ResultsWrapper<BranchResponse>;
export type WrappedBranchesResponse = PaginatedResultsWrapper<BranchResponse[]>;

// Document Responses
export type WrappedDocumentResponse = ResultsWrapper<DocumentResponse>;
Expand Down
26 changes: 0 additions & 26 deletions js/sdk/src/v3/clients/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { feature } from "../../feature";
import { r2rClient } from "../../r2rClient";
import {
WrappedBooleanResponse,
WrappedBranchesResponse,
WrappedConversationMessagesResponse,
WrappedConversationResponse,
WrappedConversationsResponse,
Expand Down Expand Up @@ -136,29 +135,4 @@ export class ConversationsClient {
},
);
}

/**
* List all branches in a conversation.
* @param id The ID of the conversation to list branches for
* @returns
*/
@feature("conversations.listBranches")
async listBranches(options: {
id: string;
offset?: number;
limit?: number;
}): Promise<WrappedBranchesResponse> {
const params: Record<string, any> = {
offset: options?.offset ?? 0,
limit: options?.limit ?? 100,
};

return this.client.makeRequest(
"GET",
`conversations/${options.id}/branches`,
{
params,
},
);
}
}
10 changes: 2 additions & 8 deletions py/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Keep '*' imports for enhanced development velocity
from .agent import *
from .base import *
from .database import *
from .main import *
from .parsers import *
from .pipelines import *
Expand Down Expand Up @@ -105,13 +106,6 @@
## LOGGING
# Basic types
"RunType",
"AnalysisTypes",
"LogAnalytics",
"LogAnalyticsConfig",
"LogFilterCriteria",
"LogProcessor",
# Logging Providers
"PersistentLoggingConfig",
# Run Manager
"RunManager",
"manage_run",
Expand Down Expand Up @@ -223,7 +217,7 @@
"BCryptProvider",
"BCryptConfig",
# Database
"PostgresDBProvider",
"PostgresDatabaseProvider",
# Embeddings
"LiteLLMEmbeddingProvider",
"OpenAIEmbeddingProvider",
Expand Down
9 changes: 4 additions & 5 deletions py/core/agent/rag.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
WebSearchResponse,
)
from core.base.agent import AgentConfig, Tool
from core.base.providers import CompletionProvider
from core.base.providers import CompletionProvider, DatabaseProvider
from core.base.utils import to_async_generator
from core.pipelines import SearchPipeline
from core.providers import (
from core.providers import ( # PostgresDatabaseProvider,
LiteLLMCompletionProvider,
OpenAICompletionProvider,
PostgresDBProvider,
)


Expand Down Expand Up @@ -126,7 +125,7 @@ def format_search_results_for_llm(
class R2RRAGAgent(RAGAgentMixin, R2RAgent):
def __init__(
self,
database_provider: PostgresDBProvider,
database_provider: DatabaseProvider,
llm_provider: Union[
LiteLLMCompletionProvider, OpenAICompletionProvider
],
Expand All @@ -144,7 +143,7 @@ def __init__(
class R2RStreamingRAGAgent(RAGAgentMixin, R2RStreamingAgent):
def __init__(
self,
database_provider: PostgresDBProvider,
database_provider: DatabaseProvider,
llm_provider: Union[
LiteLLMCompletionProvider, OpenAICompletionProvider
],
Expand Down
7 changes: 1 addition & 6 deletions py/core/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@
## LOGGING
# Basic types
"RunType",
"AnalysisTypes",
"LogAnalytics",
"LogAnalyticsConfig",
"LogFilterCriteria",
"LogProcessor",
"PersistentLoggingConfig",
# Run Manager
"RunManager",
"manage_run",
Expand Down Expand Up @@ -114,6 +108,7 @@
# Database providers
"DatabaseConfig",
"DatabaseProvider",
"Handler",
"PostgresConfigurationSettings",
# Embedding provider
"EmbeddingConfig",
Expand Down
6 changes: 3 additions & 3 deletions py/core/base/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(
config: AgentConfig,
):
self.llm_provider = llm_provider
self.database_provider = database_provider
self.database_provider: DatabaseProvider = database_provider
self.config = config
self.conversation = Conversation()
self._completed = False
Expand All @@ -92,7 +92,7 @@ def _register_tools(self):

async def _setup(self, system_instruction: Optional[str] = None):
content = system_instruction or (
await self.database_provider.get_cached_prompt(
await self.database_provider.prompts_handler.get_cached_prompt(
self.config.system_instruction_name
)
)
Expand All @@ -101,7 +101,7 @@ async def _setup(self, system_instruction: Optional[str] = None):
role="system",
content=system_instruction
or (
await self.database_provider.get_cached_prompt(
await self.database_provider.prompts_handler.get_cached_prompt(
self.config.system_instruction_name
)
),
Expand Down
12 changes: 4 additions & 8 deletions py/core/base/api/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from shared.api.models.base import (
GenericBooleanResponse,
GenericMessageResponse,
PaginatedResultsWrapper,
ResultsWrapper,
PaginatedR2RResult,
R2RResults,
WrappedBooleanResponse,
WrappedGenericMessageResponse,
)
Expand Down Expand Up @@ -43,8 +43,6 @@
SettingsResponse,
User,
WrappedAnalyticsResponse,
WrappedBranchesResponse,
WrappedBranchResponse,
WrappedChunkResponse,
WrappedChunksResponse,
WrappedCollectionResponse,
Expand Down Expand Up @@ -133,8 +131,6 @@
# Conversation Responses
"WrappedMessageResponse",
"WrappedMessagesResponse",
"WrappedBranchResponse",
"WrappedBranchesResponse",
# Chunk Responses
"WrappedChunkResponse",
"WrappedChunksResponse",
Expand All @@ -143,8 +139,8 @@
"WrappedUserResponse",
"WrappedUsersResponse",
# Base Responses
"PaginatedResultsWrapper",
"ResultsWrapper",
"PaginatedR2RResult",
"R2RResults",
"GenericBooleanResponse",
"GenericMessageResponse",
"WrappedBooleanResponse",
Expand Down
16 changes: 1 addition & 15 deletions py/core/base/logger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
from .base import PersistentLoggingConfig, RunInfoLog, RunType
from .log_processor import (
AnalysisTypes,
LogAnalytics,
LogAnalyticsConfig,
LogFilterCriteria,
LogProcessor,
)
from .base import RunInfoLog, RunType
from .run_manager import RunManager, manage_run

__all__ = [
# Basic types
"RunType",
"AnalysisTypes",
"LogAnalytics",
"LogAnalyticsConfig",
"LogFilterCriteria",
"LogProcessor",
# Logging Providers
"PersistentLoggingConfig",
"RunInfoLog",
# Run Manager
"RunManager",
Expand Down
56 changes: 0 additions & 56 deletions py/core/base/logger/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,6 @@ class RunInfoLog(BaseModel):
user_id: UUID


class PersistentLoggingConfig(ProviderConfig):
provider: str = "local"
log_table: str = "logs"
log_info_table: str = "log_info"
logging_path: Optional[str] = None

def validate_config(self) -> None:
pass

@property
def supported_providers(self) -> list[str]:
return ["local", "postgres"]


class RunType(str, Enum):
"""Enumeration of the different types of runs."""

Expand All @@ -44,45 +30,3 @@ class RunType(str, Enum):
AUTH = "AUTH"
UNSPECIFIED = "UNSPECIFIED"
KG = "KG"


class PersistentLoggingProvider(Provider):
@abstractmethod
async def close(self):
pass

@abstractmethod
async def log(
self,
run_id: UUID,
key: str,
value: str,
):
pass

@abstractmethod
async def get_logs(
self,
run_ids: list[UUID],
limit_per_run: int,
) -> list:
pass

@abstractmethod
async def info_log(
self,
run_id: UUID,
run_type: RunType,
user_id: UUID,
):
pass

@abstractmethod
async def get_info_logs(
self,
offset: int = 0,
limit: int = 100,
run_type_filter: Optional[RunType] = None,
user_ids: Optional[list[UUID]] = None,
) -> list[RunInfoLog]:
pass
Loading

0 comments on commit cf5e3aa

Please sign in to comment.