Update Ollama bot

This commit is contained in:
Manuel Vergara 2024-08-18 21:15:33 +02:00
parent dd48618093
commit dc9e81f06e
2 changed files with 36 additions and 9 deletions

View File

@ -5,10 +5,11 @@ import aiohttp
import json import json
from aiogram import types from aiogram import types
from aiohttp import ClientTimeout from aiohttp import ClientTimeout, ClientResponseError, RequestInfo
from asyncio import Lock from asyncio import Lock
from functools import wraps from functools import wraps
from dotenv import load_dotenv from dotenv import load_dotenv
from yarl import URL
load_dotenv('.env') load_dotenv('.env')
@ -72,11 +73,25 @@ async def generate(payload: dict, modelname: str, prompt: str):
if response.status != 200: if response.status != 200:
raise aiohttp.ClientResponseError( request_info = RequestInfo(
url=URL(url),
status=response.status, message=response.reason method='POST',
headers=response.request_info.headers,
real_url=response.request_info.real_url,
) )
raise ClientResponseError(
request_info=request_info,
history=tuple(),
status=response.status,
message=response.reason,
headers=response.headers
)
# raise aiohttp.ClientResponseError(
# status=response.status, message=response.reason
# )
buffer = b"" buffer = b""

View File

@ -1,18 +1,24 @@
# WORK IN PROGRESS
version: '3.8'
services: services:
ollama-tg: ollama-tg:
build: . build: .
container_name: ollama-tg container_name: ollama-tg
restart: on-failure restart: on-failure
env_file: env_file:
- ./.env - ./.env
networks:
- ollama-net
depends_on:
- ollama-api
ollama-api: ollama-api:
image: ollama/ollama:latest image: ollama/ollama:latest
container_name: ollama-server container_name: ollama-server
volumes: volumes:
- ./ollama:/root/.ollama - ./ollama:/root/.ollama
networks:
- ollama-net
# Descomenta para habilitar la GPU de NVIDIA # Descomenta para habilitar la GPU de NVIDIA
# De lo contrario, se ejecuta solo en la CPU: # De lo contrario, se ejecuta solo en la CPU:
@ -28,3 +34,9 @@ services:
restart: always restart: always
ports: ports:
- '11434:11434' - '11434:11434'
environment:
- OLLAMA_MODELS=/ollama/models
networks:
ollama-net:
driver: bridge