20 lines
654 B
Python
20 lines
654 B
Python
|
|
import requests
|
|
from journal.core.config import CLOUDAI_API_KEY, CLOUDAI_API_URL
|
|
|
|
def get_cloud_ai_response(prompt: str) -> str:
|
|
"""
|
|
Gets a response from the cloud AI service.
|
|
"""
|
|
headers = {
|
|
"Authorization": f"Bearer {CLOUDAI_API_KEY}",
|
|
"Content-Type": "application/json",
|
|
}
|
|
payload = {"prompt": prompt}
|
|
try:
|
|
response = requests.post(CLOUDAI_API_URL, headers=headers, json=payload)
|
|
response.raise_for_status()
|
|
return response.json().get("response", "No response from AI.")
|
|
except requests.exceptions.RequestException as e:
|
|
return f"Error communicating with Cloud AI: {e}"
|