Service

This module contains functionality related to the the service module for augmentation.chainlit.

Service

ChainlitService

Bases: BaseDataLayer

Data layer implementation for Chainlit integration with Langfuse.

Handles persistence of feedback and dataset management through Langfuse.

Attributes:
  • manual_dataset

    Configuration for manual dataset in Langfuse.

  • feedback_service

    Service handling Chainlit feedback persistence.

Source code in src/augmentation/chainlit/service.py
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
class ChainlitService(BaseDataLayer):
    """Data layer implementation for Chainlit integration with Langfuse.

    Handles persistence of feedback and dataset management through Langfuse.

    Attributes:
        manual_dataset: Configuration for manual dataset in Langfuse.
        feedback_service: Service handling Chainlit feedback persistence.
    """

    def __init__(
        self,
        langfuse_dataset_service: LangfuseDatasetService,
        feedback_service: ChainlitFeedbackService,
        manual_dataset: LangfuseDatasetConfiguration,
    ):
        """Initialize the Chainlit service.

        Args:
            langfuse_dataset_service: Service for managing Langfuse datasets.
            feedback_service: Service handling Chainlit feedback.
            manual_dataset: Configuration for manual dataset.
        """
        self.manual_dataset = manual_dataset
        self.feedback_service = feedback_service

        langfuse_dataset_service.create_if_does_not_exist(self.manual_dataset)

    async def upsert_feedback(self, feedback: Feedback) -> bool:
        """Upsert Chainlit feedback to Langfuse database.

        Args:
            feedback: Feedback object containing user feedback details.

        Returns:
            bool: True if feedback was successfully upserted, False otherwise.
        """
        return await self.feedback_service.upsert(feedback)

    async def build_debug_url(self, *args, **kwargs):
        """Build a debug URL. Placeholder implementation."""
        pass

    async def create_element(self, *args, **kwargs):
        """Create an element. Placeholder implementation."""
        pass

    async def create_step(self, *args, **kwargs):
        """Create a step. Placeholder implementation."""
        pass

    async def create_user(self, *args, **kwargs):
        """Create a user. Placeholder implementation."""
        pass

    async def delete_element(self, *args, **kwargs):
        """Delete an element. Placeholder implementation."""
        pass

    async def delete_feedback(self, *args, **kwargs):
        """Delete feedback. Placeholder implementation."""
        pass

    async def delete_step(self, *args, **kwargs):
        """Delete a step. Placeholder implementation."""
        pass

    async def delete_thread(self, *args, **kwargs):
        """Delete a thread. Placeholder implementation."""
        pass

    async def get_element(self, *args, **kwargs):
        """Get an element. Placeholder implementation."""
        pass

    async def get_thread(self, *args, **kwargs):
        """Get a thread. Placeholder implementation."""
        pass

    async def get_thread_author(self, *args, **kwargs):
        """Get thread author. Placeholder implementation."""
        pass

    async def get_user(self, *args, **kwargs):
        """Get a user. Placeholder implementation."""
        pass

    async def list_threads(self, *args, **kwargs):
        """List threads. Placeholder implementation."""
        pass

    async def update_step(self, *args, **kwargs):
        """Update a step. Placeholder implementation."""
        pass

    async def update_thread(self, *args, **kwargs):
        """Update a thread. Placeholder implementation."""
        pass

__init__(langfuse_dataset_service, feedback_service, manual_dataset)

Initialize the Chainlit service.

Parameters:
  • langfuse_dataset_service (LangfuseDatasetService) –

    Service for managing Langfuse datasets.

  • feedback_service (ChainlitFeedbackService) –

    Service handling Chainlit feedback.

  • manual_dataset (LangfuseDatasetConfiguration) –

    Configuration for manual dataset.

Source code in src/augmentation/chainlit/service.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def __init__(
    self,
    langfuse_dataset_service: LangfuseDatasetService,
    feedback_service: ChainlitFeedbackService,
    manual_dataset: LangfuseDatasetConfiguration,
):
    """Initialize the Chainlit service.

    Args:
        langfuse_dataset_service: Service for managing Langfuse datasets.
        feedback_service: Service handling Chainlit feedback.
        manual_dataset: Configuration for manual dataset.
    """
    self.manual_dataset = manual_dataset
    self.feedback_service = feedback_service

    langfuse_dataset_service.create_if_does_not_exist(self.manual_dataset)

build_debug_url(*args, **kwargs) async

Build a debug URL. Placeholder implementation.

Source code in src/augmentation/chainlit/service.py
50
51
52
async def build_debug_url(self, *args, **kwargs):
    """Build a debug URL. Placeholder implementation."""
    pass

create_element(*args, **kwargs) async

Create an element. Placeholder implementation.

Source code in src/augmentation/chainlit/service.py
54
55
56
async def create_element(self, *args, **kwargs):
    """Create an element. Placeholder implementation."""
    pass

create_step(*args, **kwargs) async

Create a step. Placeholder implementation.

Source code in src/augmentation/chainlit/service.py
58
59
60
async def create_step(self, *args, **kwargs):
    """Create a step. Placeholder implementation."""
    pass

create_user(*args, **kwargs) async

Create a user. Placeholder implementation.

Source code in src/augmentation/chainlit/service.py
62
63
64
async def create_user(self, *args, **kwargs):
    """Create a user. Placeholder implementation."""
    pass

delete_element(*args, **kwargs) async

Delete an element. Placeholder implementation.

Source code in src/augmentation/chainlit/service.py
66
67
68
async def delete_element(self, *args, **kwargs):
    """Delete an element. Placeholder implementation."""
    pass

delete_feedback(*args, **kwargs) async

Delete feedback. Placeholder implementation.

Source code in src/augmentation/chainlit/service.py
70
71
72
async def delete_feedback(self, *args, **kwargs):
    """Delete feedback. Placeholder implementation."""
    pass

delete_step(*args, **kwargs) async

Delete a step. Placeholder implementation.

Source code in src/augmentation/chainlit/service.py
74
75
76
async def delete_step(self, *args, **kwargs):
    """Delete a step. Placeholder implementation."""
    pass

delete_thread(*args, **kwargs) async

Delete a thread. Placeholder implementation.

Source code in src/augmentation/chainlit/service.py
78
79
80
async def delete_thread(self, *args, **kwargs):
    """Delete a thread. Placeholder implementation."""
    pass

get_element(*args, **kwargs) async

Get an element. Placeholder implementation.

Source code in src/augmentation/chainlit/service.py
82
83
84
async def get_element(self, *args, **kwargs):
    """Get an element. Placeholder implementation."""
    pass

get_thread(*args, **kwargs) async

Get a thread. Placeholder implementation.

Source code in src/augmentation/chainlit/service.py
86
87
88
async def get_thread(self, *args, **kwargs):
    """Get a thread. Placeholder implementation."""
    pass

get_thread_author(*args, **kwargs) async

Get thread author. Placeholder implementation.

Source code in src/augmentation/chainlit/service.py
90
91
92
async def get_thread_author(self, *args, **kwargs):
    """Get thread author. Placeholder implementation."""
    pass

get_user(*args, **kwargs) async

Get a user. Placeholder implementation.

Source code in src/augmentation/chainlit/service.py
94
95
96
async def get_user(self, *args, **kwargs):
    """Get a user. Placeholder implementation."""
    pass

list_threads(*args, **kwargs) async

List threads. Placeholder implementation.

Source code in src/augmentation/chainlit/service.py
 98
 99
100
async def list_threads(self, *args, **kwargs):
    """List threads. Placeholder implementation."""
    pass

update_step(*args, **kwargs) async

Update a step. Placeholder implementation.

Source code in src/augmentation/chainlit/service.py
102
103
104
async def update_step(self, *args, **kwargs):
    """Update a step. Placeholder implementation."""
    pass

update_thread(*args, **kwargs) async

Update a thread. Placeholder implementation.

Source code in src/augmentation/chainlit/service.py
106
107
108
async def update_thread(self, *args, **kwargs):
    """Update a thread. Placeholder implementation."""
    pass

upsert_feedback(feedback) async

Upsert Chainlit feedback to Langfuse database.

Parameters:
  • feedback (Feedback) –

    Feedback object containing user feedback details.

Returns:
  • bool( bool ) –

    True if feedback was successfully upserted, False otherwise.

Source code in src/augmentation/chainlit/service.py
39
40
41
42
43
44
45
46
47
48
async def upsert_feedback(self, feedback: Feedback) -> bool:
    """Upsert Chainlit feedback to Langfuse database.

    Args:
        feedback: Feedback object containing user feedback details.

    Returns:
        bool: True if feedback was successfully upserted, False otherwise.
    """
    return await self.feedback_service.upsert(feedback)