feat: inject request-local server time and freeze action asset contract
This commit is contained in:
@@ -3,11 +3,13 @@ import os
|
||||
from copy import deepcopy
|
||||
from urllib.parse import urlsplit
|
||||
from reply_emotion import REPLY_SCHEMA
|
||||
from server_clock import ServerClock
|
||||
|
||||
|
||||
class LLMProvider:
|
||||
def __init__(self, environ=None):
|
||||
env = os.environ if environ is None else environ
|
||||
self.clock = ServerClock(env.get('LAN_LLM_TIME_ZONE', 'Asia/Shanghai'))
|
||||
self.base_url = env.get('LAN_LLM_BASE_URL', 'http://127.0.0.1:8888/v1').rstrip('/')
|
||||
self.model = env.get('LAN_LLM_MODEL', 'qwen3.8-27b')
|
||||
self.api_key = env.get('LAN_LLM_API_KEY', '')
|
||||
@@ -31,7 +33,7 @@ class LLMProvider:
|
||||
raise ValueError('invalid LLM structured output mode')
|
||||
|
||||
def request(self, messages, *, max_tokens=64):
|
||||
body = {'model': self.model, 'messages': messages, 'max_tokens': max_tokens, 'temperature': 0.3, 'stream': True}
|
||||
body = {'model': self.model, 'messages': self.clock.messages(messages), 'max_tokens': max_tokens, 'temperature': 0.3, 'stream': True}
|
||||
if self.template_kwargs:
|
||||
body['chat_template_kwargs'] = self.template_kwargs
|
||||
if self.structured_output == 'json_schema':
|
||||
|
||||
Reference in New Issue
Block a user