function calling: start callback should have function name first

This commit is contained in:
Aleix Conchillo Flaqué
2024-08-18 20:48:20 -07:00
parent ef0d0531fa
commit f3a4e54996
4 changed files with 9 additions and 9 deletions

View File

@@ -32,7 +32,7 @@ logger.remove(0)
logger.add(sys.stderr, level="DEBUG")
async def start_fetch_weather(llm, context, function_name):
async def start_fetch_weather(function_name, llm, context):
await llm.push_frame(TextFrame("Let me check on that."))

View File

@@ -122,7 +122,7 @@ class IntakeProcessor:
# The user provided an incorrect birthday; ask them to try again
await result_callback([{"role": "system", "content": "The user provided an incorrect birthday. Ask them for their birthday again. When they answer, call the verify_birthday function."}])
async def start_prescriptions(self, llm, context, function_name):
async def start_prescriptions(self, function_name, llm, context):
print(f"!!! doing start prescriptions")
# Move on to allergies
context.set_tools(
@@ -157,7 +157,7 @@ class IntakeProcessor:
await llm.process_frame(OpenAILLMContextFrame(context), FrameDirection.DOWNSTREAM)
print(f"!!! past await process frame in start prescriptions")
async def start_allergies(self, llm, context, function_name):
async def start_allergies(self, function_name, llm, context):
print("!!! doing start allergies")
# Move on to conditions
context.set_tools(
@@ -191,7 +191,7 @@ class IntakeProcessor:
"content": "Now ask the user if they have any medical conditions the doctor should know about. Once they've answered the question, call the list_conditions function."})
await llm.process_frame(OpenAILLMContextFrame(context), FrameDirection.DOWNSTREAM)
async def start_conditions(self, llm, context, function_name):
async def start_conditions(self, function_name, llm, context):
print("!!! doing start conditions")
# Move on to visit reasons
context.set_tools(
@@ -224,7 +224,7 @@ class IntakeProcessor:
"content": "Finally, ask the user the reason for their doctor visit today. Once they answer, call the list_visit_reasons function."})
await llm.process_frame(OpenAILLMContextFrame(context), FrameDirection.DOWNSTREAM)
async def start_visit_reasons(self, llm, context, function_name):
async def start_visit_reasons(self, function_name, llm, context):
print("!!! doing start visit reasons")
# move to finish call
context.set_tools([])

View File

@@ -323,9 +323,9 @@ class RTVIProcessor(FrameProcessor):
async def handle_function_call_start(
self,
function_name: str,
llm: FrameProcessor,
context: OpenAILLMContext,
function_name: str):
context: OpenAILLMContext):
fn = RTVILLMFunctionCallStartMessageData(function_name=function_name)
message = RTVILLMFunctionCallStartMessage(data=fn)
await self._push_transport_message(message, exclude_none=False)

View File

@@ -140,9 +140,9 @@ class LLMService(AIService):
# QUESTION FOR CB: maybe this isn't needed anymore?
async def call_start_function(self, context: OpenAILLMContext, function_name: str):
if function_name in self._start_callbacks.keys():
await self._start_callbacks[function_name](self, context, function_name)
await self._start_callbacks[function_name](function_name, self, context)
elif None in self._start_callbacks.keys():
return await self._start_callbacks[None](self, context, function_name)
return await self._start_callbacks[None](function_name, self, context)
async def request_image_frame(self, user_id: str, *, text_content: str | None = None):
await self.push_frame(UserImageRequestFrame(user_id=user_id, context=text_content),