Skip to content

Commit

Permalink
Fix bug with tools caching
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaGusev committed Jul 9, 2024
1 parent a3666b3 commit 9f12192
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@ async def generate(self, message: Message) -> None:
history = self.db.fetch_conversation(conv_id)
params = self.db.get_parameters(chat_id)
params = provider.params if params is None else params
params = copy.deepcopy(params)
system_prompt = self.db.get_system_prompt(chat_id)
system_prompt = provider.system_prompt if system_prompt is None else system_prompt
content = await self._build_content(message)
Expand Down Expand Up @@ -934,11 +935,15 @@ async def debug(self, message: Message, command: CommandObject) -> None:
history = self._prepare_history(history, provider, False)
params = self.db.get_parameters(user_id)
params = provider.params if params is None else params
params = copy.deepcopy(params)
system_prompt = self.db.get_system_prompt(user_id)
system_prompt = provider.system_prompt if system_prompt is None else system_prompt
placeholder = await message.reply("💬")
history = self._fix_image_roles(history)
history = self._fix_broken_tool_calls(history)
history = self._merge_messages(history)
if history[-1]["role"] == "assistant":
history.pop()
answer = await self._query_api(provider=provider, messages=history, system_prompt=system_prompt, **params)
await placeholder.edit_text(answer[: self.config.output_chunk_size])

Expand Down
1 change: 1 addition & 0 deletions src/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ def get_parameters(self, user_id: int) -> Optional[Dict[str, Any]]:
params = self.get_current_model_parameters(user_id)
if params and params.generation_parameters and params.generation_parameters != "null":
parsed_params: Dict[str, Any] = json.loads(params.generation_parameters)
parsed_params.pop("tools", None)
return parsed_params
return None

Expand Down

0 comments on commit 9f12192

Please sign in to comment.