Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tool Call Improvements #71

Merged
merged 12 commits into from
Feb 17, 2025
27 changes: 2 additions & 25 deletions defog/llm/models.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
from pydantic import BaseModel
from pydantic import BaseModel, Field
from enum import Enum
from typing import Optional, Union, Dict, Any


class OpenAIToolChoice(Enum):
AUTO = "auto" # default if not provided. calls 0, 1, or multiple functions
REQUIRED = "required" # calls at least 1 function
NONE = "none" # calls no functions
from typing import Optional, Union, Dict, Any, Literal


class OpenAIFunctionSpecs(BaseModel):
Expand All @@ -17,26 +11,9 @@ class OpenAIFunctionSpecs(BaseModel):
)


class OpenAIForcedFunction(BaseModel):
# a forced function call - forces a call to one specific function
type: str = "function"
function: OpenAIFunctionSpecs


class AnthropicToolChoice(Enum):
AUTO = "auto" # default if not provided. calls 0, 1, or multiple functions
REQUIRED = "required" # calls at least 1 function


class AnthropicFunctionSpecs(BaseModel):
name: str # name of the function to call
description: Optional[str] = None # description of the function
input_schema: Optional[Union[str, Dict[str, Any]]] = (
None # parameters of the function
)


class AnthropicForcedFunction(BaseModel):
# a forced function call - forces a call to one specific function
type: str = "function"
function: AnthropicFunctionSpecs
Loading