Spaces:
Runtime error
Runtime error
Peter
commited on
Commit
·
235585a
1
Parent(s):
9a9e8f9
📝 docstrings and upd inputs
Browse filesSigned-off-by: Peter <74869040+pszemraj@users.noreply.github.com>
app.py
CHANGED
|
@@ -45,15 +45,15 @@ cwd = Path.cwd()
|
|
| 45 |
my_cwd = str(cwd.resolve()) # string so it can be passed to os.path() objects
|
| 46 |
|
| 47 |
|
| 48 |
-
def chat(prompt_message, temperature=0.
|
| 49 |
"""
|
| 50 |
-
chat -
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
"""
|
| 58 |
history = []
|
| 59 |
response = ask_gpt(
|
|
@@ -78,26 +78,26 @@ def ask_gpt(
|
|
| 78 |
chat_pipe,
|
| 79 |
speaker="person alpha",
|
| 80 |
responder="person beta",
|
| 81 |
-
|
|
|
|
| 82 |
top_p=0.95,
|
| 83 |
top_k=25,
|
| 84 |
temperature=0.6,
|
| 85 |
-
):
|
| 86 |
"""
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
"""
|
| 100 |
-
|
| 101 |
st = time.perf_counter()
|
| 102 |
prompt = clean(message) # clean user input
|
| 103 |
prompt = prompt.strip() # get rid of any extra whitespace
|
|
|
|
| 45 |
my_cwd = str(cwd.resolve()) # string so it can be passed to os.path() objects
|
| 46 |
|
| 47 |
|
| 48 |
+
def chat(prompt_message, temperature: float = 0.6, top_p: float = 0.95, top_k: int = 25)-> str:
|
| 49 |
"""
|
| 50 |
+
chat - the main function for the chatbot. This is the function that is called when the user
|
| 51 |
|
| 52 |
+
:param _type_ prompt_message: the message to send to the model
|
| 53 |
+
:param float temperature: the temperature value for the model, defaults to 0.6
|
| 54 |
+
:param float top_p: the top_p value for the model, defaults to 0.95
|
| 55 |
+
:param int top_k: the top_k value for the model, defaults to 25
|
| 56 |
+
:return str: the response from the model
|
| 57 |
"""
|
| 58 |
history = []
|
| 59 |
response = ask_gpt(
|
|
|
|
| 78 |
chat_pipe,
|
| 79 |
speaker="person alpha",
|
| 80 |
responder="person beta",
|
| 81 |
+
min_length=4,
|
| 82 |
+
max_length=64,
|
| 83 |
top_p=0.95,
|
| 84 |
top_k=25,
|
| 85 |
temperature=0.6,
|
| 86 |
+
) -> str:
|
| 87 |
"""
|
| 88 |
+
ask_gpt - helper function that asks the GPT model a question and returns the response
|
| 89 |
+
|
| 90 |
+
:param str message: the question to ask the model
|
| 91 |
+
:param chat_pipe: the pipeline object for the model, created by the pipeline() function
|
| 92 |
+
:param str speaker: the name of the speaker, defaults to "person alpha"
|
| 93 |
+
:param str responder: the name of the responder, defaults to "person beta"
|
| 94 |
+
:param int min_length: the minimum length of the response, defaults to 4
|
| 95 |
+
:param int max_length: the maximum length of the response, defaults to 64
|
| 96 |
+
:param float top_p: the top_p value for the model, defaults to 0.95
|
| 97 |
+
:param int top_k: the top_k value for the model, defaults to 25
|
| 98 |
+
:param float temperature: the temperature value for the model, defaults to 0.6
|
| 99 |
+
:return str: the response from the model
|
| 100 |
"""
|
|
|
|
| 101 |
st = time.perf_counter()
|
| 102 |
prompt = clean(message) # clean user input
|
| 103 |
prompt = prompt.strip() # get rid of any extra whitespace
|