t.me/xtekky commited on
Commit
dbfeab7
1 Parent(s): de1a201

code refractoring

Browse files
README.md CHANGED
@@ -27,7 +27,6 @@ This repository provides reverse-engineered language models from various sources
27
  - [`ora`](#example-ora)
28
  - [`writesonic`](#example-writesonic)
29
  - [`you`](#example-you)
30
- - [`cocalc`](#example-cocalc)
31
 
32
  ## Current Sites <a name="current-sites"></a>
33
 
@@ -39,7 +38,6 @@ This repository provides reverse-engineered language models from various sources
39
  | [t3nsor.com](https://t3nsor.com)|GPT-3.5|
40
  | [you.com](https://you.com)|GPT-3.5 / Internet / good search|
41
  | [phind.com](https://phind.com)|GPT-4 / Internet / good search|
42
- | [cocalc.com](https://cocalc.com)|GPT-3.5 / Unknown Internet|
43
 
44
  ## Sites with Authentication <a name="sites-with-authentication"></a>
45
 
@@ -311,19 +309,6 @@ while True:
311
  chat.append({"question": prompt, "answer": response["response"]})
312
  ```
313
 
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
  ## Dependencies
328
 
329
  The repository is written in Python and requires the following packages:
 
27
  - [`ora`](#example-ora)
28
  - [`writesonic`](#example-writesonic)
29
  - [`you`](#example-you)
 
30
 
31
  ## Current Sites <a name="current-sites"></a>
32
 
 
38
  | [t3nsor.com](https://t3nsor.com)|GPT-3.5|
39
  | [you.com](https://you.com)|GPT-3.5 / Internet / good search|
40
  | [phind.com](https://phind.com)|GPT-4 / Internet / good search|
 
41
 
42
  ## Sites with Authentication <a name="sites-with-authentication"></a>
43
 
 
309
  chat.append({"question": prompt, "answer": response["response"]})
310
  ```
311
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312
  ## Dependencies
313
 
314
  The repository is written in Python and requires the following packages:
{cocalc → unfinished/cocalc}/__init__.py RENAMED
@@ -4,25 +4,24 @@ import json
4
  class Completion:
5
  def create(
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:
9
 
10
- client = Session(client_identifier="chrome_108")
11
  client.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
- 'cookie' : "Cookie: CC_ANA=c68b16f3-f74c-403f-8e18-1d89168b2d13; "
17
  "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
  }
 
19
  payload = {
20
  "input": prompt,
21
  "system": system_prompt,
22
  "tag": "next:index"
23
  }
24
 
25
- response = client.post(f"https://cocalc.com/api/v2/openai/chatgpt", json=payload)
26
 
27
- return json.loads(response)["output"]
28
 
 
4
  class Completion:
5
  def create(
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? ") -> str:
 
8
 
9
+ client = Session()
10
  client.headers = {
11
+ 'Accept': '*/*',
12
+ 'Accept-Language': 'en-US,en;q=0.5',
13
  "origin" : "https://cocalc.com",
14
  "referer" : "https://cocalc.com/api/v2/openai/chatgpt",
 
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",
16
  }
17
+
18
  payload = {
19
  "input": prompt,
20
  "system": system_prompt,
21
  "tag": "next:index"
22
  }
23
 
24
+ response = client.post(f"https://cocalc.com/api/v2/openai/chatgpt", json=payload).json()
25
 
26
+ return response
27
 
unfinished/cocalc/cocalc_test.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import cocalc
2
+
3
+
4
+ response = cocalc.Completion.create(
5
+ prompt = 'hello world'
6
+ )
7
+
8
+ print(response)