2
This commit is contained in:
1 parent
c1c0dfca9e
commit
60beb1e00f
2 files changed
+19
-26
No files matched your search
+3
-2
@@ -1,14 +1,15 @@
|
||||
FROM mcr.microsoft.com/playwright/python:v1.49.0-noble
|
||||
|
||||
# Установка дополнительных Python зависимостей
|
||||
RUN pip install --no-cache-dir \
|
||||
RUN pip install --no-cache-dir --root-user-action=ignore \
|
||||
fastapi \
|
||||
uvicorn \
|
||||
pydantic \
|
||||
browser-use \
|
||||
langchain-openai \
|
||||
langchain \
|
||||
python-dotenv
|
||||
python-dotenv \
|
||||
setuptools
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
||||
@@ -19,33 +19,25 @@ REMOTE_DEBUGGING_ENABLED = os.getenv("REMOTE_DEBUGGING_ENABLED", "false").lower(
|
||||
# Модель по умолчанию из переменной окружения
|
||||
DEFAULT_MODEL = os.getenv("LLM_MODEL_NAME", "openai/gpt-4o-mini")
|
||||
|
||||
app = FastAPI(title="Browser Use API", version="1.0.0")
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
# Startup logic
|
||||
import sys
|
||||
from importlib import metadata
|
||||
print(f"Python version: {sys.version}")
|
||||
print("Installed packages:")
|
||||
dists = metadata.distributions()
|
||||
for dist in dists:
|
||||
print(f" {dist.metadata['Name']}=={dist.version}")
|
||||
yield
|
||||
# Shutdown logic (if needed)
|
||||
|
||||
app = FastAPI(title="Browser Use API", version="1.0.0", lifespan=lifespan)
|
||||
|
||||
# Модели запросов
|
||||
class TaskRequest(BaseModel):
|
||||
task: str
|
||||
max_steps: Optional[int] = 20
|
||||
model: Optional[str] = None
|
||||
|
||||
class TaskResponse(BaseModel):
|
||||
task_id: str
|
||||
status: str
|
||||
result: Optional[str] = None
|
||||
error: Optional[str] = None
|
||||
|
||||
# Хранилище задач
|
||||
tasks = {}
|
||||
|
||||
@app.on_event("startup")
|
||||
async def startup_event():
|
||||
import sys
|
||||
import pkg_resources
|
||||
print(f"Python version: {sys.version}")
|
||||
print("Installed packages:")
|
||||
for dist in pkg_resources.working_set:
|
||||
print(f" {dist.project_name}=={dist.version}")
|
||||
|
||||
@app.post("/api/tasks", response_model=TaskResponse)
|
||||
async def create_task(request: TaskRequest):
|
||||
"""Создать новую задачу браузера"""
|
||||
import uuid
|
||||
|
||||
Reference in new issue
Block a user