forked from helallao/perplexity-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccount_creation.py
More file actions
89 lines (69 loc) · 2.5 KB
/
Copy pathaccount_creation.py
File metadata and controls
89 lines (69 loc) · 2.5 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
"""
Account creation example.
This example demonstrates how to create new accounts
automatically using Emailnator for unlimited queries.
"""
import perplexity
def main():
"""Run account creation example."""
print("=" * 60)
print("Perplexity API - Account Creation Example")
print("=" * 60)
print("\nNote: This example requires Emailnator cookies")
print("See README for instructions on obtaining cookies\n")
# Example with Emailnator cookies (replace with actual cookies)
emailnator_cookies = {
# 'XSRF-TOKEN': 'your-xsrf-token',
# 'laravel_session': 'your-session',
}
if not emailnator_cookies or not any(emailnator_cookies.values()):
print("No Emailnator cookies provided. Showing example code only.\n")
print("Example code:")
print("-" * 60)
print("""
# With actual Emailnator cookies:
client = perplexity.Client()
print("Creating new account...")
client.create_account(emailnator_cookies)
print(f"Account created successfully!")
print(f"Enhanced queries available: {client.copilot}")
print(f"File uploads available: {client.file_upload}")
# Now you can use enhanced modes
response = client.search(
'Complex query here',
mode='pro', # or 'reasoning', 'deep research'
model='gpt-4.5'
)
""")
print("-" * 60)
return
# Actual implementation
client = perplexity.Client()
print("[1/3] Client created (no queries available)")
print(f"Enhanced queries: {client.copilot}")
print("\n[2/3] Creating new account with Emailnator...")
try:
client.create_account(emailnator_cookies)
print("Account created successfully!")
except Exception as e:
print(f"Error creating account: {e}")
print("\nTip: Make sure Emailnator cookies are fresh")
print("Visit https://emailnator.com/ and get new cookies")
return
print(f"\n[3/3] Account ready!")
print(f"Enhanced queries available: {client.copilot}")
print(f"File uploads available: {client.file_upload}")
# Test with enhanced mode
print("\nTesting with enhanced mode...")
response = client.search("What is quantum entanglement?", mode="pro")
if "answer" in response:
print("\nResponse:")
print("-" * 60)
print(response["answer"][:300] + "...")
print("-" * 60)
print(f"\nQueries remaining: {client.copilot}")
print("\n" + "=" * 60)
print("Account creation example completed!")
print("=" * 60)
if __name__ == "__main__":
main()