Skip to content

Commit

Permalink
fix(oci) add initialization step
Browse files Browse the repository at this point in the history
Run a small generation to make sure we have downloaded the cached
transformers config.
  • Loading branch information
saghul committed Feb 20, 2025
1 parent a9fafb6 commit f256fdd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
40 changes: 40 additions & 0 deletions skynet/modules/ttt/oci/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from langchain_community.chat_models import ChatOCIGenAI
from langchain_core.messages import HumanMessage, SystemMessage

from skynet.env import (
oci_auth_type,
oci_compartment_id,
oci_config_profile,
oci_model_id,
oci_service_endpoint,
use_oci,
)


async def initialize():
if not use_oci:
return

# Prime it so all transformers config is downloaded.
model_kwargs = {
"temperature": 0,
"frequency_penalty": 1,
"max_tokens": None,
}

llm = ChatOCIGenAI(
model_id=oci_model_id,
service_endpoint=oci_service_endpoint,
compartment_id=oci_compartment_id,
provider="meta",
model_kwargs=model_kwargs,
auth_type=oci_auth_type,
auth_profile=oci_config_profile,
)

messages = [
SystemMessage(content="Your are an AI assistant."),
HumanMessage(content="Hello."),
]

await llm.ainvoke(messages)
5 changes: 4 additions & 1 deletion skynet/modules/ttt/summaries/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from skynet.auth.user_info import setup_credentials
from skynet.env import echo_requests_base_url, echo_requests_percent, echo_requests_token
from skynet.logs import get_logger
from skynet.modules.ttt.oci.utils import initialize as initialize_oci
from skynet.modules.ttt.openai_api.app import initialize as initialize_openai_api
from skynet.utils import create_app
from ..persistence import db
Expand Down Expand Up @@ -56,14 +57,16 @@ async def executor_startup():

initialize_openai_api()

log.info('summaries:executor module initialized')
await initialize_oci()

await db.initialize()
log.info('Persistence initialized')

start_monitoring_jobs()
log.info('Jobs monitoring started')

log.info('summaries:executor module initialized')


async def executor_shutdown():
await db.close()
Expand Down

0 comments on commit f256fdd

Please sign in to comment.