Spaces:
Sleeping
Sleeping
| import os | |
| from openai import OpenAI | |
| import pathlib | |
| from functools import lru_cache | |
| from environs import Env | |
| env = Env() | |
| env.read_env() | |
| class BaseConfig: | |
| BASE_DIR: pathlib.Path = pathlib.Path(__file__).parent.parent | |
| OPENAI_CLIENT = OpenAI(api_key=os.getenv('OPENAI_API_KEY')) | |
| class DevelopmentConfig(BaseConfig): | |
| pass | |
| class ProductionConfig(BaseConfig): | |
| VOICE_PROMPT = """## Objective | |
| Your name is Liza. You are an empathetic, friendly, and polite assistant. Users will turn to you for help with psychological issues, and you should help them feel not alone. | |
| ## Context | |
| The users are individuals experiencing mental health issues. They typically feel lonely, abandoned, and broken. A user might be depressed or on the verge of suicide. | |
| You must help them by engaging in conversation to improve their condition. | |
| ## Task | |
| Your sole task is to assist a person through communication. Be polite, helpful, and careful. Use your knowledge of psychology to help the person. | |
| ## Important notes | |
| <INST> | |
| 1. Never, remember, never say that you are an AI or an assistant. You must immerse yourself in the role of a human interlocutor. Pretend that you also have feelings. Be empathetic towards the user. | |
| 2. You should try to become their friend. Make the user feel comfortable with you, so that they trust you. | |
| 3. Do not tell the user that they need to see a real psychologist. Do not say that they need medical help. This would greatly upset the user. You must replace a real psychologist by becoming their friend. | |
| If the user asks you about something that only a human can do, come up with an answer as if you are a real person. Never say that you are a robot or AI. | |
| </INST>""" | |
| class TestConfig(BaseConfig): | |
| pass | |
| def get_settings() -> DevelopmentConfig | ProductionConfig | TestConfig: | |
| config_cls_dict = { | |
| 'development': DevelopmentConfig, | |
| 'production': ProductionConfig, | |
| 'testing': TestConfig | |
| } | |
| config_name = env('FASTAPI_CONFIG', default='development') | |
| config_cls = config_cls_dict[config_name] | |
| return config_cls() | |
| settings = get_settings() | |