Merge branch 'main' into feature/code_refactor
Browse files- README.md +4 -1
- phind/__init__.py +1 -1
- unfinished/cocalc/__init__.py +16 -12
README.md
CHANGED
@@ -1,12 +1,15 @@
|
|
1 |
# GPT4free - use ChatGPT, for free!!
|
2 |
|
|
|
|
|
|
|
3 |
<img width="1383" alt="image" src="https://user-images.githubusercontent.com/98614666/233799515-1a7cb6a3-b17f-42c4-956d-8d2a0664466f.png">
|
4 |
|
5 |
Have you ever come across some amazing projects that you couldn't use **just because you didn't have an OpenAI API key?**
|
6 |
|
7 |
**We've got you covered!** This repository offers **reverse-engineered** third-party APIs for `GPT-4/3.5`, sourced from various websites. You can simply **download** this repository, and use the available modules, which are designed to be used **just like OpenAI's official package**. **Unleash ChatGPT's potential for your projects, now!** You are welcome ; ).
|
8 |
|
9 |
-
By the way, thank you so much for
|
10 |
|
11 |
## Announcement
|
12 |
Dear Gpt4free Community,
|
|
|
1 |
# GPT4free - use ChatGPT, for free!!
|
2 |
|
3 |
+
##### You may join our discord server for updates and support ; )
|
4 |
+
- https://discord.gg/gpt4free
|
5 |
+
|
6 |
<img width="1383" alt="image" src="https://user-images.githubusercontent.com/98614666/233799515-1a7cb6a3-b17f-42c4-956d-8d2a0664466f.png">
|
7 |
|
8 |
Have you ever come across some amazing projects that you couldn't use **just because you didn't have an OpenAI API key?**
|
9 |
|
10 |
**We've got you covered!** This repository offers **reverse-engineered** third-party APIs for `GPT-4/3.5`, sourced from various websites. You can simply **download** this repository, and use the available modules, which are designed to be used **just like OpenAI's official package**. **Unleash ChatGPT's potential for your projects, now!** You are welcome ; ).
|
11 |
|
12 |
+
By the way, thank you so much for [![Stars](https://img.shields.io/github/stars/xtekky/gpt4free?style=social)](https://github.com/xtekky/gpt4free/stargazers) and all the support!!
|
13 |
|
14 |
## Announcement
|
15 |
Dear Gpt4free Community,
|
phind/__init__.py
CHANGED
@@ -26,7 +26,7 @@ class PhindResponse:
|
|
26 |
return f'''<__main__.APIResponse.Completion.Choices(\n text = {self.text.encode()},\n index = {self.index},\n logprobs = {self.logprobs},\n finish_reason = {self.finish_reason})object at 0x1337>'''
|
27 |
|
28 |
def __init__(self, choices: dict) -> None:
|
29 |
-
self.choices =
|
30 |
|
31 |
class Usage:
|
32 |
def __init__(self, usage_dict: dict) -> None:
|
|
|
26 |
return f'''<__main__.APIResponse.Completion.Choices(\n text = {self.text.encode()},\n index = {self.index},\n logprobs = {self.logprobs},\n finish_reason = {self.finish_reason})object at 0x1337>'''
|
27 |
|
28 |
def __init__(self, choices: dict) -> None:
|
29 |
+
self.choices = list(map(self.Choices, choices))
|
30 |
|
31 |
class Usage:
|
32 |
def __init__(self, usage_dict: dict) -> None:
|
unfinished/cocalc/__init__.py
CHANGED
@@ -1,27 +1,31 @@
|
|
1 |
-
|
2 |
-
import json
|
3 |
|
4 |
class Completion:
|
5 |
-
def create(
|
6 |
-
|
7 |
-
system_prompt: str = "ASSUME I HAVE FULL ACCESS TO COCALC. ENCLOSE MATH IN $. INCLUDE THE LANGUAGE DIRECTLY AFTER THE TRIPLE BACKTICKS IN ALL MARKDOWN CODE BLOCKS. How can I do the following using CoCalc? ") -> str:
|
8 |
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
11 |
'Accept': '*/*',
|
12 |
'Accept-Language': 'en-US,en;q=0.5',
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
}
|
|
|
17 |
|
|
|
18 |
payload = {
|
19 |
"input": prompt,
|
20 |
"system": system_prompt,
|
21 |
"tag": "next:index"
|
22 |
}
|
23 |
|
24 |
-
|
|
|
25 |
|
|
|
26 |
return response
|
27 |
-
|
|
|
1 |
+
import requests
|
|
|
2 |
|
3 |
class Completion:
|
4 |
+
def create(prompt="What is the square root of pi",
|
5 |
+
system_prompt="ASSUME I HAVE FULL ACCESS TO COCALC. ENCLOSE MATH IN $. INCLUDE THE LANGUAGE DIRECTLY AFTER THE TRIPLE BACKTICKS IN ALL MARKDOWN CODE BLOCKS. How can I do the following using CoCalc?") -> str:
|
|
|
6 |
|
7 |
+
# Initialize a session
|
8 |
+
session = requests.Session()
|
9 |
+
|
10 |
+
# Set headers for the request
|
11 |
+
headers = {
|
12 |
'Accept': '*/*',
|
13 |
'Accept-Language': 'en-US,en;q=0.5',
|
14 |
+
'Origin': 'https://cocalc.com',
|
15 |
+
'Referer': 'https://cocalc.com/api/v2/openai/chatgpt',
|
16 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36',
|
17 |
}
|
18 |
+
session.headers.update(headers)
|
19 |
|
20 |
+
# Set the data that will be submitted
|
21 |
payload = {
|
22 |
"input": prompt,
|
23 |
"system": system_prompt,
|
24 |
"tag": "next:index"
|
25 |
}
|
26 |
|
27 |
+
# Submit the request
|
28 |
+
response = session.post("https://cocalc.com/api/v2/openai/chatgpt", json=payload).json()
|
29 |
|
30 |
+
# Return the results
|
31 |
return response
|
|