XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

ora.sh update (gpt-3.5)

d2ba13c9
t.me/xtekky <98614666+xtekky@users.noreply.github.com>
提交于

代码差异

3 个文件 +48 -5
Modified README.md +1 -0
@@ -171,6 +171,7 @@ while True:
171 171 response = ora.Completion.create(
172 172 model = model,
173 173 prompt = prompt,
174 includeHistory = True, # remember history
174 175 conversationId = init.id)
175 176
176 177 print(response.completion.choices[0].text)
Modified ora/__init__.py +18 -5
@@ -2,20 +2,33 @@ from ora.model import CompletionModel
2 2 from ora.typing import OraResponse
3 3 from requests import post
4 4 from time import time
5 from random import randint
5 6
6 7 class Completion:
7 8 def create(
8 9 model : CompletionModel,
9 10 prompt: str,
11 includeHistory: bool = True,
10 12 conversationId: str or None = None) -> OraResponse:
11 13
12 14 extra = {
13 15 'conversationId': conversationId} if conversationId else {}
14
15 response = post('https://ora.sh/api/conversation', json = extra | {
16 'chatbotId': model.id,
17 'input' : prompt,
18 'userId' : model.createdBy}).json()
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()
19 32
20 33 return OraResponse({
21 34 'id' : response['conversationId'],
Added testing/ora_test.py +29 -0
@@ -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)