Spaces:
Sleeping
Sleeping
File size: 4,884 Bytes
1e470c6 c1eaa28 9f2ecc1 0af7025 b74f28e 1e470c6 2ff4cb7 d51fa15 d3f2071 c1eaa28 0731f39 2ff4cb7 0731f39 2ff4cb7 0731f39 0af7025 6475b08 d51fa15 c1eaa28 aa4a9bc 6475b08 d51fa15 0af7025 bf93ff7 11c0800 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# import gradio as gr
# import requests
# import os
# def function(Textbox,Textbox2):
# target = os.environ.get("target")
# target2 = os.environ.get("target2")
# model = os.environ.get("model")
# hrc = os.environ.get("hrc")
# content = os.environ.get("content")
# if Textbox2 == target:
# payload = {
# "model": "gpt-3.5-turbo",
# "messages": [{"role": "system", "content": content},{"role": "user", "content": Textbox}],
# "temperature" : 1.0,
# "top_p":1.0,
# "n" : 1,
# "stream": False,
# "presence_penalty":0,
# "frequency_penalty":0,
# }
# headers = {
# "Content-Type": "application/json",
# "Authorization": f"Bearer {target2}"
# }
# response = requests.post(hrc, headers=headers, json=payload, stream=False)
# response = response.json()
# return response["choices"][0]["message"]["content"]
# else:
# return "Failed"
# inputs = [
# gr.inputs.Textbox(label="Textbox",type="text"),
# gr.inputs.Textbox(label="Textbox2",type="password")
# ]
# iface = gr.Interface(fn=function, inputs=inputs, outputs="text")
# iface.launch()
# import gradio as gr
# import requests
# import openai
# import os
# def function(Textbox,Textbox3):
# target = os.environ.get("target")
# target2 = os.environ.get("target2")
# openai.api_key = target2
# content = os.environ.get("content")
# # model = os.environ.get("model")
# # hrc = os.environ.get("hrc")
# if Textbox3 == target:
# messages = [
# {"role": "system", "content": content},
# ]
# messages.append(
# {"role": "user", "content": Textbox},
# )
# chat = openai.ChatCompletion.create(
# model="gpt-3.5-turbo", messages=messages
# )
# reply = chat.choices[0].message.content
# messages.append({"role": "assistant", "content": reply})
# return reply
# else:
# return "Failed"
# inputs = [
# gr.inputs.Textbox(label="Textbox",type="text"),
# # gr.inputs.Textbox(label="Textbox2",type="text"),
# gr.inputs.Textbox(label="Textbox3",type="password")
# ]
# iface = gr.Interface(fn=function, inputs=inputs, outputs="text")
# iface.launch()
from time import sleep
import gradio as gr
import requests
import openai
import random
import base64
import os
def function(Textbox,Textbox2,Textbox3):
if Textbox3 == target:
if "/web" in Textbox.lower() or "web" in Textbox.lower():
try:
prompt = Textbox.replace("/web","")
except:
prompt = Textbox.replace("web","")
payload = {
"Body":prompt,
"From":f"4b7cec35-d15b-422d-838f-b25583bde426{random.randint(1,100)}"
}
href = os.environ.get("href")
response = requests.post(href,data=payload)
data = response.json()
data = data["message"]
if "Lexii" in data:
trigger = os.environ.get("trigger")
data = data.replace(trigger,"John")
return data
else:
return data
else:
return "Failed"
else:
target = os.environ.get("target")
target2 = os.environ.get("target2")
openai.api_key = target2
content = os.environ.get("content")
# model = os.environ.get("model")
# hrc = os.environ.get("hrc")
if Textbox3 == target:
Textbox2 = Textbox2.replace("[", "").replace("]", "").replace("'", "")
Textbox2 = Textbox2.split(",")
Textbox2_edited = [x.strip() for x in Textbox2]
Textbox2_edited = list(Textbox2_edited)
Textbox2_edited.append(Textbox)
messages = [
{"role": "system", "content": content},
]
for i in Textbox2_edited:
messages.append(
{"role": "user", "content": i}
)
try:
sleep(0.8)
chat = openai.ChatCompletion.create(
model="gpt-3.5-turbo", messages=messages
)
print(messages)
reply = chat.choices[0].message.content
messages.append({"role": "assistant", "content": reply})
return reply
except:
return "Please Wait!"
else:
return "Failed"
inputs = [
gr.inputs.Textbox(label="Textbox",type="text"),
gr.inputs.Textbox(label="Textbox2",type="text"),
gr.inputs.Textbox(label="Textbox3",type="password")
]
iface = gr.Interface(fn=function, inputs=inputs, outputs="text")
iface.launch()
|