From 6c1c8abc263f5d15da3d7c8eb1929f6d58bc1db5 Mon Sep 17 00:00:00 2001 From: Vasilije <8619304+Vasilije1990@users.noreply.github.com> Date: Thu, 16 Jan 2025 13:26:37 +0100 Subject: [PATCH] Update adapter.py --- cognee/infrastructure/llm/openai/adapter.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/cognee/infrastructure/llm/openai/adapter.py b/cognee/infrastructure/llm/openai/adapter.py index 7f12947fd..d45662380 100644 --- a/cognee/infrastructure/llm/openai/adapter.py +++ b/cognee/infrastructure/llm/openai/adapter.py @@ -12,7 +12,6 @@ from cognee.infrastructure.llm.llm_interface import LLMInterface from cognee.infrastructure.llm.prompts import read_query_prompt from cognee.base_config import get_base_config - monitoring = get_base_config().monitoring_tool if monitoring == MonitoringTool.LANGFUSE: from langfuse.decorators import observe @@ -35,14 +34,19 @@ class OpenAIAdapter(LLMInterface): transcription_model: str, streaming: bool = False, ): + self.aclient = instructor.from_litellm(litellm.acompletion) + self.client = instructor.from_litellm(litellm.completion) + self.transcription_model = transcription_model + self.model = model + self.api_key = api_key + self.endpoint = endpoint + self.api_version = api_version + self.streaming = streaming - - - - @observe(as_type='generation') - async def acreate_structured_output(self, text_input: str, system_prompt: str, - response_model: Type[BaseModel]) -> BaseModel: - + @observe(as_type="generation") + async def acreate_structured_output( + self, text_input: str, system_prompt: str, response_model: Type[BaseModel] + ) -> BaseModel: """Generate a response from a user query.""" return await self.aclient.chat.completions.create(