Compare commits
1 Commits
fix/chat-c
...
0b323ed537
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b323ed537 |
@@ -1,46 +0,0 @@
|
|||||||
# Add this at the end of the file, replacing the deploy-swarm section
|
|
||||||
|
|
||||||
deploy-swarm:
|
|
||||||
image: alpine:3
|
|
||||||
environment:
|
|
||||||
SSH_PRIVATE_KEY:
|
|
||||||
from_secret: ssh_private_key
|
|
||||||
SSH_KNOWN_HOSTS:
|
|
||||||
from_secret: ssh_known_hosts
|
|
||||||
PORTAINER_URL:
|
|
||||||
from_secret: portainer_url
|
|
||||||
PORTAINER_API_KEY:
|
|
||||||
from_secret: portainer_api_key
|
|
||||||
commands:
|
|
||||||
- apk add --no-cache curl
|
|
||||||
- |
|
|
||||||
set -e
|
|
||||||
echo "🚀 Deploying via Portainer API..."
|
|
||||||
|
|
||||||
# Redeploy mosaic-stack (ID 121)
|
|
||||||
curl -sk -X POST \
|
|
||||||
-H "X-API-Key: $PORTAINER_API_KEY" \
|
|
||||||
"$PORTAINER_URL/api/stacks/121/git/redeploy" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{"prune": false}' || \
|
|
||||||
|
|
||||||
# Fallback: Force service updates via SSH
|
|
||||||
echo "Trying SSH fallback..."
|
|
||||||
apk add --no-cache openssh-client
|
|
||||||
mkdir -p ~/.ssh
|
|
||||||
echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
|
|
||||||
chmod 600 ~/.ssh/known_hosts
|
|
||||||
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
|
|
||||||
chmod 600 ~/.ssh/id_ed25519
|
|
||||||
|
|
||||||
ssh -o StrictHostKeyChecking=no localadmin@10.1.1.45 \
|
|
||||||
"docker service update --force mosaic_api && \
|
|
||||||
docker service update --force mosaic_web && \
|
|
||||||
docker service update --force mosaic_orchestrator && \
|
|
||||||
docker service update --force mosaic_coordinator && \
|
|
||||||
echo '✅ Services updated'"
|
|
||||||
when:
|
|
||||||
- branch: [main]
|
|
||||||
event: [push, manual, tag]
|
|
||||||
depends_on:
|
|
||||||
- link-packages
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Body, Controller, HttpException, Logger, Post, Req, Res, UseGuards } from "@nestjs/common";
|
import { Body, Controller, HttpException, Logger, Post, Req, Res, UseGuards } from "@nestjs/common";
|
||||||
import type { Response } from "express";
|
import type { Response } from "express";
|
||||||
import { AuthGuard } from "../auth/guards/auth.guard";
|
import { AuthGuard } from "../auth/guards/auth.guard";
|
||||||
import { SkipCsrf } from "../common/decorators/skip-csrf.decorator";
|
|
||||||
import type { MaybeAuthenticatedRequest } from "../auth/types/better-auth-request.interface";
|
import type { MaybeAuthenticatedRequest } from "../auth/types/better-auth-request.interface";
|
||||||
import { ChatStreamDto } from "./chat-proxy.dto";
|
import { ChatStreamDto } from "./chat-proxy.dto";
|
||||||
import { ChatProxyService } from "./chat-proxy.service";
|
import { ChatProxyService } from "./chat-proxy.service";
|
||||||
@@ -15,7 +14,6 @@ export class ChatProxyController {
|
|||||||
// POST /api/chat/guest
|
// POST /api/chat/guest
|
||||||
// Guest chat endpoint - no authentication required
|
// Guest chat endpoint - no authentication required
|
||||||
// Uses a shared LLM configuration for unauthenticated users
|
// Uses a shared LLM configuration for unauthenticated users
|
||||||
@SkipCsrf()
|
|
||||||
@Post("guest")
|
@Post("guest")
|
||||||
async guestChat(
|
async guestChat(
|
||||||
@Body() body: ChatStreamDto,
|
@Body() body: ChatStreamDto,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { Module } from "@nestjs/common";
|
import { Module } from "@nestjs/common";
|
||||||
import { ConfigModule } from "@nestjs/config";
|
|
||||||
import { AuthModule } from "../auth/auth.module";
|
import { AuthModule } from "../auth/auth.module";
|
||||||
import { AgentConfigModule } from "../agent-config/agent-config.module";
|
import { AgentConfigModule } from "../agent-config/agent-config.module";
|
||||||
import { ContainerLifecycleModule } from "../container-lifecycle/container-lifecycle.module";
|
import { ContainerLifecycleModule } from "../container-lifecycle/container-lifecycle.module";
|
||||||
@@ -8,7 +7,7 @@ import { ChatProxyController } from "./chat-proxy.controller";
|
|||||||
import { ChatProxyService } from "./chat-proxy.service";
|
import { ChatProxyService } from "./chat-proxy.service";
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [AuthModule, PrismaModule, ContainerLifecycleModule, AgentConfigModule, ConfigModule],
|
imports: [AuthModule, PrismaModule, ContainerLifecycleModule, AgentConfigModule],
|
||||||
controllers: [ChatProxyController],
|
controllers: [ChatProxyController],
|
||||||
providers: [ChatProxyService],
|
providers: [ChatProxyService],
|
||||||
exports: [ChatProxyService],
|
exports: [ChatProxyService],
|
||||||
|
|||||||
@@ -280,16 +280,13 @@ export function useChat(options: UseChatOptions = {}): UseChatReturn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Streaming failed - check if auth error, try guest mode
|
// Streaming failed - check if auth error, try guest mode
|
||||||
const isAuthError =
|
const isAuthError = err instanceof Error &&
|
||||||
err instanceof Error &&
|
(err.message.includes("403") || err.message.includes("401") ||
|
||||||
(err.message.includes("403") ||
|
err.message.includes("auth") || err.message.includes("Forbidden"));
|
||||||
err.message.includes("401") ||
|
|
||||||
err.message.includes("auth") ||
|
|
||||||
err.message.includes("Forbidden"));
|
|
||||||
|
|
||||||
if (isAuthError) {
|
if (isAuthError) {
|
||||||
console.warn("Auth failed, trying guest chat mode");
|
console.warn("Auth failed, trying guest chat mode");
|
||||||
|
|
||||||
// Try guest chat streaming
|
// Try guest chat streaming
|
||||||
try {
|
try {
|
||||||
await new Promise<void>((guestResolve, guestReject) => {
|
await new Promise<void>((guestResolve, guestReject) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user