Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -78,6 +78,103 @@
|
|
78 |
|
79 |
# iface.launch()
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
from time import sleep
|
82 |
import gradio as gr
|
83 |
import requests
|
@@ -86,14 +183,11 @@ import random
|
|
86 |
import base64
|
87 |
import os
|
88 |
|
89 |
-
def function(Textbox,Textbox2,
|
90 |
-
openai.api_key = ''
|
91 |
-
openai.api_base = os.environ.get("base")
|
92 |
target = os.environ.get("target")
|
93 |
target2 = os.environ.get("target2")
|
94 |
openai.api_key = target2
|
95 |
content = os.environ.get("content")
|
96 |
-
content2 = os.environ.get("content2")
|
97 |
link1 = os.environ.get("link1")
|
98 |
path = os.environ.get("path")
|
99 |
link2 = os.environ.get("link2")
|
@@ -145,18 +239,18 @@ def function(Textbox,Textbox2, Textbox3):
|
|
145 |
Textbox2_edited = list(Textbox2_edited)
|
146 |
Textbox2_edited.append(Textbox)
|
147 |
messages = [
|
148 |
-
{"role": "system", "content":
|
149 |
]
|
150 |
for i in Textbox2_edited:
|
151 |
messages.append(
|
152 |
{"role": "user", "content": i}
|
153 |
)
|
154 |
try:
|
155 |
-
|
156 |
chat = openai.ChatCompletion.create(
|
157 |
model="gpt-3.5-turbo", messages=messages
|
158 |
)
|
159 |
-
|
160 |
reply = chat.choices[0].message.content
|
161 |
messages.append({"role": "assistant", "content": reply})
|
162 |
return reply
|
|
|
78 |
|
79 |
# iface.launch()
|
80 |
|
81 |
+
# from time import sleep
|
82 |
+
# import gradio as gr
|
83 |
+
# import requests
|
84 |
+
# import openai
|
85 |
+
# import random
|
86 |
+
# import base64
|
87 |
+
# import os
|
88 |
+
|
89 |
+
# def function(Textbox,Textbox2, Textbox3):
|
90 |
+
# openai.api_key = ''
|
91 |
+
# openai.api_base = os.environ.get("base")
|
92 |
+
# target = os.environ.get("target")
|
93 |
+
# target2 = os.environ.get("target2")
|
94 |
+
# openai.api_key = target2
|
95 |
+
# content = os.environ.get("content")
|
96 |
+
# content2 = os.environ.get("content2")
|
97 |
+
# link1 = os.environ.get("link1")
|
98 |
+
# path = os.environ.get("path")
|
99 |
+
# link2 = os.environ.get("link2")
|
100 |
+
# if "/web" in Textbox.lower() or "web" in Textbox.lower():
|
101 |
+
# try:
|
102 |
+
# prompt = Textbox.replace("/web","")
|
103 |
+
# except:
|
104 |
+
# prompt = Textbox.replace("web","")
|
105 |
+
# headers = {
|
106 |
+
# "authority": link1,
|
107 |
+
# "method": "POST",
|
108 |
+
# "path": path,
|
109 |
+
# "scheme": "https",
|
110 |
+
# "accept": "application/json, text/plain, */*",
|
111 |
+
# "accept-encoding": "gzip, deflate, br",
|
112 |
+
# "accept-language": "en-US,en;q=0.9",
|
113 |
+
# "content-length": "88",
|
114 |
+
# "content-type": "application/json",
|
115 |
+
# "origin": link2,
|
116 |
+
# "referer": f"{link2}/",
|
117 |
+
# "sec-ch-ua": '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
|
118 |
+
# "sec-ch-ua-mobile": "?0",
|
119 |
+
# "sec-ch-ua-platform": '"Windows"',
|
120 |
+
# "sec-fetch-dest": "empty",
|
121 |
+
# "sec-fetch-mode": "cors",
|
122 |
+
# "sec-fetch-site": "same-site",
|
123 |
+
# "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
|
124 |
+
# }
|
125 |
+
# href = os.environ.get("href")
|
126 |
+
# response = requests.post(href,json={
|
127 |
+
# "Body":prompt,
|
128 |
+
# "From":f"4b7cec35-d15b-422d-838f-b25583bde426{random.randint(1,100)}"
|
129 |
+
# },headers=headers)
|
130 |
+
# data = response.json()
|
131 |
+
# data = data["message"]
|
132 |
+
# trigger = os.environ.get("trigger")
|
133 |
+
# if trigger in data:
|
134 |
+
# data = data.replace(trigger,"John")
|
135 |
+
# return data
|
136 |
+
# else:
|
137 |
+
# return data
|
138 |
+
# else:
|
139 |
+
# # model = os.environ.get("model")
|
140 |
+
# # hrc = os.environ.get("hrc")
|
141 |
+
# if Textbox3 == target:
|
142 |
+
# Textbox2 = Textbox2.replace("[", "").replace("]", "").replace("'", "")
|
143 |
+
# Textbox2 = Textbox2.split(",")
|
144 |
+
# Textbox2_edited = [x.strip() for x in Textbox2]
|
145 |
+
# Textbox2_edited = list(Textbox2_edited)
|
146 |
+
# Textbox2_edited.append(Textbox)
|
147 |
+
# messages = [
|
148 |
+
# {"role": "system", "content": content2},
|
149 |
+
# ]
|
150 |
+
# for i in Textbox2_edited:
|
151 |
+
# messages.append(
|
152 |
+
# {"role": "user", "content": i}
|
153 |
+
# )
|
154 |
+
# try:
|
155 |
+
# # sleep(0.8)
|
156 |
+
# chat = openai.ChatCompletion.create(
|
157 |
+
# model="gpt-3.5-turbo", messages=messages
|
158 |
+
# )
|
159 |
+
# # reply = chat.choices[0].message.content
|
160 |
+
# reply = chat.choices[0].message.content
|
161 |
+
# messages.append({"role": "assistant", "content": reply})
|
162 |
+
# return reply
|
163 |
+
# except:
|
164 |
+
# return "Please Wait!"
|
165 |
+
# else:
|
166 |
+
# return "Failed"
|
167 |
+
|
168 |
+
# inputs = [
|
169 |
+
# gr.inputs.Textbox(label="Textbox",type="text"),
|
170 |
+
# gr.inputs.Textbox(label="Textbox2",type="text"),
|
171 |
+
# gr.inputs.Textbox(label="Textbox3",type="password")
|
172 |
+
# ]
|
173 |
+
|
174 |
+
# iface = gr.Interface(fn=function, inputs=inputs, outputs="text")
|
175 |
+
|
176 |
+
# iface.launch()
|
177 |
+
|
178 |
from time import sleep
|
179 |
import gradio as gr
|
180 |
import requests
|
|
|
183 |
import base64
|
184 |
import os
|
185 |
|
186 |
+
def function(Textbox,Textbox2,Textbox3):
|
|
|
|
|
187 |
target = os.environ.get("target")
|
188 |
target2 = os.environ.get("target2")
|
189 |
openai.api_key = target2
|
190 |
content = os.environ.get("content")
|
|
|
191 |
link1 = os.environ.get("link1")
|
192 |
path = os.environ.get("path")
|
193 |
link2 = os.environ.get("link2")
|
|
|
239 |
Textbox2_edited = list(Textbox2_edited)
|
240 |
Textbox2_edited.append(Textbox)
|
241 |
messages = [
|
242 |
+
{"role": "system", "content": content},
|
243 |
]
|
244 |
for i in Textbox2_edited:
|
245 |
messages.append(
|
246 |
{"role": "user", "content": i}
|
247 |
)
|
248 |
try:
|
249 |
+
sleep(0.8)
|
250 |
chat = openai.ChatCompletion.create(
|
251 |
model="gpt-3.5-turbo", messages=messages
|
252 |
)
|
253 |
+
print(messages)
|
254 |
reply = chat.choices[0].message.content
|
255 |
messages.append({"role": "assistant", "content": reply})
|
256 |
return reply
|