import gradio as gr import requests import re import os API_TOKEN = os.environ.get("API_TOKEN") API_ENDPOINT = os.environ.get("API_ENDPOINT") API_PROCESS = os.environ.get("API_PROCESS") KEY = os.environ.get("KEY") headers = { "Content-Type": "application/json", "X-Access-Token": API_TOKEN } instruction = f"Respond with the format OUTPUT: response" create_memory = [] user = "" bot = "" update_memory = create_memory.copy() history = "" exec(API_PROCESS) def send_message(instruction, message, memory, options): task_message = f"INSTRUCTION: {instruction}\n\nINPUT: {message[1]}" response = requests.post( f"{API_ENDPOINT}/generate", json={ "task": task_message, **options }, headers=headers ) response_text = response.json()['result'] print(f"\n\n{response_text}\n\n") return response_text def predict(get_input, access_key): if (access_key != KEY): print("REQUEST FAILED: Attempted Key: " + access_key) return ("[UNAUTHORIZED ACCESS]", get_input); get_input = get_input.strip() response = api_request(get_input) print(f"---\nUSER: {get_input}\nBOT: {response}\n---") return [response, ""] def main(): with gr.Blocks() as demo: with gr.Row(variant = "panel"): gr.Markdown("šŸ˜ˆ temporary locked gpt4 till these stupid automation stops (i can read logs and they are failing cause they missing an argument šŸ¤¬) (how tf yall bypassing the blocked gradio api šŸ’€)!!!\n\n\nā›” do not overuse it\n\n\nrespone takes 4-20+ seconds per request but if u make it write a essay it could take over a minute!\n\n\ndo not use it for math it may not be 100% correct!!!\n\n\nuhh ... https://discord.gg/6JRtGawz7B") with gr.Row(): with gr.Column(): input = gr.Textbox(label = "Input", lines = 4) access_key = gr.Textbox(label = "Access Key", lines = 1) run = gr.Button("ā–¶") with gr.Row(): with gr.Column(): output = gr.Textbox(label = "Output", value = "", lines = 50) input.submit(predict, inputs = [input, access_key], outputs = [output, input]) run.click(predict, inputs = [input, access_key], outputs = [output, input]) demo.queue(concurrency_count = 5, api_open = False) demo.launch(inline = True, max_threads = 5, show_api = False) if __name__ == "__main__": main()