Skip to content

Instantly share code, notes, and snippets.

@w1redch4d
Created January 31, 2025 22:36
Show Gist options
  • Save w1redch4d/a35ad236118bdb3282b9a99121069717 to your computer and use it in GitHub Desktop.
Save w1redch4d/a35ad236118bdb3282b9a99121069717 to your computer and use it in GitHub Desktop.
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