Skip to content

Commit

Permalink
chore: add warning to function calling with chat_round
Browse files Browse the repository at this point in the history
  • Loading branch information
zhudotexe committed Sep 18, 2023
1 parent 6933e7f commit b0a58f7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion kani/kani.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import inspect
import logging
import warnings
import weakref
from typing import AsyncIterable, Callable

Expand Down Expand Up @@ -124,12 +125,21 @@ async def chat_round(self, query: str, **kwargs) -> ChatMessage:
:param kwargs: Additional arguments to pass to the model engine (e.g. hyperparameters).
:returns: The model's reply.
"""
# warn if the user has functions defined and has not explicitly silenced them in this call
if self.functions and "include_functions" not in kwargs:
warnings.warn(
f"You have defined functions in the body of {type(self).__name__} but chat_round() will not call"
" functions. Use full_round() instead.\nIf this is intentional, use chat_round(...,"
" include_functions=False) to silence this warning."
)
kwargs = {**kwargs, "include_functions": False}
# do the chat round
async with self.lock:
# add the user's chat input to the state
await self.add_to_history(ChatMessage.user(query.strip()))

# and get a completion
completion = await self.get_model_completion(include_functions=False, **kwargs)
completion = await self.get_model_completion(**kwargs)
message = completion.message
await self.add_to_history(message)
return message
Expand Down

0 comments on commit b0a58f7

Please sign in to comment.