Spaces:
Build error
Build error
kwabs22 commited on
Commit ·
8cb5f04
1
Parent(s): d52d19e
custom generate unpack issue
Browse files
app.py
CHANGED
|
@@ -80,7 +80,7 @@ def generate_response(user_message): #generate_response_token_by_token
|
|
| 80 |
error_message = process.stderr.read()
|
| 81 |
print(f"Error: {error_message}")
|
| 82 |
|
| 83 |
-
def custom_generate_response(cust_user_message, prompt_index,
|
| 84 |
"""
|
| 85 |
Generates a custom response based on the user message, the selected prompt,
|
| 86 |
and the provided list of prompts, including a custom ending specific to the prompt.
|
|
@@ -88,9 +88,10 @@ def custom_generate_response(cust_user_message, prompt_index, prompts_list):
|
|
| 88 |
Parameters:
|
| 89 |
- cust_user_message: The message input from the user.
|
| 90 |
- prompt_index: The index of the custom prompt to use.
|
| 91 |
-
-
|
| 92 |
"""
|
| 93 |
-
|
|
|
|
| 94 |
cust_user_message = f"{prompt}\n\n{cust_user_message}\n\n{ending}"
|
| 95 |
yield from generate_response(cust_user_message)
|
| 96 |
|
|
|
|
| 80 |
error_message = process.stderr.read()
|
| 81 |
print(f"Error: {error_message}")
|
| 82 |
|
| 83 |
+
def custom_generate_response(cust_user_message, prompt_index, category):
|
| 84 |
"""
|
| 85 |
Generates a custom response based on the user message, the selected prompt,
|
| 86 |
and the provided list of prompts, including a custom ending specific to the prompt.
|
|
|
|
| 88 |
Parameters:
|
| 89 |
- cust_user_message: The message input from the user.
|
| 90 |
- prompt_index: The index of the custom prompt to use.
|
| 91 |
+
- category: The key of list of prompts to use for generating the response.
|
| 92 |
"""
|
| 93 |
+
prompts_list = Allprompts[category] # Retrieve the correct list of prompts based on the category
|
| 94 |
+
prompt, ending = prompts_list[prompt_index] # Unpack the prompt and its ending
|
| 95 |
cust_user_message = f"{prompt}\n\n{cust_user_message}\n\n{ending}"
|
| 96 |
yield from generate_response(cust_user_message)
|
| 97 |
|