diff options
| author | thomas grothe <thomas@Shai-Hulud.myfiosgateway.com> | 2025-06-28 00:13:25 -0400 |
|---|---|---|
| committer | thomas grothe <thomas@Shai-Hulud.myfiosgateway.com> | 2025-06-28 00:13:25 -0400 |
| commit | 481340fd3ab6e38c525c44833c7a942401d9f9b1 (patch) | |
| tree | 9bf6f68375b570913ab7113dd1de256e2a9096e8 /gemini.py | |
| parent | 82b5ea0eb32a68394ac33a0f8767acfd6ccb77b2 (diff) | |
some video tools and the beginning of my gemini cli
Diffstat (limited to 'gemini.py')
| -rw-r--r-- | gemini.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/gemini.py b/gemini.py new file mode 100644 index 0000000..a8f5708 --- /dev/null +++ b/gemini.py @@ -0,0 +1,55 @@ +#!/bin/python3 + +#from google import genai +import os +import argparse +import requests + + +API_KEY=os.getenv('GEMINI_API_KEY') +API_URL=f'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key={API_KEY}' +#client = genai.Client(api_key=os.getenv('GEMINI_API_KEY')) + +#todo make modular +def main(): + parser = argparse.ArgumentParser("gemini cli tool") + subparsers = parser.add_subparsers(dest='command', help='Command to execute') + + parser_query = subparsers.add_parser('q', help='query the model') + parser_query.add_argument('query', nargs='+', help='the query string') + + args = parser.parse_args() + + + print(API_URL) + + if args.command == 'q': + query_text = ' '.join(args.query) + + headers = { + 'Content-Type': 'application/json' + } + + data = { #todo options for other parameters + "contents": [ + { + "parts": [ + { + "text": query_text + } + ] + } + ] + } + + #todo: also save the response to db + httpResponse = requests.post(API_URL, headers=headers, json=data) + json = httpResponse.json() + response = json['candidates'][0]['content']['parts'][0]['text'] + + print(response) + return + + +if __name__ == '__main__': + main() |
