[Misc] Lint code and fix code smells (#1871)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import os
|
||||
import json
|
||||
|
||||
import os
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from openai import OpenAI
|
||||
@@ -20,7 +19,6 @@ class OpenAIStructuredLLM(LLMBase):
|
||||
base_url = self.config.openai_base_url or os.getenv("OPENAI_API_BASE")
|
||||
self.client = OpenAI(api_key=api_key, base_url=base_url)
|
||||
|
||||
|
||||
def _parse_response(self, response, tools):
|
||||
"""
|
||||
Process the response based on whether tools are used or not.
|
||||
@@ -31,8 +29,8 @@ class OpenAIStructuredLLM(LLMBase):
|
||||
|
||||
Returns:
|
||||
str or dict: The processed response.
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
if tools:
|
||||
processed_response = {
|
||||
"content": response.choices[0].message.content,
|
||||
@@ -52,7 +50,6 @@ class OpenAIStructuredLLM(LLMBase):
|
||||
|
||||
else:
|
||||
return response.choices[0].message.content
|
||||
|
||||
|
||||
def generate_response(
|
||||
self,
|
||||
@@ -87,4 +84,4 @@ class OpenAIStructuredLLM(LLMBase):
|
||||
|
||||
response = self.client.beta.chat.completions.parse(**params)
|
||||
|
||||
return self._parse_response(response, tools)
|
||||
return self._parse_response(response, tools)
|
||||
|
||||
Reference in New Issue
Block a user