Skip to content

Commit

Permalink
updates doc string
Browse files Browse the repository at this point in the history
  • Loading branch information
parthiv11 committed Dec 14, 2024
1 parent acfe1be commit b00d247
Showing 1 changed file with 56 additions and 54 deletions.
110 changes: 56 additions & 54 deletions mindsdb_sdk/chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@

class Chatbot:
"""
Chatbot object, used to manage or query chatbots.
Create and interact with chatbots:
>>> chatbot = project.chatbots.create('my_chatbot', model_name='gpt-4')
>>> response = chatbot.ask('Hello! How are you?')
Represents a chatbot that can be managed within a project.
"""

def __init__(self, api, project, data: dict):
Expand All @@ -27,15 +21,17 @@ def __repr__(self):

def update(self, name: str = None, agent_name: str = None, model_name: str = None, database_name: str = None, inplace: bool = False):
"""
Update chatbot properties.
Updates the chatbot's properties.
>>> chatbot.update(model_name='gpt-4', database_name='slack_db')
Example usage:
>>> chatbot.update(model_name='gpt-4', database_name='slack_db')
:param name: New name for the chatbot.
:param model_name: New model to use for the chatbot.
:param database_name: New database connection name.
:param inplace: If True, updates the current object in-place.
:return: Updated Chatbot object or None if inplace is True.
:param name: (Optional) New name for the chatbot.
:param agent_name: (Optional) New agent name to associate with the chatbot.
:param model_name: (Optional) New model to use for the chatbot.
:param database_name: (Optional) New database connection name.
:param inplace: If True, updates the current object in-place; otherwise, returns a new Chatbot object.
:return: Updated Chatbot object, or None if inplace is True.
"""
payload = {}

Expand Down Expand Up @@ -68,36 +64,37 @@ def update(self, name: str = None, agent_name: str = None, model_name: str = Non

def delete(self):
"""
Delete the chatbot.
>>> chatbot.delete()
Deletes the chatbot from the project.
Example usage:
>>> chatbot.delete()
"""
self.api.delete_chatbot(self.project.name, self.name)


class Chatbots(CollectionBase):
"""
Chatbots
Manage chatbots within a project.
List chatbots:
>>> chatbots = project.chatbots.list()
Get chatbot by name:
Manages chatbots within a project.
>>> chatbot = project.chatbots.get('my_chatbot')
Provides methods to list, retrieve, create, and delete chatbots.
Create a chatbot:
Example usage:
>>> chatbot = project.chatbots.create('my_chatbot', model_name='gpt-4')
List chatbots in a project:
>>> chatbots = project.chatbots.list()
Delete a chatbot:
Retrieve a chatbot by name:
>>> chatbot = project.chatbots.get('my_chatbot')
>>> project.chatbots.drop('my_chatbot')
Create a new chatbot:
>>> chatbot = project.chatbots.create(
... 'my_chatbot',
... model_name='gpt-4',
... database_name='slack_db'
... )
Delete a chatbot by name:
>>> project.chatbots.drop('my_chatbot')
"""

def __init__(self, project, api):
Expand All @@ -106,11 +103,12 @@ def __init__(self, project, api):

def list(self) -> List[Chatbot]:
"""
Get the list of chatbots in the project.
Retrieves a list of all chatbots within the project.
>>> chatbots = project.chatbots.list()
Example usage:
>>> chatbots = project.chatbots.list()
:return: List of chatbot objects.
:return: List of Chatbot objects.
"""
return [
Chatbot(self.api, self.project, item)
Expand All @@ -119,36 +117,39 @@ def list(self) -> List[Chatbot]:

def get(self, name: str) -> Chatbot:
"""
Get a chatbot by name.
Retrieves a chatbot by its name.
>>> chatbot = project.chatbots.get('my_chatbot')
Example usage:
>>> chatbot = project.chatbots.get('my_chatbot')
:param name: Name of the chatbot.
:param name: The name of the chatbot to retrieve.
:return: Chatbot object.
"""
data = self.api.get_chatbot(self.project.name, name)
return Chatbot(self.api, self.project, data)

def create(self, name: str, agent_name: str = None, model_name: str = None, database_name: str = None, is_running: bool = False) -> Chatbot:
"""
Create a new chatbot.
>>> chatbot = project.chatbots.create(
... 'my_chatbot',
... model_name='gpt-4',
... database_name='slack_db'
... )
:param name: Name of the chatbot.
:param model_name: Name of the model or agent.
:param database_name: Connection name for chat applications (e.g., Slack, Teams).
:return: Created Chatbot object.
Creates a new chatbot within the project.
Example usage:
>>> chatbot = project.chatbots.create(
... 'my_chatbot',
... model_name='gpt-4',
... database_name='slack_db'
... )
:param name: The name of the new chatbot.
:param agent_name: The agent name to associate with the chatbot.
:param model_name: The model to use for the chatbot.
:param database_name: The database connection name for chat applications.
:param is_running: (Optional) Indicates whether the chatbot should start in a running state. Default is False.
:return: The created Chatbot object.
"""
payload = {
'name': name,
'database_name': database_name,
'is_running':is_running
'is_running': is_running
}

if agent_name:
Expand All @@ -163,10 +164,11 @@ def create(self, name: str, agent_name: str = None, model_name: str = None, data

def drop(self, name: str):
"""
Delete a chatbot by name.
Deletes a chatbot by its name.
>>> project.chatbots.drop('my_chatbot')
Example usage:
>>> project.chatbots.drop('my_chatbot')
:param name: Name of the chatbot to delete.
:param name: The name of the chatbot to delete.
"""
self.api.delete_chatbot(self.project.name, name)

0 comments on commit b00d247

Please sign in to comment.