(20241205) LLM endpoint active now.
This commit is contained in:
+15
-7
@@ -75,6 +75,7 @@ from models.behaviour.mail.oauth_v2 import MailOAuthModel
|
||||
from models.behaviour.mail.sync_v2 import MailSyncModel
|
||||
from models.behaviour.mail.retrieve import MailRetrieveModel
|
||||
from models.behaviour.sms.auth import SMSAuthModel
|
||||
from models.behaviour.ai.llm.open_ai import LLMOpenAI
|
||||
|
||||
# To make REST API calls:
|
||||
import httpx
|
||||
@@ -91,13 +92,11 @@ from api.blueprints.mail.retrieve import mail_retrieve_bp
|
||||
from api.blueprints.sms.auth import sms_auth_bp
|
||||
from api.blueprints.tech.chat_alerts import tech_chat_alert_bp
|
||||
from api.blueprints.test.callback import test_callback_bp
|
||||
from api.blueprints.ai.llm.invoke import llm_invoke_bp
|
||||
|
||||
# All the helpers:
|
||||
from api.helpers.user import session
|
||||
|
||||
# To work with LLMs:
|
||||
from langchain_openai import ChatOpenAI
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
@@ -129,6 +128,7 @@ app.register_blueprint(mail_retrieve_bp, url_prefix = f"/{MODULE_BASE}/mail")
|
||||
app.register_blueprint(sms_auth_bp, url_prefix = f"/{MODULE_BASE}/sms")
|
||||
app.register_blueprint(tech_chat_alert_bp, url_prefix = f"/{MODULE_BASE}/tech/alert")
|
||||
app.register_blueprint(test_callback_bp, url_prefix = f"/{MODULE_BASE}/test")
|
||||
app.register_blueprint(llm_invoke_bp, url_prefix = f"/{MODULE_BASE}/ai")
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
@@ -200,7 +200,7 @@ async def app_startup(**kwargs):
|
||||
pool = 120.0, # .... Time to wait for a free connection from the pool.
|
||||
connect = 2.5, # ... Time to wait for establishing a connection to the server.
|
||||
write = 10.0, # .... Time to wait for sending data.
|
||||
read = 2.5 # ....... Time to wait for receiving data.
|
||||
read = 9.9 # ....... Time to wait for receiving data.
|
||||
)
|
||||
)
|
||||
|
||||
@@ -374,9 +374,17 @@ async def app_startup(**kwargs):
|
||||
# ┛
|
||||
|
||||
# For LLMs:
|
||||
current_app.llm = ChatOpenAI(
|
||||
model = script_cred["openAi"]["model"],
|
||||
openai_api_key = script_cred["openAi"]["openai_api_key"]
|
||||
current_app.llm = LLMOpenAI(
|
||||
llm_creds = {
|
||||
"model": script_cred["openAi"]["model"],
|
||||
"openai_api_key": script_cred["openAi"]["openai_api_key"]
|
||||
},
|
||||
cache = current_app.module_cache,
|
||||
alert_url = current_app.script_data["alerts"]["url"],
|
||||
http_client = current_app.http_client,
|
||||
debug = enable_debugging,
|
||||
debug_prefix = "AI (LLM) | ",
|
||||
debug_only_errors = True
|
||||
)
|
||||
|
||||
current_app.printer("AI ready.")
|
||||
|
||||
Reference in New Issue
Block a user