function calling: start callback should have function name first
This commit is contained in:
@@ -32,7 +32,7 @@ logger.remove(0)
|
|||||||
logger.add(sys.stderr, level="DEBUG")
|
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."))
|
await llm.push_frame(TextFrame("Let me check on that."))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ class IntakeProcessor:
|
|||||||
# The user provided an incorrect birthday; ask them to try again
|
# 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."}])
|
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")
|
print(f"!!! doing start prescriptions")
|
||||||
# Move on to allergies
|
# Move on to allergies
|
||||||
context.set_tools(
|
context.set_tools(
|
||||||
@@ -157,7 +157,7 @@ class IntakeProcessor:
|
|||||||
await llm.process_frame(OpenAILLMContextFrame(context), FrameDirection.DOWNSTREAM)
|
await llm.process_frame(OpenAILLMContextFrame(context), FrameDirection.DOWNSTREAM)
|
||||||
print(f"!!! past await process frame in start prescriptions")
|
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")
|
print("!!! doing start allergies")
|
||||||
# Move on to conditions
|
# Move on to conditions
|
||||||
context.set_tools(
|
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."})
|
"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)
|
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")
|
print("!!! doing start conditions")
|
||||||
# Move on to visit reasons
|
# Move on to visit reasons
|
||||||
context.set_tools(
|
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."})
|
"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)
|
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")
|
print("!!! doing start visit reasons")
|
||||||
# move to finish call
|
# move to finish call
|
||||||
context.set_tools([])
|
context.set_tools([])
|
||||||
|
|||||||
@@ -323,9 +323,9 @@ class RTVIProcessor(FrameProcessor):
|
|||||||
|
|
||||||
async def handle_function_call_start(
|
async def handle_function_call_start(
|
||||||
self,
|
self,
|
||||||
|
function_name: str,
|
||||||
llm: FrameProcessor,
|
llm: FrameProcessor,
|
||||||
context: OpenAILLMContext,
|
context: OpenAILLMContext):
|
||||||
function_name: str):
|
|
||||||
fn = RTVILLMFunctionCallStartMessageData(function_name=function_name)
|
fn = RTVILLMFunctionCallStartMessageData(function_name=function_name)
|
||||||
message = RTVILLMFunctionCallStartMessage(data=fn)
|
message = RTVILLMFunctionCallStartMessage(data=fn)
|
||||||
await self._push_transport_message(message, exclude_none=False)
|
await self._push_transport_message(message, exclude_none=False)
|
||||||
|
|||||||
@@ -140,9 +140,9 @@ class LLMService(AIService):
|
|||||||
# QUESTION FOR CB: maybe this isn't needed anymore?
|
# QUESTION FOR CB: maybe this isn't needed anymore?
|
||||||
async def call_start_function(self, context: OpenAILLMContext, function_name: str):
|
async def call_start_function(self, context: OpenAILLMContext, function_name: str):
|
||||||
if function_name in self._start_callbacks.keys():
|
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():
|
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):
|
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),
|
await self.push_frame(UserImageRequestFrame(user_id=user_id, context=text_content),
|
||||||
|
|||||||
Reference in New Issue
Block a user