Fix nested pydantic model issue (#1905)

* Fix nested pydantic model issue

* fix failing tests

* add in vcr

* cleanup

* drop prints

* Fix vcr issues

* added new recordings

* trying to fix vcr

* add in fix from lorenze.
This commit is contained in:
Brandon Hancock (bhancock_ai)
2025-01-16 11:28:58 -05:00
committed by GitHub
parent 42311d9c7a
commit b5779dca12
10 changed files with 3624 additions and 61 deletions

View File

@@ -11,12 +11,10 @@ class InternalInstructor:
model: Type,
agent: Optional[Any] = None,
llm: Optional[str] = None,
instructions: Optional[str] = None,
):
self.content = content
self.agent = agent
self.llm = llm
self.instructions = instructions
self.model = model
self._client = None
self.set_instructor()
@@ -31,10 +29,7 @@ class InternalInstructor:
import instructor
from litellm import completion
self._client = instructor.from_litellm(
completion,
mode=instructor.Mode.TOOLS,
)
self._client = instructor.from_litellm(completion)
def to_json(self):
model = self.to_pydantic()
@@ -42,8 +37,6 @@ class InternalInstructor:
def to_pydantic(self):
messages = [{"role": "user", "content": self.content}]
if self.instructions:
messages.append({"role": "system", "content": self.instructions})
model = self._client.chat.completions.create(
model=self.llm.model, response_model=self.model, messages=messages
)