Из конфига удалена температура модели (параметры пока будут задаваться в пресете OpenRouter).
This commit is contained in:
parent
a1e5d4d2e8
commit
2e7f2d0632
3 changed files with 4 additions and 8 deletions
10
ai_agent.py
10
ai_agent.py
|
|
@ -30,14 +30,13 @@ class Message:
|
||||||
|
|
||||||
|
|
||||||
class AiAgent:
|
class AiAgent:
|
||||||
def __init__(self, api_token: str, model: str, model_temp: float, db: BasicDatabase):
|
def __init__(self, api_token: str, model: str, db: BasicDatabase):
|
||||||
retry_config = RetryConfig(strategy="backoff",
|
retry_config = RetryConfig(strategy="backoff",
|
||||||
backoff=BackoffStrategy(
|
backoff=BackoffStrategy(
|
||||||
initial_interval=2000, max_interval=8000, exponent=2, max_elapsed_time=14000),
|
initial_interval=2000, max_interval=8000, exponent=2, max_elapsed_time=14000),
|
||||||
retry_connection_errors=True)
|
retry_connection_errors=True)
|
||||||
self.db = db
|
self.db = db
|
||||||
self.model = model
|
self.model = model
|
||||||
self.model_temp = model_temp
|
|
||||||
self.client = OpenRouter(api_key=api_token, retry_config=retry_config)
|
self.client = OpenRouter(api_key=api_token, retry_config=retry_config)
|
||||||
|
|
||||||
async def get_group_chat_reply(self, bot_id: int, chat_id: int,
|
async def get_group_chat_reply(self, bot_id: int, chat_id: int,
|
||||||
|
|
@ -56,8 +55,7 @@ class AiAgent:
|
||||||
response = await self.client.chat.send_async(
|
response = await self.client.chat.send_async(
|
||||||
model=self.model,
|
model=self.model,
|
||||||
messages=context,
|
messages=context,
|
||||||
max_tokens=500,
|
max_tokens=500
|
||||||
temperature=self.model_temp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Extract AI response
|
# Extract AI response
|
||||||
|
|
@ -136,6 +134,6 @@ class AiAgent:
|
||||||
agent: AiAgent
|
agent: AiAgent
|
||||||
|
|
||||||
|
|
||||||
def create_ai_agent(api_token: str, model: str, model_temp: float, db: BasicDatabase):
|
def create_ai_agent(api_token: str, model: str, db: BasicDatabase):
|
||||||
global agent
|
global agent
|
||||||
agent = AiAgent(api_token, model, model_temp, db)
|
agent = AiAgent(api_token, model, db)
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ async def main() -> None:
|
||||||
|
|
||||||
create_ai_agent(config['openrouter_token'],
|
create_ai_agent(config['openrouter_token'],
|
||||||
config['openrouter_model'],
|
config['openrouter_model'],
|
||||||
config['openrouter_model_temp'],
|
|
||||||
database.DB)
|
database.DB)
|
||||||
|
|
||||||
bots: list[Bot] = []
|
bots: list[Bot] = []
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
create_ai_agent(config['openrouter_token'],
|
create_ai_agent(config['openrouter_token'],
|
||||||
config['openrouter_model'],
|
config['openrouter_model'],
|
||||||
config['openrouter_model_temp'],
|
|
||||||
database.DB)
|
database.DB)
|
||||||
|
|
||||||
bot = Bot(labeler=handlers.labeler)
|
bot = Bot(labeler=handlers.labeler)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue