Skip to content

Commit

Permalink
Merge branch 'f/fixing-sast-findings' into 'development'
Browse files Browse the repository at this point in the history
Fixed SAST findings

See merge request Deltix/openai-apps/bedrock-to-openai-adapter!14
  • Loading branch information
adubovik committed Sep 11, 2023
2 parents d8821d1 + 8ac88e4 commit 6883be2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
9 changes: 5 additions & 4 deletions client/client_adapter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import logging
from typing import List

import openai
Expand All @@ -12,9 +13,9 @@
from utils.args import get_host_port_args
from utils.cli import select_option
from utils.input import make_input
from utils.printing import print_ai, print_error
from utils.printing import print_exception as print_exc
from utils.printing import print_info
from utils.printing import print_ai, print_error, print_info

log = logging.getLogger(__name__)

DEFAULT_API_VERSION = "2023-03-15-preview"

Expand All @@ -32,7 +33,7 @@ def get_available_models(base_url: str) -> List[str]:


def print_exception(exc: Exception) -> None:
print_exc()
log.exception(exc)
if isinstance(exc, OpenAIError):
print_error(json.dumps(exc.json_body, indent=2))
else:
Expand Down
20 changes: 0 additions & 20 deletions utils/printing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import traceback

from colorama import Back, Fore, Style
from langchain.schema import AIMessage, BaseMessage, HumanMessage, SystemMessage


def get_input(prefix: str = "") -> str:
Expand Down Expand Up @@ -37,20 +34,3 @@ def print_human(msg: str, **args):

def print_ai(msg: str, **args):
print(Fore.BLUE + msg + Style.RESET_ALL, flush=True, **args)


def print_exception():
print(Fore.RED, flush=True)
traceback.print_exc()
print(Style.RESET_ALL, flush=True)


def print_base_message(msg: BaseMessage, **args):
if isinstance(msg, HumanMessage):
print_human(msg.content, **args)
elif isinstance(msg, AIMessage):
print_ai(msg.content, **args)
elif isinstance(msg, SystemMessage):
print_system(msg.content, **args)
else:
print(msg.content, **args)

0 comments on commit 6883be2

Please sign in to comment.