Add self-hosting capabilities and deployment guide for the application

Implement self-hosting for RockyLinux by adding systemd and Nginx configurations, updating API models to support standard OpenAI keys, and providing a comprehensive deployment guide.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 923ae0e3-a363-4db8-b04a-e8baca2a1330
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: f8aa455f-f180-4964-94dd-11cfb1a42383
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8af7d2ec-2cc3-4ece-8af3-9f071488d072/923ae0e3-a363-4db8-b04a-e8baca2a1330/VnHW0bR
Replit-Helium-Checkpoint-Created: true
This commit is contained in:
pironantoine
2026-04-03 17:06:07 +00:00
parent ae970b2a32
commit c0322d5c8e
9 changed files with 656 additions and 52 deletions
+25 -8
View File
@@ -14,16 +14,31 @@ _client: OpenAI | None = None
def get_client() -> OpenAI:
"""
Supporte deux modes :
- Replit AI Integration : AI_INTEGRATIONS_OPENAI_BASE_URL + AI_INTEGRATIONS_OPENAI_API_KEY
- Auto-hébergement standard : OPENAI_API_KEY (+ OPENAI_BASE_URL optionnel pour proxy)
"""
global _client
if _client is None:
base_url = os.environ.get("AI_INTEGRATIONS_OPENAI_BASE_URL")
api_key = os.environ.get("AI_INTEGRATIONS_OPENAI_API_KEY")
if not base_url or not api_key:
replit_base = os.environ.get("AI_INTEGRATIONS_OPENAI_BASE_URL")
replit_key = os.environ.get("AI_INTEGRATIONS_OPENAI_API_KEY")
std_key = os.environ.get("OPENAI_API_KEY")
std_base = os.environ.get("OPENAI_BASE_URL")
if replit_base and replit_key:
_client = OpenAI(base_url=replit_base, api_key=replit_key)
elif std_key:
kwargs = {"api_key": std_key}
if std_base:
kwargs["base_url"] = std_base
_client = OpenAI(**kwargs)
else:
raise RuntimeError(
"AI_INTEGRATIONS_OPENAI_BASE_URL et AI_INTEGRATIONS_OPENAI_API_KEY "
"sont requis. Configurez les intégrations Replit AI."
"Aucune clé IA configurée. "
"Définissez OPENAI_API_KEY dans le fichier .env "
"ou configurez les intégrations Replit AI."
)
_client = OpenAI(base_url=base_url, api_key=api_key)
return _client
@@ -34,8 +49,9 @@ def filter_idea(content: str) -> dict:
"""
try:
client = get_client()
filter_model = os.environ.get("OPENAI_FILTER_MODEL", "gpt-4o-mini")
response = client.chat.completions.create(
model="gpt-5-mini",
model=filter_model,
max_completion_tokens=300,
response_format={"type": "json_object"},
messages=[
@@ -96,9 +112,10 @@ def synthesize_ideas(ideas: list[str]) -> str:
)
try:
client = get_client()
synthesis_model = os.environ.get("OPENAI_SYNTHESIS_MODEL", "gpt-4o")
ideas_text = "\n".join(f"{i + 1}. {idea}" for i, idea in enumerate(ideas))
response = client.chat.completions.create(
model="gpt-5.2",
model=synthesis_model,
max_completion_tokens=1200,
messages=[
{"role": "system", "content": SYNTHESIS_PROMPT},
+8 -8
View File
@@ -1,8 +1,8 @@
flask==3.1.1
flask-cors==5.0.1
flask-limiter==3.9.4
openai==1.77.0
psycopg2-binary==2.9.10
python-dotenv==1.0.1
bleach==6.2.0
validators==0.34.0
bleach>=6.2.0
flask>=3.1.1
flask-cors>=5.0.1
flask-limiter>=3.9.4
gunicorn>=23.0.0
openai>=1.77.0
psycopg2-binary>=2.9.10
python-dotenv>=1.0.1