lionagi 0.0.111__py3-none-any.whl → 0.0.113__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. lionagi/__init__.py +7 -2
  2. lionagi/bridge/__init__.py +7 -0
  3. lionagi/bridge/langchain.py +131 -0
  4. lionagi/bridge/llama_index.py +157 -0
  5. lionagi/configs/__init__.py +7 -0
  6. lionagi/configs/oai_configs.py +49 -0
  7. lionagi/configs/openrouter_config.py +49 -0
  8. lionagi/core/__init__.py +15 -0
  9. lionagi/{session/conversation.py → core/conversations.py} +10 -17
  10. lionagi/core/flows.py +1 -0
  11. lionagi/core/instruction_sets.py +1 -0
  12. lionagi/{session/message.py → core/messages.py} +5 -5
  13. lionagi/core/sessions.py +262 -0
  14. lionagi/datastore/__init__.py +1 -0
  15. lionagi/datastore/chroma.py +1 -0
  16. lionagi/datastore/deeplake.py +1 -0
  17. lionagi/datastore/elasticsearch.py +1 -0
  18. lionagi/datastore/lantern.py +1 -0
  19. lionagi/datastore/pinecone.py +1 -0
  20. lionagi/datastore/postgres.py +1 -0
  21. lionagi/datastore/qdrant.py +1 -0
  22. lionagi/loader/__init__.py +12 -0
  23. lionagi/loader/chunker.py +157 -0
  24. lionagi/loader/reader.py +124 -0
  25. lionagi/objs/__init__.py +7 -0
  26. lionagi/objs/messenger.py +163 -0
  27. lionagi/objs/tool_registry.py +247 -0
  28. lionagi/schema/__init__.py +11 -0
  29. lionagi/schema/base_condition.py +1 -0
  30. lionagi/schema/base_schema.py +239 -0
  31. lionagi/schema/base_tool.py +9 -0
  32. lionagi/schema/data_logger.py +94 -0
  33. lionagi/services/__init__.py +14 -0
  34. lionagi/services/anthropic.py +1 -0
  35. lionagi/services/anyscale.py +0 -0
  36. lionagi/services/azure.py +1 -0
  37. lionagi/{api/oai_service.py → services/base_api_service.py} +74 -148
  38. lionagi/services/bedrock.py +0 -0
  39. lionagi/services/chatcompletion.py +48 -0
  40. lionagi/services/everlyai.py +0 -0
  41. lionagi/services/gemini.py +0 -0
  42. lionagi/services/gpt4all.py +0 -0
  43. lionagi/services/huggingface.py +0 -0
  44. lionagi/services/litellm.py +1 -0
  45. lionagi/services/localai.py +0 -0
  46. lionagi/services/mistralai.py +0 -0
  47. lionagi/services/oai.py +34 -0
  48. lionagi/services/ollama.py +1 -0
  49. lionagi/services/openllm.py +0 -0
  50. lionagi/services/openrouter.py +32 -0
  51. lionagi/services/perplexity.py +0 -0
  52. lionagi/services/predibase.py +0 -0
  53. lionagi/services/rungpt.py +0 -0
  54. lionagi/services/service_objs.py +282 -0
  55. lionagi/services/vllm.py +0 -0
  56. lionagi/services/xinference.py +0 -0
  57. lionagi/structure/__init__.py +7 -0
  58. lionagi/structure/relationship.py +128 -0
  59. lionagi/structure/structure.py +160 -0
  60. lionagi/tests/__init__.py +0 -0
  61. lionagi/tests/test_flatten_util.py +426 -0
  62. lionagi/tools/__init__.py +0 -0
  63. lionagi/tools/coder.py +1 -0
  64. lionagi/tools/planner.py +1 -0
  65. lionagi/tools/prompter.py +1 -0
  66. lionagi/tools/sandbox.py +1 -0
  67. lionagi/tools/scorer.py +1 -0
  68. lionagi/tools/summarizer.py +1 -0
  69. lionagi/tools/validator.py +1 -0
  70. lionagi/utils/__init__.py +46 -8
  71. lionagi/utils/api_util.py +63 -416
  72. lionagi/utils/call_util.py +347 -0
  73. lionagi/utils/flat_util.py +540 -0
  74. lionagi/utils/io_util.py +102 -0
  75. lionagi/utils/load_utils.py +190 -0
  76. lionagi/utils/sys_util.py +85 -660
  77. lionagi/utils/tool_util.py +82 -199
  78. lionagi/utils/type_util.py +81 -0
  79. lionagi/version.py +1 -1
  80. {lionagi-0.0.111.dist-info → lionagi-0.0.113.dist-info}/METADATA +44 -15
  81. lionagi-0.0.113.dist-info/RECORD +84 -0
  82. lionagi/api/__init__.py +0 -8
  83. lionagi/api/oai_config.py +0 -16
  84. lionagi/session/__init__.py +0 -7
  85. lionagi/session/session.py +0 -380
  86. lionagi/utils/doc_util.py +0 -331
  87. lionagi/utils/log_util.py +0 -86
  88. lionagi-0.0.111.dist-info/RECORD +0 -20
  89. {lionagi-0.0.111.dist-info → lionagi-0.0.113.dist-info}/LICENSE +0 -0
  90. {lionagi-0.0.111.dist-info → lionagi-0.0.113.dist-info}/WHEEL +0 -0
  91. {lionagi-0.0.111.dist-info → lionagi-0.0.113.dist-info}/top_level.txt +0 -0
lionagi/__init__.py CHANGED
@@ -16,9 +16,14 @@ Copyright 2023 HaiyangLi <ocean@lionagi.ai>
16
16
 
17
17
  import logging
18
18
  from .version import __version__
19
- from .session import *
19
+
20
20
  from .utils import *
21
- from .api import *
21
+ from .schema import *
22
+ from .structure import *
23
+ from .core import *
24
+ from .objs import *
25
+ # from .datastore import *
26
+ # from .structure import *
22
27
 
23
28
 
24
29
  logger = logging.getLogger(__name__)
@@ -0,0 +1,7 @@
1
+ from .langchain import from_langchain
2
+ from .llama_index import from_llama_index
3
+
4
+ __all__ = [
5
+ "from_langchain",
6
+ "from_llama_index"
7
+ ]
@@ -0,0 +1,131 @@
1
+ from typing import Union, Callable, List, Dict, Any
2
+ from ..schema.base_schema import T, DataNode
3
+ from ..utils.sys_util import change_dict_key
4
+
5
+
6
+ def from_langchain(lc_doc: Any) -> T:
7
+ """
8
+ Converts a langchain document into a DataNode object.
9
+
10
+ Parameters:
11
+ lc_doc (Any): The langchain document to be converted.
12
+
13
+ Returns:
14
+ DataNode: A DataNode object created from the langchain document.
15
+ """
16
+ info_json = lc_doc.to_json()
17
+ info_node = {'lc_id': info_json['id']}
18
+ info_node = {**info_node, **info_json['kwargs']}
19
+ return DataNode(**info_node)
20
+
21
+ def to_langchain_document(datanode: T, **kwargs: Any) -> Any:
22
+ """
23
+ Converts a DataNode into a langchain Document.
24
+
25
+ Parameters:
26
+ datanode (DataNode): The DataNode to be converted.
27
+
28
+ **kwargs: Additional keyword arguments to be included in the Document.
29
+
30
+ Returns:
31
+ Any: A langchain Document created from the DataNode.
32
+ """
33
+ from langchain.schema import Document
34
+
35
+ dnode = datanode.to_dict()
36
+ change_dict_key(dnode, old_key='content', new_key='page_content')
37
+ change_dict_key(dnode, old_key='lc_id', new_key='id_')
38
+ dnode = {**dnode, **kwargs}
39
+ return Document(**dnode)
40
+
41
+ def langchain_loader(loader: Union[str, Callable],
42
+ loader_args: List[Any] = [],
43
+ loader_kwargs: Dict[str, Any] = {}) -> Any:
44
+ """
45
+ Loads data using a specified langchain loader.
46
+
47
+ Parameters:
48
+ loader (Union[str, Callable]): The name of the loader function or the loader function itself.
49
+
50
+ loader_args (List[Any]): Positional arguments to pass to the loader function.
51
+
52
+ loader_kwargs (Dict[str, Any]): Keyword arguments to pass to the loader function.
53
+
54
+ Returns:
55
+ Any: The data loaded by the loader function.
56
+
57
+ Raises:
58
+ ValueError: If the specified loader is invalid or if the loader fails to load data.
59
+ """
60
+ import langchain.document_loaders as document_loaders
61
+
62
+ try:
63
+ if isinstance(loader, str):
64
+ loader = getattr(document_loaders, loader)
65
+ else:
66
+ loader = loader
67
+ except Exception as e:
68
+ raise ValueError(f'Invalid loader: {loader}. Error: {e}')
69
+
70
+ try:
71
+ loader_obj = loader(*loader_args, **loader_kwargs)
72
+ data = loader_obj.load()
73
+ return data
74
+ except Exception as e:
75
+ raise ValueError(f'Failed to load. Error: {e}')
76
+
77
+ def langchain_text_splitter(data: Union[str, List],
78
+ splitter: Union[str, Callable],
79
+ splitter_args: List[Any] = [],
80
+ splitter_kwargs: Dict[str, Any] = {}) -> List[str]:
81
+
82
+ import langchain.text_splitter as text_splitter
83
+
84
+ try:
85
+ if isinstance(splitter, str):
86
+ splitter = getattr(text_splitter, splitter)
87
+ else:
88
+ splitter = splitter
89
+ except Exception as e:
90
+ raise ValueError(f'Invalid text splitter: {splitter}. Error: {e}')
91
+
92
+ try:
93
+ splitter_obj = splitter(*splitter_args, **splitter_kwargs)
94
+ if isinstance(data, str):
95
+ chunk = splitter_obj.split_text(data)
96
+ else:
97
+ chunk = splitter_obj.split_documents(data)
98
+ return chunk
99
+ except Exception as e:
100
+ raise ValueError(f'Failed to split. Error: {e}')
101
+
102
+ # def langchain_code_splitter(doc: str,
103
+ # language: str,
104
+ # splitter_args: List[Any] = [],
105
+ # splitter_kwargs: Dict[str, Any] = {}) -> List[Any]:
106
+ # """
107
+ # Splits code into smaller chunks using a RecursiveCharacterTextSplitter specific to a language.
108
+ #
109
+ # Parameters:
110
+ # doc (str): The code document to be split.
111
+ # language (str): The programming language of the code.
112
+ # splitter_args (List[Any]): Positional arguments to pass to the splitter.
113
+ # splitter_kwargs (Dict[str, Any]): Keyword arguments to pass to the splitter.
114
+ #
115
+ # Returns:
116
+ # List[Any]: A list of Documents, each representing a chunk of the original code.
117
+ #
118
+ # Raises:
119
+ # ValueError: If the splitter fails to split the code document.
120
+ # """
121
+ # from langchain.text_splitter import RecursiveCharacterTextSplitter
122
+ #
123
+ # try:
124
+ # splitter = RecursiveCharacterTextSplitter.from_language(
125
+ # language=language, *splitter_args, **splitter_kwargs
126
+ # )
127
+ # docs = splitter.create_documents([doc])
128
+ # return docs
129
+ # except Exception as e:
130
+ # raise ValueError(f'Failed to split. Error: {e}')
131
+ #
@@ -0,0 +1,157 @@
1
+ from typing import Union, Callable, List, Any, Dict
2
+ from ..schema.base_schema import DataNode, T
3
+ from ..utils.sys_util import change_dict_key
4
+
5
+
6
+ def from_llama_index(llama_node: Any, **kwargs: Any) -> T:
7
+ """
8
+ Converts a Llama Index node into a DataNode object.
9
+
10
+ Parameters:
11
+ llama_node (Any): The Llama Index node to be converted.
12
+
13
+ **kwargs: Additional keyword arguments for JSON serialization.
14
+
15
+ Returns:
16
+ DataNode: A DataNode object created from the Llama Index node.
17
+ """
18
+ llama_dict = llama_node.to_dict(**kwargs)
19
+ return DataNode.from_dict(llama_dict)
20
+
21
+ def to_llama_index_textnode(datanode: T, **kwargs: Any) -> Any:
22
+ """
23
+ Converts a DataNode into a Llama Index TextNode.
24
+
25
+ Parameters:
26
+ datanode (DataNode): The DataNode to be converted.
27
+
28
+ **kwargs: Additional keyword arguments to be included in the TextNode.
29
+
30
+ Returns:
31
+ TextNode: A Llama Index TextNode created from the DataNode.
32
+ """
33
+ # to llama_index textnode
34
+ from llama_index.schema import TextNode
35
+
36
+ dnode = datanode.to_dict()
37
+ change_dict_key(dnode, old_key='content', new_key='text')
38
+ change_dict_key(dnode, old_key='node_id', new_key='id_')
39
+
40
+ dnode = {**dnode, **kwargs}
41
+ return TextNode.from_dict(dnode)
42
+
43
+ def get_llama_reader(reader: Union[str, Callable]) -> Callable:
44
+ """
45
+ Gets a Llama Index reader function.
46
+
47
+ Parameters:
48
+ reader (Union[str, Callable]): The name of the reader function or the reader function itself.
49
+
50
+ Returns:
51
+ Callable: The Llama Index reader function.
52
+
53
+ Raises:
54
+ ValueError: If the specified reader is invalid.
55
+ """
56
+ try:
57
+ if isinstance(reader, str):
58
+ if reader == 'SimpleDirectoryReader':
59
+ from llama_index import SimpleDirectoryReader
60
+ return SimpleDirectoryReader
61
+ else:
62
+ from llama_index import download_loader
63
+ return download_loader(reader)
64
+ else:
65
+ return reader
66
+ except Exception as e:
67
+ raise ValueError(f'Invalid reader: {reader}, Error: {e}')
68
+
69
+ def llama_index_reader(reader: Union[str, Callable],
70
+ reader_args: List[Any] = [],
71
+ reader_kwargs: Dict[str, Any] = {},
72
+ load_data_args: List[Any] = [],
73
+ load_data_kwargs: Dict[str, Any] = {}) -> List[Any]:
74
+ """
75
+ Loads documents using a specified Llama Index reader.
76
+
77
+ Parameters:
78
+ reader (Union[str, Callable]): The name of the reader function or the reader function itself.
79
+
80
+ reader_args (List[Any]): Positional arguments to pass to the reader function.
81
+
82
+ reader_kwargs (Dict[str, Any]): Keyword arguments to pass to the reader function.
83
+
84
+ load_data_args (List[Any]): Positional arguments for the load_data method.
85
+
86
+ load_data_kwargs (Dict[str, Any]): Keyword arguments for the load_data method.
87
+
88
+ Returns:
89
+ List[Any]: A list of documents loaded by the reader.
90
+
91
+ Raises:
92
+ ValueError: If the specified reader is invalid or if the reader fails to load documents.
93
+ """
94
+ reader = get_llama_reader(reader)
95
+
96
+ try:
97
+ loader = reader(*reader_args, **reader_kwargs)
98
+ documents = loader.load_data(*load_data_args, **load_data_kwargs)
99
+ return documents
100
+
101
+ except Exception as e:
102
+ raise ValueError(f'Failed to read. Error: {e}')
103
+
104
+ def get_llama_parser(parser: Union[str, Callable]) -> Callable:
105
+ import llama_index.node_parser as node_parser
106
+ import llama_index.text_splitter as text_splitter
107
+
108
+ try:
109
+ return getattr(node_parser, parser)
110
+ except Exception as e1:
111
+ try:
112
+ if isinstance(parser, str):
113
+ return getattr(text_splitter, parser)
114
+ else:
115
+ return parser
116
+ except Exception as e2:
117
+ raise ValueError(f'Invalid node parser: {parser}. Error: {e1}, {e2}')
118
+
119
+
120
+ def llama_index_node_parser(documents: List[Any],
121
+ parser: Union[str, Callable],
122
+ parser_args: List[Any] = [],
123
+ parser_kwargs: Dict[str, Any] = {},
124
+ parsing_kwargs: Dict[str, Any] = {}) -> List[Any]:
125
+ """
126
+ Parses documents into nodes using a specified Llama Index node parser.
127
+
128
+ Parameters:
129
+ documents (List[Any]): The documents to parse.
130
+
131
+ parser (Union[str, Callable]): The name of the parser function or the parser function itself.
132
+
133
+ parser_args (List[Any]): Positional arguments to pass to the parser function.
134
+
135
+ parser_kwargs (Dict[str, Any]): Keyword arguments to pass to the parser function.
136
+
137
+ Returns:
138
+ List[Any]: A list of nodes parsed from the documents.
139
+
140
+ Raises:
141
+ ValueError: If the specified parser is invalid or if the parser fails to parse the documents.
142
+ """
143
+ parser = get_llama_parser(parser)
144
+
145
+ try:
146
+ parser_obj = parser(*parser_args, **parser_kwargs)
147
+ nodes = parser_obj.get_nodes_from_documents(documents, **parsing_kwargs)
148
+ return nodes
149
+
150
+ except Exception as e1:
151
+ try:
152
+ parser_obj = parser.from_defaults(*parser_args, **parser_kwargs)
153
+ nodes = parser_obj.get_nodes_from_documents(documents, **parsing_kwargs)
154
+ return nodes
155
+ except Exception as e2:
156
+ raise ValueError(f'Failed to parse. Error: {e1}, {e2}')
157
+
@@ -0,0 +1,7 @@
1
+ from .oai_configs import oai_schema
2
+ from .openrouter_config import openrouter_schema
3
+
4
+ __all__ = [
5
+ "oai_schema",
6
+ "openrouter_schema"
7
+ ]
@@ -0,0 +1,49 @@
1
+ oai_chat_llmconfig = {
2
+ "model": "gpt-4-1106-preview",
3
+ "frequency_penalty": 0,
4
+ "max_tokens": None,
5
+ "n": 1,
6
+ "presence_penalty": 0,
7
+ "response_format": {"type": "text"},
8
+ "seed": None,
9
+ "stop": None,
10
+ "stream": False,
11
+ "temperature": 0.7,
12
+ "top_p": 1,
13
+ "tools": None,
14
+ "tool_choice": "none",
15
+ "user": None
16
+ }
17
+
18
+ oai_chat_schema = {
19
+ "required" : ["model", "frequency_penalty", "n", "presence_penalty", "response_format", "temperature", "top_p"],
20
+ "optional": ["seed", "stop", "stream", "tools", "tool_choice", "user", "max_tokens"],
21
+ "input": "messages",
22
+ "config": oai_chat_llmconfig
23
+ }
24
+
25
+ oai_finetune_llmconfig = {
26
+ "model": "gpt-3.5-turbo",
27
+ "hyperparameters": {
28
+ "batch_size": "auto",
29
+ "learning_rate_multiplier": "auto",
30
+ "n_epochs": "auto"
31
+ },
32
+ "suffix": None,
33
+ "training_file": None,
34
+ }
35
+
36
+ oai_finetune_schema = {
37
+ "required" : ["model", "training_file"],
38
+ "optional": ["hyperparameters", "suffix", "validate_file"],
39
+ "input": ["training_file"],
40
+ "config": oai_finetune_llmconfig
41
+ }
42
+
43
+
44
+ oai_schema = {
45
+
46
+ "chat": oai_chat_schema,
47
+ "finetune": oai_finetune_schema
48
+
49
+ }
@@ -0,0 +1,49 @@
1
+ openrouter_chat_llmconfig = {
2
+ "model": "gpt-4-1106-preview",
3
+ "frequency_penalty": 0,
4
+ "max_tokens": None,
5
+ "n": 1,
6
+ "presence_penalty": 0,
7
+ "response_format": {"type": "text"},
8
+ "seed": None,
9
+ "stop": None,
10
+ "stream": False,
11
+ "temperature": 0.7,
12
+ "top_p": 1,
13
+ "tools": None,
14
+ "tool_choice": "none",
15
+ "user": None
16
+ }
17
+
18
+ openrouter_chat_schema = {
19
+ "required" : ["model", "frequency_penalty", "n", "presence_penalty", "response_format", "temperature", "top_p"],
20
+ "optional": ["seed", "stop", "stream", "tools", "tool_choice", "user", "max_tokens"],
21
+ "input": "messages",
22
+ "config": openrouter_chat_llmconfig
23
+ }
24
+
25
+ openrouter_finetune_llmconfig = {
26
+ "model": "gpt-3.5-turbo",
27
+ "hyperparameters": {
28
+ "batch_size": "auto",
29
+ "learning_rate_multiplier": "auto",
30
+ "n_epochs": "auto"
31
+ },
32
+ "suffix": None,
33
+ "training_file": None,
34
+ }
35
+
36
+ openrouter_finetune_schema = {
37
+ "required" : ["model", "training_file"],
38
+ "optional": ["hyperparameters", "suffix", "validate_file"],
39
+ "input": ["training_file"],
40
+ "config": openrouter_finetune_llmconfig
41
+ }
42
+
43
+
44
+ openrouter_schema = {
45
+
46
+ "chat": openrouter_chat_schema,
47
+ "finetune": openrouter_finetune_schema
48
+
49
+ }
@@ -0,0 +1,15 @@
1
+ # from .messages import Response, Instruction, System
2
+ from .conversations import Conversation
3
+ from .sessions import Session
4
+
5
+ # from .instruction_sets import InstructionSet
6
+ # from .flows.flow import Flow
7
+
8
+
9
+ __all__ = [
10
+ # "Response",
11
+ # "Instruction",
12
+ # "System",
13
+ "Conversation",
14
+ "Session", #"Flow", "InstructionSet"
15
+ ]
@@ -1,4 +1,4 @@
1
- from .message import Message
1
+ from .messages import Message
2
2
 
3
3
 
4
4
  class Conversation:
@@ -9,22 +9,21 @@ class Conversation:
9
9
  user instructions, and assistant responses.
10
10
 
11
11
  Attributes:
12
- response_counts (int):
13
- The count of assistant responses in the conversation.
14
- messages (list):
15
- A list to store messages in the conversation.
16
- msg (Message):
17
- An instance of the Message class for creating messages.
18
- responses (list):
19
- A list to store assistant responses in the conversation.
12
+ response_counts (int): The count of assistant responses in the conversation.
13
+ messages (list): A list to store messages in the conversation.
14
+ msg (Message): An instance of the Message class for creating messages.
15
+ responses (list): A list to store assistant responses in the conversation.
20
16
 
21
17
  Methods:
22
18
  initiate_conversation(system, instruction, context=None, name=None):
23
19
  Initiate a conversation with a system setting and user instruction.
20
+
24
21
  add_messages(system, instruction, context=None, response=None, tool=None, name=None):
25
22
  Add messages to the conversation, including system setting, user instruction, and assistant response.
23
+
26
24
  change_system(system):
27
25
  Change the system setting in the conversation.
26
+
28
27
  keep_last_n_exchanges(n: int):
29
28
  Keep the last n exchanges in the conversation.
30
29
  """
@@ -48,11 +47,8 @@ class Conversation:
48
47
 
49
48
  Parameters:
50
49
  system (str): The system setting for the conversation.
51
-
52
50
  instruction (str): The user instruction to initiate the conversation.
53
-
54
51
  context (dict): Additional context for the conversation. Default is None.
55
-
56
52
  name (str): The name associated with the user. Default is None.
57
53
  """
58
54
  self.messages, self.responses = [], []
@@ -66,13 +62,10 @@ class Conversation:
66
62
 
67
63
  Parameters:
68
64
  system (str): The system setting for the message. Default is None.
69
-
70
65
  instruction (str): The instruction content for the message. Default is None.
71
-
72
66
  context (dict): Additional context for the message. Default is None.
73
-
74
67
  response (dict): The response content for the message. Default is None.
75
-
68
+ tool (dict): The tool information for the message. Default is None.
76
69
  name (str): The name associated with the message. Default is None.
77
70
  """
78
71
  msg = self.msg(system=system, instruction=instruction, context=context,
@@ -101,5 +94,5 @@ class Conversation:
101
94
  ]
102
95
  if len(response_indices) >= n:
103
96
  first_index_to_keep = response_indices[-n] + 1
104
- self.messages = self.messages[0] + self.messages[first_index_to_keep:]
97
+ self.messages = [self.system] + self.messages[first_index_to_keep:]
105
98
 
lionagi/core/flows.py ADDED
@@ -0,0 +1 @@
1
+ # represents structured sessions
@@ -0,0 +1 @@
1
+ # dynamically structured preconfigured instructions
@@ -1,7 +1,7 @@
1
1
  from datetime import datetime
2
2
  import json
3
- from ..utils.sys_util import create_id, l_call
4
- from ..utils.log_util import DataLogger
3
+ from ..utils import create_id, lcall
4
+ from ..schema import DataLogger
5
5
 
6
6
 
7
7
  class Message:
@@ -61,7 +61,7 @@ class Message:
61
61
 
62
62
  name (str): The name associated with the message. Default is None.
63
63
  """
64
- if sum(l_call([system, instruction, response], bool)) > 1:
64
+ if sum(lcall([system, instruction, response], bool)) > 1:
65
65
  raise ValueError("Error: Message cannot have more than one role.")
66
66
 
67
67
  else:
@@ -145,7 +145,7 @@ class Message:
145
145
  context=context, response=response, name=name)
146
146
  return self.to_json()
147
147
 
148
- def to_csv(self, dir=None, filename=None, verbose=True, timestamp=True, dir_exist_ok=True, file_exist_ok=False):
148
+ def to_csv(self, filename=None,dir=None, verbose=True, timestamp=True, dir_exist_ok=True, file_exist_ok=False):
149
149
  """
150
150
  Save the message to a CSV file.
151
151
 
@@ -162,5 +162,5 @@ class Message:
162
162
 
163
163
  file_exist_ok (bool): Whether to allow the file to exist. Default is False.
164
164
  """
165
- self._logger.to_csv(dir, filename, verbose, timestamp, dir_exist_ok, file_exist_ok)
165
+ self._logger.to_csv(filename,dir=dir, verbose=verbose, timestamp=timestamp, dir_exist_ok=dir_exist_ok, file_exist_ok=file_exist_ok)
166
166