Session
Message
Class to define the message. Message with contain the role and content.And further can we wrap in the session.
Source code in src/project/database/Session.py
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 | |
__init__(role=Role.MODEL, content='')
Constructor to initialize the message.
Parameters:
-
role(project.database.Session.Role, default:project.database.Session.Role.MODEL) –Role of the message. Defaults to Role.MODEL.
-
content(str, default:'') –Content of the message. Defaults to ''.
Source code in src/project/database/Session.py
35 36 37 38 39 40 41 42 43 44 | |
get_content()
Get the content of the message.
Returns:
-
str(str) –Content of the message
Source code in src/project/database/Session.py
54 55 56 57 58 59 60 | |
Role
Bases: enum.Enum
Enum to define the role of the message.
Source code in src/project/database/Session.py
22 23 24 25 26 27 | |
Session
Class to define the session. Session act as a container for the messages. A session will have a unique id and name.
Source code in src/project/database/Session.py
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 109 | |
__init__()
Constructor to initialize the session.
Source code in src/project/database/Session.py
69 70 71 72 73 74 75 | |
get_messages()
Get the session name.
Returns:
Source code in src/project/database/Session.py
103 104 105 106 107 108 109 | |
get_session_id()
Get the session id.
Returns:
-
int(int) –Session id
Source code in src/project/database/Session.py
77 78 79 80 81 82 83 | |
get_session_name()
Get the session name.
Returns:
-
str(str) –Session name
Source code in src/project/database/Session.py
85 86 87 88 89 90 91 | |
update_message(message=None)
Update the messages.
Parameters:
-
message(list, default:None) –List of messages. Defaults to None.
Source code in src/project/database/Session.py
93 94 95 96 97 98 99 100 101 | |
convert_to_markdown(session)
Function to convert the session to markdown.
Parameters:
Returns:
-
str(str) –Markdown text
Source code in src/project/database/Session.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
map_message_list_to_history(messages)
Function to map the message list to history. Give a list of messages and return the history mentioned in https://ai.google.dev/tutorials/python_quickstart .
Parameters:
Returns:
-
list[dict]–list[dict]: converted history
Source code in src/project/database/Session.py
139 140 141 142 143 144 145 146 147 148 149 | |
to_markdown(text)
Convert the text to markdown.
Parameters:
-
text(str) –Text to be converted to markdown.
Returns:
-
Markdown(IPython.core.display.Markdown) –Markdown text
Source code in src/project/database/Session.py
9 10 11 12 13 14 15 16 17 18 19 | |