1- import os
21import json
2+ import os
33
44
55def get_devchat_site_packages_path ():
66 """@DevChatApi
77 Retrieve the DevChat site packages path from the environment variable.
88
99 Returns:
10- str: The path stored in DEVCHAT_PYTHONPATH environment variable,
10+ str: The path stored in DEVCHAT_PYTHONPATH environment variable,
1111 or an empty string if the variable isn't set.
1212 """
1313 return os .environ .get ("DEVCHAT_PYTHONPATH" , "" )
@@ -18,7 +18,7 @@ def get_llm_model():
1818 Retrieve the DevChat LLM model from the environment variable.
1919
2020 Returns:
21- str: The LLM model stored in LLM_MODEL environment variable,
21+ str: The LLM model stored in LLM_MODEL environment variable,
2222 or an empty string if the variable isn't set.
2323 """
2424 return os .environ .get ("LLM_MODEL" , "gpt-3.5-turbo-1106" )
@@ -28,8 +28,10 @@ def get_parent_hash():
2828 """@DevChatApi
2929 Retrieves the parent hash value from the environment variable.
3030
31- This function is designed to obtain the hash value of the parent message in a sequence of chat interactions,
32- where each pair of question and response is associated with respective hash values. It helps in reconstructing
31+ This function is designed to obtain the hash value of the parent message in a sequence of
32+ chat interactions,
33+ where each pair of question and response is associated with respective hash values.
34+ It helps in reconstructing
3335 the order of conversation threads by providing the parent hash for the current message.
3436
3537 Returns:
@@ -43,15 +45,19 @@ def get_context_contents():
4345 """@DevChatApi
4446 Retrieve the chat context history from an environment variable.
4547
46- This function looks up the `CONTEXT_CONTENTS` environment variable, parses it as JSON, and returns the result.
48+ This function looks up the `CONTEXT_CONTENTS` environment variable, parses it as JSON,
49+ and returns the result.
4750 It's used to obtain the historical content of the chat, which is stored in a JSON array format.
4851 Each item in the array represents a message with a sender role and content, for example:
49- [{"role": "user", "content": "User's message"}, {"role": "assistant", "content": "Assistant's reply"}].
52+ [{"role": "user", "content": "User's message"},
53+ {"role": "assistant", "content": "Assistant's reply"}].
5054
5155 Returns:
52- list: A list of dictionaries representing the chat history. Each dictionary contains the keys 'role' and
53- 'content', corresponding to who sent the message and what the message was, respectively.
54- If the `CONTEXT_CONTENTS` variable is not set, an empty list is returned.
56+ list: A list of dictionaries representing the chat history. Each dictionary
57+ contains the keys 'role' and
58+ 'content', corresponding to who sent the message and what the message was,
59+ respectively. If the `CONTEXT_CONTENTS` variable is not set, an empty list
60+ is returned.
5561 """
5662 return json .loads (os .environ .get ("CONTEXT_CONTENTS" , "[]" ))
5763
@@ -66,7 +72,7 @@ def get_user_input_text():
6672 context, assuming it's from the user, returning it as a string. If the
6773 context is empty, an empty string is returned. This function is typically
6874 used to get the last input provided by the user in the chat interface.
69-
75+
7076 Returns:
7177 str: The content of the most recent user input message if it exists,
7278 otherwise an empty string.
@@ -103,5 +109,3 @@ def get_user_input_files():
103109 if last_index == len (contexts ):
104110 return []
105111 return [item ["content" ] for item in contexts [last_index :]]
106-
107-
0 commit comments