Spaces:
Paused
Paused
Update main.py
Browse files
main.py
CHANGED
|
@@ -224,6 +224,35 @@ def ryuzaki_ai(
|
|
| 224 |
except Exception as e:
|
| 225 |
return {"status": "false", "message": f"error: {e}"}
|
| 226 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
@app.get("/ryuzaki/unsplash")
|
| 228 |
async def get_image_unsplash(query: str, size: str="500x500"):
|
| 229 |
url = SOURCE_UNSPLASH_URL
|
|
|
|
| 224 |
except Exception as e:
|
| 225 |
return {"status": "false", "message": f"error: {e}"}
|
| 226 |
|
| 227 |
+
@app.post("/ryuzaki/google-ai", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
| 228 |
+
def v1beta3_google_ai(
|
| 229 |
+
item: ChatgptCustom,
|
| 230 |
+
api_key: None = Depends(validate_api_key)
|
| 231 |
+
):
|
| 232 |
+
url = SOURCE_ASSISTANT_GOOGLE_AI
|
| 233 |
+
token = ASSISTANT_GOOGLE_API_KEYS
|
| 234 |
+
api_url = f"{SOURCE_ASSISTANT_GOOGLE_AI}/v1beta3/models/text-bison-001:generateText?key={ASSISTANT_GOOGLE_API_KEYS}"
|
| 235 |
+
try:
|
| 236 |
+
headers = {"Content-Type": "application/json"}
|
| 237 |
+
data = {
|
| 238 |
+
"prompt": {
|
| 239 |
+
"text": item.query
|
| 240 |
+
}
|
| 241 |
+
}
|
| 242 |
+
response = requests.post(api_url, headers=headers, json=data)
|
| 243 |
+
response_str = response.json()
|
| 244 |
+
answer = response_str["candidates"]
|
| 245 |
+
for results in answer:
|
| 246 |
+
message = results.get("output")
|
| 247 |
+
return SuccessResponse(
|
| 248 |
+
status="True",
|
| 249 |
+
randydev={
|
| 250 |
+
"message": message
|
| 251 |
+
}
|
| 252 |
+
)
|
| 253 |
+
except:
|
| 254 |
+
return {"status": "false", "message": "Error response."}
|
| 255 |
+
|
| 256 |
@app.get("/ryuzaki/unsplash")
|
| 257 |
async def get_image_unsplash(query: str, size: str="500x500"):
|
| 258 |
url = SOURCE_UNSPLASH_URL
|