Created
January 31, 2025 22:36
-
-
Save w1redch4d/a35ad236118bdb3282b9a99121069717 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import itertools | |
import json | |
import sys | |
import distro | |
def main(): | |
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36" | |
headers = { | |
'Content-Type': 'application/json', | |
'user-agent': f'{user_agent}', | |
} | |
arg = ' '.join(sys.argv[1:]) | |
# json_data = { | |
# "model": "gpt-4o-mini", | |
# "stream": "false", | |
# 'messages': [ | |
# { | |
# 'role': 'user', | |
# 'content': f'Answer with only the actual command without any intro or explanation. What is the {distro.id()} linux command line command to {arg}', | |
# }, | |
# ] | |
# } | |
json_data = { | |
"model": "gpt-4o-mini", | |
"stream": False, | |
"messages": [ | |
{ | |
"role": "system", | |
"content": "You are Marvis, a helpful assistant." | |
}, | |
{ | |
"role": "user", | |
"content": f"Answer with only the actual command without any intro or explanation. What is the {distro.id()} linux command line command to {arg}" | |
} | |
] | |
} | |
response = requests.post('https://gpt-4o-mini.deno.dev/v1/chat/completions', headers=headers, json=json_data) | |
print(json.loads(response.text)['choices'][0]['message']['content']) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment