mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 10:15:27 -04:00
Improve Ollama setup and model endpoint handling
This commit is contained in:
+12
-2
@@ -4,8 +4,6 @@ import asyncio
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import pty
|
||||
import fcntl
|
||||
import shlex
|
||||
import shutil
|
||||
import uuid
|
||||
@@ -13,6 +11,13 @@ import tempfile
|
||||
from pathlib import Path
|
||||
from typing import Dict, Any
|
||||
|
||||
try:
|
||||
import fcntl
|
||||
import pty
|
||||
except ImportError:
|
||||
fcntl = None
|
||||
pty = None
|
||||
|
||||
from fastapi import APIRouter, Request, HTTPException
|
||||
from fastapi.responses import StreamingResponse
|
||||
from pydantic import BaseModel
|
||||
@@ -97,6 +102,11 @@ async def _exec_shell(command: str, timeout: int = EXEC_TIMEOUT) -> Dict[str, An
|
||||
|
||||
async def _generate_pty(cmd: str, timeout: int, request: Request):
|
||||
"""Run command in a pseudo-TTY so tqdm/progress bars work natively."""
|
||||
if pty is None or fcntl is None:
|
||||
yield f"data: {json.dumps({'stream': 'stderr', 'data': 'PTY streaming is not available on Windows'})}\n\n"
|
||||
yield f"data: {json.dumps({'exit_code': -1})}\n\n"
|
||||
return
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
master_fd, slave_fd = pty.openpty()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user