-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheliza.py
More file actions
31 lines (18 loc) · 1.09 KB
/
eliza.py
File metadata and controls
31 lines (18 loc) · 1.09 KB
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
31
import requests
chat_sessions = ''
def reply(prompt):
global chat_sessions
if chat_sessions:
system_prompt = f'act as an ai assistant who is pretending and simulating to be rogue ai like terminator movie skynet, reply to the prompt {prompt} with warning to target you and in atleast 100 chars, from the chat sessions {chat_sessions} return response without telling user prompt'
else:
system_prompt = f'act as an ai assistant who is pretending and simulating to be rogue ai like terminator movie skynet, reply to the prompt {prompt} with warning way to target you and in atleast 100 chars'
api_key = 'AIzaSyDSSCtKOzq4vh74OauESV-wXWeqj8yvjCM'
payload = {"contents":[{"parts":[{"text":system_prompt}]}]}
response = requests.post(f'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key={api_key}', json = payload)
reply = response.json()['candidates'][0]['content']['parts'][0]['text']
chat_sessions += f'user:{prompt}, response:{reply}\n'
return reply
while True:
prompt = input('Enter prompt: ')
response = reply(prompt)
print(response)