mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 15:48:29 +00:00
wip
This commit is contained in:
@@ -183,7 +183,6 @@ class LLM:
|
|||||||
tools: Optional[List[dict]] = None,
|
tools: Optional[List[dict]] = None,
|
||||||
callbacks: Optional[List[Any]] = None,
|
callbacks: Optional[List[Any]] = None,
|
||||||
available_functions: Optional[Dict[str, Any]] = None,
|
available_functions: Optional[Dict[str, Any]] = None,
|
||||||
response_format: Optional[BaseModel] = None,
|
|
||||||
) -> str:
|
) -> str:
|
||||||
"""
|
"""
|
||||||
High-level LLM call method that handles:
|
High-level LLM call method that handles:
|
||||||
@@ -280,7 +279,8 @@ class LLM:
|
|||||||
params = {k: v for k, v in params.items() if v is not None}
|
params = {k: v for k, v in params.items() if v is not None}
|
||||||
|
|
||||||
# --- Direct structured response if no tools are provided.
|
# --- Direct structured response if no tools are provided.
|
||||||
if response_format is not None and (tools is None or len(tools) == 0):
|
if self.response_format is not None and (tools is None or len(tools) == 0):
|
||||||
|
print("Direct structured response")
|
||||||
try:
|
try:
|
||||||
# Cast messages to required type and remove model param
|
# Cast messages to required type and remove model param
|
||||||
params["messages"] = cast(
|
params["messages"] = cast(
|
||||||
@@ -297,6 +297,7 @@ class LLM:
|
|||||||
|
|
||||||
# --- Standard flow with potential tool calls.
|
# --- Standard flow with potential tool calls.
|
||||||
try:
|
try:
|
||||||
|
print("NOT DIRECT STRUCTURED RESPONSE")
|
||||||
response = litellm.completion(**params)
|
response = litellm.completion(**params)
|
||||||
response_message = cast(Choices, cast(ModelResponse, response).choices)[
|
response_message = cast(Choices, cast(ModelResponse, response).choices)[
|
||||||
0
|
0
|
||||||
@@ -341,7 +342,7 @@ class LLM:
|
|||||||
return text_response
|
return text_response
|
||||||
|
|
||||||
# If a structured response is requested, perform a secondary call using the tool result.
|
# If a structured response is requested, perform a secondary call using the tool result.
|
||||||
if response_format is not None:
|
if self.response_format is not None:
|
||||||
new_params = dict(params)
|
new_params = dict(params)
|
||||||
# Cast tool result message to required type
|
# Cast tool result message to required type
|
||||||
new_params["messages"] = cast(
|
new_params["messages"] = cast(
|
||||||
|
|||||||
Reference in New Issue
Block a user