Spaces:
Running
Running
Download src/processor/response/setup.py from Jakob08/moneychatbot: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/spaces/Jakob08/moneychatbot/resolve/main/src/processor/response/setup.py
- Command line
-
hf download hf://spaces/Jakob08/moneychatbot/src/processor/response/setup.py
-
curl -L -o setup.py https://huggingface.co/spaces/Jakob08/moneychatbot/resolve/main/src/processor/response/setup.py
1.02 kB
| # | |
| # SPDX-FileCopyrightText: Hadad <hadad@linuxmail.org> | |
| # SPDX-License-Identifier: Apache-2.0 | |
| # | |
| from ...utils.time import get_current_time | |
| from config import INSTRUCTIONS | |
| def setup_response(conversation_history, user_input): | |
| history = [] | |
| history.insert( | |
| 0, | |
| { | |
| "role": "system", | |
| "content": ( | |
| f"Today is: {get_current_time()}" | |
| + "\n\n\n" | |
| + INSTRUCTIONS | |
| ) | |
| } | |
| ) | |
| if isinstance(conversation_history, list): | |
| for history_item in conversation_history: | |
| message_role = history_item.get("role") | |
| message_content = history_item.get("content") | |
| if message_role in ("user", "assistant") and isinstance(message_content, str): | |
| history.append({"role": message_role, "content": message_content}) | |
| if isinstance(user_input, str) and user_input.strip(): | |
| history.append({"role": "user", "content": user_input}) | |
| return history |