You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm noticing that when I have dynamic routes set up, there are cases where the routing selects a function call, but openai code throws an error due to (I think) the LLM not actually returning a tool call in the completion. Possibly this is because I am using the default LLM (I can't seem to get rid of this warning: WARNING semantic_router.utils.logger No LLM provided for dynamic route, will use OpenAI LLM default. Ensure API key is set in OPENAI_API_KEY environment variable.)
Error is thrown here:
if function_schemas:
tool_calls = completion.choices[0].message.tool_calls
if tool_calls is None: raise ValueError("Invalid output, expected a tool call.")
if len(tool_calls) < 1:
raise ValueError(
"Invalid output, expected at least one tool to be specified."
)
function_schemas = {'name': 'metacog_doc_loader', 'description': 'Loads a metacognition supplemental document related to the topic as context for the language model.\n\n:param topic: The topic which determines which file to load, and must be\n either "student-study", "time-management", or "none". Do NOT use any\n other topic.\n:type topic: str\n:return: The complete text of the loaded document or none if the topic was not known.', 'parameters': {'type': 'object', 'properties': {'topic': {'type': 'string', 'description': 'The topic which determines which file to load, and must be\n either "student-study", "time-management", or "none". Do NOT use any\n other topic.'}, 'config': {'type': 'object', 'description': 'No description available.'}}, 'required': ['topic']}}
But the chat completion is:
ChatCompletion(id='chatcmpl-AnV8oWIVf9mo2G5fUb5mc6Txisbvn', choices=[Choice(finish_reason='length', index=0, logprobs=None, message=ChatCompletionMessage(content="Setting realistic goals involves a few key steps:\n\n1. Self-Assessment: Understand your strengths, weaknesses, interests, and values. Reflect on past experiences to identify what has worked well for you and what hasn't.\n\n2. Research and Information Gathering: Learn about the requirements and challenges associated with your goal. This might involve talking to others who have achieved similar goals or reading relevant materials.\n\n3. SMART Criteria: Ensure your goals are Specific, Measurable, Achievable, Relevant, and Time-bound. This framework helps in setting clear and realistic objectives.\n\n4. Break Down Goals: Divide larger goals into smaller, manageable tasks. This makes it easier to track progress and adjust as needed.\n\n5. Seek Feedback: Discuss your goals with mentors, peers, or professionals who can provide insights and advice.\n\n6. Flexibility and Adaptation: Be prepared to adjust your goals based on new information or changes in circumstances.\n\n7. **Time Management", refusal=None, role='assistant', audio=None, function_call=None, tool_calls=None))], created=1736361142, model='gpt-4o-2024-08-06', object='chat.completion', service_tier=None, system_fingerprint='fp_d28bcae782', usage=CompletionUsage(completion_tokens=200, prompt_tokens=199, total_tokens=399, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=0, audio_tokens=0, reasoning_tokens=0, rejected_prediction_tokens=0), prompt_tokens_details=PromptTokensDetails(audio_tokens=0, cached_tokens=0)))
This is still very new to me, so it's entirely possible this is due to human error, but within a chat session that uses langgraph and semantic router, I'm see this a lot on short user messages that are vague, short, and probably should be out of scope of the main routes.
The text was updated successfully, but these errors were encountered:
I'm noticing that when I have dynamic routes set up, there are cases where the routing selects a function call, but openai code throws an error due to (I think) the LLM not actually returning a tool call in the completion. Possibly this is because I am using the default LLM (I can't seem to get rid of this warning: WARNING semantic_router.utils.logger No LLM provided for dynamic route, will use OpenAI LLM default. Ensure API key is set in OPENAI_API_KEY environment variable.)
Error is thrown here:
if function_schemas:
tool_calls = completion.choices[0].message.tool_calls
if tool_calls is None:
raise ValueError("Invalid output, expected a tool call.")
if len(tool_calls) < 1:
raise ValueError(
"Invalid output, expected at least one tool to be specified."
)
function_schemas = {'name': 'metacog_doc_loader', 'description': 'Loads a metacognition supplemental document related to the topic as context for the language model.\n\n:param topic: The topic which determines which file to load, and must be\n either "student-study", "time-management", or "none". Do NOT use any\n other topic.\n:type topic: str\n:return: The complete text of the loaded document or none if the topic was not known.', 'parameters': {'type': 'object', 'properties': {'topic': {'type': 'string', 'description': 'The topic which determines which file to load, and must be\n either "student-study", "time-management", or "none". Do NOT use any\n other topic.'}, 'config': {'type': 'object', 'description': 'No description available.'}}, 'required': ['topic']}}
But the chat completion is:
ChatCompletion(id='chatcmpl-AnV8oWIVf9mo2G5fUb5mc6Txisbvn', choices=[Choice(finish_reason='length', index=0, logprobs=None, message=ChatCompletionMessage(content="Setting realistic goals involves a few key steps:\n\n1. Self-Assessment: Understand your strengths, weaknesses, interests, and values. Reflect on past experiences to identify what has worked well for you and what hasn't.\n\n2. Research and Information Gathering: Learn about the requirements and challenges associated with your goal. This might involve talking to others who have achieved similar goals or reading relevant materials.\n\n3. SMART Criteria: Ensure your goals are Specific, Measurable, Achievable, Relevant, and Time-bound. This framework helps in setting clear and realistic objectives.\n\n4. Break Down Goals: Divide larger goals into smaller, manageable tasks. This makes it easier to track progress and adjust as needed.\n\n5. Seek Feedback: Discuss your goals with mentors, peers, or professionals who can provide insights and advice.\n\n6. Flexibility and Adaptation: Be prepared to adjust your goals based on new information or changes in circumstances.\n\n7. **Time Management", refusal=None, role='assistant', audio=None, function_call=None, tool_calls=None))], created=1736361142, model='gpt-4o-2024-08-06', object='chat.completion', service_tier=None, system_fingerprint='fp_d28bcae782', usage=CompletionUsage(completion_tokens=200, prompt_tokens=199, total_tokens=399, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=0, audio_tokens=0, reasoning_tokens=0, rejected_prediction_tokens=0), prompt_tokens_details=PromptTokensDetails(audio_tokens=0, cached_tokens=0)))
This is still very new to me, so it's entirely possible this is due to human error, but within a chat session that uses langgraph and semantic router, I'm see this a lot on short user messages that are vague, short, and probably should be out of scope of the main routes.
The text was updated successfully, but these errors were encountered: