t.me/xtekky
commited on
Commit
·
d2ba13c
1
Parent(s):
5596b76
ora.sh update (gpt-3.5)
Browse files- README.md +1 -0
- ora/__init__.py +18 -5
- testing/ora_test.py +29 -0
README.md
CHANGED
@@ -171,6 +171,7 @@ while True:
|
|
171 |
response = ora.Completion.create(
|
172 |
model = model,
|
173 |
prompt = prompt,
|
|
|
174 |
conversationId = init.id)
|
175 |
|
176 |
print(response.completion.choices[0].text)
|
|
|
171 |
response = ora.Completion.create(
|
172 |
model = model,
|
173 |
prompt = prompt,
|
174 |
+
includeHistory = True, # remember history
|
175 |
conversationId = init.id)
|
176 |
|
177 |
print(response.completion.choices[0].text)
|
ora/__init__.py
CHANGED
@@ -2,20 +2,33 @@ from ora.model import CompletionModel
|
|
2 |
from ora.typing import OraResponse
|
3 |
from requests import post
|
4 |
from time import time
|
|
|
5 |
|
6 |
class Completion:
|
7 |
def create(
|
8 |
model : CompletionModel,
|
9 |
prompt: str,
|
|
|
10 |
conversationId: str or None = None) -> OraResponse:
|
11 |
|
12 |
extra = {
|
13 |
'conversationId': conversationId} if conversationId else {}
|
14 |
-
|
15 |
-
response = post('https://ora.sh/api/conversation',
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
return OraResponse({
|
21 |
'id' : response['conversationId'],
|
|
|
2 |
from ora.typing import OraResponse
|
3 |
from requests import post
|
4 |
from time import time
|
5 |
+
from random import randint
|
6 |
|
7 |
class Completion:
|
8 |
def create(
|
9 |
model : CompletionModel,
|
10 |
prompt: str,
|
11 |
+
includeHistory: bool = True,
|
12 |
conversationId: str or None = None) -> OraResponse:
|
13 |
|
14 |
extra = {
|
15 |
'conversationId': conversationId} if conversationId else {}
|
16 |
+
|
17 |
+
response = post('https://ora.sh/api/conversation',
|
18 |
+
headers = {
|
19 |
+
"host" : "ora.sh",
|
20 |
+
"authorization" : f"Bearer AY0{randint(1111, 9999)}",
|
21 |
+
"user-agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
|
22 |
+
"origin" : "https://ora.sh",
|
23 |
+
"referer" : "https://ora.sh/chat/",
|
24 |
+
},
|
25 |
+
json = extra | {
|
26 |
+
'chatbotId': model.id,
|
27 |
+
'input' : prompt,
|
28 |
+
'userId' : model.createdBy,
|
29 |
+
'model' : 'gpt-3.5-turbo',
|
30 |
+
'provider' : 'OPEN_AI',
|
31 |
+
'includeHistory': includeHistory}).json()
|
32 |
|
33 |
return OraResponse({
|
34 |
'id' : response['conversationId'],
|
testing/ora_test.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# inport ora
|
2 |
+
import ora
|
3 |
+
|
4 |
+
# create model
|
5 |
+
model = ora.CompletionModel.create(
|
6 |
+
system_prompt = 'You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible',
|
7 |
+
description = 'ChatGPT Openai Language Model',
|
8 |
+
name = 'gpt-3.5')
|
9 |
+
|
10 |
+
print(model.id)
|
11 |
+
|
12 |
+
# init conversation (will give you a conversationId)
|
13 |
+
init = ora.Completion.create(
|
14 |
+
model = model,
|
15 |
+
prompt = 'hello world')
|
16 |
+
|
17 |
+
print(init.completion.choices[0].text)
|
18 |
+
|
19 |
+
while True:
|
20 |
+
# pass in conversationId to continue conversation
|
21 |
+
|
22 |
+
prompt = input('>>> ')
|
23 |
+
response = ora.Completion.create(
|
24 |
+
model = model,
|
25 |
+
prompt = prompt,
|
26 |
+
includeHistory = True,
|
27 |
+
conversationId = init.id)
|
28 |
+
|
29 |
+
print(response.completion.choices[0].text)
|