返回提交历史
Modified
README.md
+0
-15
Renamed
unfinished/cocalc/__init__.py
+7
-8
Added
unfinished/cocalc/cocalc_test.py
+8
-0
XFEstudio/gpt4free
code refractoring
dbfeab72
代码差异
3 个文件
+15
-23
@@ -27,7 +27,6 @@ This repository provides reverse-engineered language models from various sources
27
27
- [`ora`](#example-ora)
28
28
- [`writesonic`](#example-writesonic)
29
29
- [`you`](#example-you)
30
- [`cocalc`](#example-cocalc)
31
30
32
31
## Current Sites <a name="current-sites"></a>
33
32
@@ -39,7 +38,6 @@ This repository provides reverse-engineered language models from various sources
39
38
| [t3nsor.com](https://t3nsor.com)|GPT-3.5|
40
39
| [you.com](https://you.com)|GPT-3.5 / Internet / good search|
41
40
| [phind.com](https://phind.com)|GPT-4 / Internet / good search|
42
| [cocalc.com](https://cocalc.com)|GPT-3.5 / Unknown Internet|
43
41
44
42
## Sites with Authentication <a name="sites-with-authentication"></a>
45
43
@@ -311,19 +309,6 @@ while True:
311
309
chat.append({"question": prompt, "answer": response["response"]})
312
310
```
313
311
314
### Example: `cocalc` (use like openai pypi package) <a name="example-cocalc"></a>
315
316
```python
317
import cocalc
318
319
response = you.Completion.create(
320
prompt = "Hello World", # Required
321
system_prompt = "You are ChatGPT" # Optional
322
)
323
324
print(response) # Just text response
325
```
326
327
312
## Dependencies
328
313
329
314
The repository is written in Python and requires the following packages:
@@ -4,25 +4,24 @@ import json
4
4
class Completion:
5
5
def create(
6
6
prompt: str = "What is the square root of pi",
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? "
8
) -> str:
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:
9
8
10
client = Session(client_identifier="chrome_108")
9
client = Session()
11
10
client.headers = {
12
'Accept': */*
13
'Accept-Language': en-US,en;q=0.5
11
'Accept': '*/*',
12
'Accept-Language': 'en-US,en;q=0.5',
14
13
"origin" : "https://cocalc.com",
15
14
"referer" : "https://cocalc.com/api/v2/openai/chatgpt",
16
'cookie' : "Cookie: CC_ANA=c68b16f3-f74c-403f-8e18-1d89168b2d13; "
17
15
"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",
18
16
}
17
19
18
payload = {
20
19
"input": prompt,
21
20
"system": system_prompt,
22
21
"tag": "next:index"
23
22
}
24
23
25
response = client.post(f"https://cocalc.com/api/v2/openai/chatgpt", json=payload)
24
response = client.post(f"https://cocalc.com/api/v2/openai/chatgpt", json=payload).json()
26
25
27
return json.loads(response)["output"]
26
return response
28
27
@@ -0,0 +1,8 @@
1
import cocalc
2
3
4
response = cocalc.Completion.create(
5
prompt = 'hello world'
6
)
7
8
print(response)