-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpy-script
30 lines (21 loc) · 850 Bytes
/
py-script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import openai
openai.api_key = 'your API key'
def get_openai_response(prompt):
response = openai.Completion.create(
engine="text-davinci-002",
prompt=prompt,
max_tokens=150
)
return response.choices[0].text.strip()
def main():
print("Virtual Therapist: Hello! I'm Virtual Therapist, here to listen to your problems and provide advice. Share what's on your mind, or type 'exit' to end the conversation.")
while True:
user_input = input("You: ")
if user_input.lower() == 'exit':
print("Virtual Therapist: Take care! Feel free to come back anytime.")
break
prompt = f"You: {user_input}\nVirtual Therapist:"
response = get_openai_response(prompt)
print(f"Virtual Therapist: {response}")
if __name__ == "__main__":
main()