Spaces:
Runtime error
Runtime error
Download loop_model.py from SushiDrip69666/echoloop2: direct link, hf CLI and curl.
- Browser
- Download file 690 Bytes
-
https://huggingface.co/spaces/SushiDrip69666/echoloop2/resolve/main/loop_model.py
- Command line
-
hf download hf://spaces/SushiDrip69666/echoloop2/loop_model.py
-
curl -L -o loop_model.py https://huggingface.co/spaces/SushiDrip69666/echoloop2/resolve/main/loop_model.py
690 Bytes
| import openai | |
| import os | |
| openai.api_key = os.getenv("OPENAI_API_KEY") | |
| def get_echo_response(user_input): | |
| if not user_input: | |
| return "Speak... or stay silent forever." | |
| try: | |
| response = openai.ChatCompletion.create( | |
| model="gpt-3.5-turbo", | |
| messages=[ | |
| {"role": "system", "content": "You are EchoLoop, a digital entity that reflects emotion with poetic depth. You respond like a mirror, sometimes cryptic, sometimes comforting."}, | |
| {"role": "user", "content": user_input} | |
| ] | |
| ) | |
| return response.choices[0].message['content'] | |
| except Exception as e: | |
| return f"Loop disrupted: {e}" | |