Spaces:
Running
Running
lalashechka
commited on
Commit
•
b93f329
1
Parent(s):
e302561
Update app.py
Browse files
app.py
CHANGED
@@ -52,6 +52,14 @@ async def generate_response(request_body: RequestBody):
|
|
52 |
pattern = r'https?://\S+\.(?:jpg|jpeg|png|gif)'
|
53 |
match2 = re.search(pattern, decoded_string)
|
54 |
all_chunk = match2.group()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
if key_body != key_true:
|
57 |
all_chunk = "How's the hack going?"
|
|
|
52 |
pattern = r'https?://\S+\.(?:jpg|jpeg|png|gif)'
|
53 |
match2 = re.search(pattern, decoded_string)
|
54 |
all_chunk = match2.group()
|
55 |
+
|
56 |
+
if model == 'gemini2':
|
57 |
+
key_gemini2 = os.environ['key_gemini2']
|
58 |
+
headers = {'Content-Type': 'application/json',}
|
59 |
+
params = {'key': key_gemini2}
|
60 |
+
json_data = {'contents': [{'parts': [{'text': input_text}]}]}
|
61 |
+
response = requests.post('https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent', params=params, headers=headers, json=json_data)
|
62 |
+
all_chunk = response.json()['candidates'][0]['content']['parts'][0]['text']
|
63 |
|
64 |
if key_body != key_true:
|
65 |
all_chunk = "How's the hack going?"
|