Spaces:
Runtime error
Runtime error
Raveheart1
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -16,14 +16,13 @@ def translate_text(tamil_text):
|
|
16 |
return translation
|
17 |
|
18 |
def query_gemini_api(translated_text):
|
19 |
-
|
20 |
headers = {"Content-Type": "application/json"}
|
21 |
prompt = f"Based on the following sentence, continue the story: {translated_text}"
|
22 |
payload = {
|
23 |
"contents": [{"parts": [{"text": prompt}]}]
|
24 |
}
|
25 |
-
response = requests.post(
|
26 |
-
|
27 |
if response.status_code == 200:
|
28 |
result = response.json()
|
29 |
creative_text = result['candidates'][0]['content']['parts'][0]['text']
|
@@ -31,7 +30,6 @@ def query_gemini_api(translated_text):
|
|
31 |
else:
|
32 |
return f"Error: {response.status_code} - {response.text}"
|
33 |
|
34 |
-
|
35 |
def query_image(payload):
|
36 |
huggingface_api_key = os.getenv('HUGGINGFACE_API_KEY')
|
37 |
API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev"
|
|
|
16 |
return translation
|
17 |
|
18 |
def query_gemini_api(translated_text):
|
19 |
+
url = "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent"
|
20 |
headers = {"Content-Type": "application/json"}
|
21 |
prompt = f"Based on the following sentence, continue the story: {translated_text}"
|
22 |
payload = {
|
23 |
"contents": [{"parts": [{"text": prompt}]}]
|
24 |
}
|
25 |
+
response = requests.post(url, headers=headers, json=payload) # Corrected this line
|
|
|
26 |
if response.status_code == 200:
|
27 |
result = response.json()
|
28 |
creative_text = result['candidates'][0]['content']['parts'][0]['text']
|
|
|
30 |
else:
|
31 |
return f"Error: {response.status_code} - {response.text}"
|
32 |
|
|
|
33 |
def query_image(payload):
|
34 |
huggingface_api_key = os.getenv('HUGGINGFACE_API_KEY')
|
35 |
API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev"
|