Skip to content

Commit 3fe3fc9

Browse files
authored
Add files via upload
1 parent 668715d commit 3fe3fc9

File tree

11 files changed

+1589
-1026
lines changed

11 files changed

+1589
-1026
lines changed

README.md

Lines changed: 99 additions & 1023 deletions
Large diffs are not rendered by default.

composer.json

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,29 @@
1414
"email": "yandribret@gmail.com"
1515
}
1616
],
17+
"keywords": [
18+
"gpt",
19+
"gpt-3",
20+
"gpt-3.5",
21+
"gpt-4",
22+
"gpti",
23+
"gpt-free",
24+
"ai",
25+
"blackbox",
26+
"prodia",
27+
"bing",
28+
"chat",
29+
"stream",
30+
"dalle",
31+
"generate-image",
32+
"llama-3.1",
33+
"gpt-4o"
34+
],
1735
"minimum-stability": "stable",
1836
"require": {
1937
"guzzlehttp/guzzle": "^7.8"
2038
},
2139
"homepage": "https://github.com/yandricr/gpti-php",
22-
"extra": {
23-
"donate": "https://ko-fi.com/yandricr"
24-
},
2540
"support": {
2641
"email": "yandribret@gmail.com",
2742
"source": "https://github.com/yandricr/gpti-php",

src/bing.php

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
<?php
2+
namespace gpti;
3+
4+
require_once __DIR__ ."/util.php";
5+
use apistrm;
6+
7+
class bing extends apistrm {
8+
private $result_ = null;
9+
private $error_ = null;
10+
private $user_ = null;
11+
private $secret_ = null;
12+
private $payld = null;
13+
private $stm_ = false;
14+
15+
public function __construct($messages=[], $markdown=false, $stream=false, $conversation_style="Balanced") {
16+
$payload = array(
17+
"messages" => array(),
18+
"model" => "Bing",
19+
"stream" => false,
20+
"markdown" => false,
21+
"conversation_style" => "Balanced"
22+
);
23+
24+
try {
25+
$mess = [];
26+
$mark = false;
27+
$stm = false;
28+
$conver_style = false;
29+
30+
if(isset($conversation_style)){
31+
$conver_style = $conversation_style;
32+
}
33+
34+
if(isset($messages)){
35+
$mess = $messages;
36+
}
37+
38+
if(isset($markdown)){
39+
if($markdown == true){
40+
$mark = true;
41+
} else {
42+
$mark = false;
43+
}
44+
}
45+
46+
if(isset($stream)){
47+
if($stream == true){
48+
$stm = true;
49+
$this->stm_ = true;
50+
} else {
51+
$stm = false;
52+
}
53+
}
54+
55+
$payload = array(
56+
"messages" => $mess,
57+
"model" => "Bing",
58+
"stream" => $stm,
59+
"markdown" => $mark,
60+
"conversation_style" => $conver_style
61+
);
62+
} catch (\Throwable $th) {
63+
$payload = array(
64+
"messages" => [],
65+
"model" => "Bing",
66+
"stream" => false,
67+
"markdown" => false,
68+
"conversation_style" => "Balanced"
69+
);
70+
}
71+
72+
$this->payld = $payload;
73+
}
74+
75+
public function setAPI($user="", $secret=""){
76+
try {
77+
if(gettype($user) === "string" && strlen(trim($user)) > 0){
78+
$this->user_ = $user;
79+
} else {
80+
$this->user_ = null;
81+
}
82+
83+
if(gettype($secret) === "string" && strlen(trim($secret)) > 0){
84+
$this->secret_ = $secret;
85+
} else {
86+
$this->secret_ = null;
87+
}
88+
} catch (\Throwable $th) {
89+
$this->user_ = null;
90+
$this->secret_ = null;
91+
}
92+
}
93+
94+
public function execute(){
95+
try {
96+
$this->ex($this->user_, $this->secret_, $this->payld, 'https://nexra.aryahcr.cc/api/chat/complements', $this->stm_);
97+
$this->error_ = $this->err();
98+
$this->result_ = $this->res();
99+
} catch (\Throwable $th) {
100+
$this->error_ = array(
101+
"code" => 500,
102+
"status" => false,
103+
"error" => "INTERNAL_SERVER_ERROR",
104+
"message" => "general (unknown) error"
105+
);
106+
$this->result_ = null;
107+
}
108+
}
109+
110+
public function stream(){
111+
try {
112+
if($this->err() == null && $this->stm_ == true){
113+
$text = null;
114+
115+
foreach($this->strm() as $data){
116+
$text = $data;
117+
if($text != null){
118+
yield $text;
119+
}
120+
}
121+
122+
if($text == null){
123+
$data_ = array(
124+
"message" => null,
125+
"original" => null,
126+
"finish" => true,
127+
"error" => true
128+
);
129+
$data_ = json_decode(json_encode($data_));
130+
131+
yield $data_;
132+
}
133+
} else {
134+
yield null;
135+
}
136+
} catch (\Throwable $th) {
137+
yield null;
138+
}
139+
}
140+
141+
public function result()
142+
{
143+
return $this->result_;
144+
}
145+
146+
public function error()
147+
{
148+
return $this->error_;
149+
}
150+
}
151+
152+
?>

src/blackbox.php

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
<?php
2+
namespace gpti;
3+
4+
require_once __DIR__ ."/util.php";
5+
use apistrm;
6+
7+
class blackbox extends apistrm {
8+
private $result_ = null;
9+
private $error_ = null;
10+
private $user_ = null;
11+
private $secret_ = null;
12+
private $payld = null;
13+
private $stm_ = false;
14+
15+
public function __construct($messages=[], $markdown=false, $stream=false, $websearch=false) {
16+
$payload = array(
17+
"messages" => array(),
18+
"model" => "blackbox",
19+
"stream" => false,
20+
"markdown" => false,
21+
"websearch" => false
22+
);
23+
24+
try {
25+
$mess = [];
26+
$mark = false;
27+
$stm = false;
28+
$webs = false;
29+
30+
if(isset($websearch) && $websearch === true){
31+
$webs = true;
32+
}
33+
34+
if(isset($messages)){
35+
$mess = $messages;
36+
}
37+
38+
if(isset($markdown)){
39+
if($markdown == true){
40+
$mark = true;
41+
} else {
42+
$mark = false;
43+
}
44+
}
45+
46+
if(isset($stream)){
47+
if($stream == true){
48+
$stm = true;
49+
$this->stm_ = true;
50+
} else {
51+
$stm = false;
52+
}
53+
}
54+
55+
$payload = array(
56+
"messages" => $mess,
57+
"model" => "blackbox",
58+
"stream" => $stm,
59+
"markdown" => $mark,
60+
"websearch" => $webs
61+
);
62+
} catch (\Throwable $th) {
63+
$payload = array(
64+
"messages" => [],
65+
"model" => "blackbox",
66+
"stream" => false,
67+
"markdown" => false,
68+
"websearch" => false
69+
);
70+
}
71+
72+
$this->payld = $payload;
73+
}
74+
75+
public function setAPI($user="", $secret=""){
76+
try {
77+
if(gettype($user) === "string" && strlen(trim($user)) > 0){
78+
$this->user_ = $user;
79+
} else {
80+
$this->user_ = null;
81+
}
82+
83+
if(gettype($secret) === "string" && strlen(trim($secret)) > 0){
84+
$this->secret_ = $secret;
85+
} else {
86+
$this->secret_ = null;
87+
}
88+
} catch (\Throwable $th) {
89+
$this->user_ = null;
90+
$this->secret_ = null;
91+
}
92+
}
93+
94+
public function execute(){
95+
try {
96+
$this->ex($this->user_, $this->secret_, $this->payld, 'https://nexra.aryahcr.cc/api/chat/complements', $this->stm_);
97+
$this->error_ = $this->err();
98+
$this->result_ = $this->res();
99+
} catch (\Throwable $th) {
100+
$this->error_ = array(
101+
"code" => 500,
102+
"status" => false,
103+
"error" => "INTERNAL_SERVER_ERROR",
104+
"message" => "general (unknown) error"
105+
);
106+
$this->result_ = null;
107+
}
108+
}
109+
110+
public function stream(){
111+
try {
112+
if($this->err() == null && $this->stm_ == true){
113+
$text = null;
114+
115+
foreach($this->strm() as $data){
116+
$text = $data;
117+
if($text != null){
118+
yield $text;
119+
}
120+
}
121+
122+
if($text == null){
123+
$data_ = array(
124+
"message" => null,
125+
"original" => null,
126+
"finish" => true,
127+
"error" => true
128+
);
129+
$data_ = json_decode(json_encode($data_));
130+
131+
yield $data_;
132+
}
133+
} else {
134+
yield null;
135+
}
136+
} catch (\Throwable $th) {
137+
yield null;
138+
}
139+
}
140+
141+
public function result()
142+
{
143+
return $this->result_;
144+
}
145+
146+
public function error()
147+
{
148+
return $this->error_;
149+
}
150+
}
151+
152+
?>

0 commit comments

Comments
 (0)