You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0

openai 1.0.0 이상의 버전에서는 openai.ChatCompletion으로 completion을 생성할 수 없고

먼저 client를 생성한 후 client에서 completion을 받도록 변경되었습니다.

그와 관련된 오류메세지입니다.

구버전의 openai client 용 코드를 1.0.0보다 높은 버전의 openai client에서 사용하고 있다는 메시지입니다.

아래 링크의 문서를 확인해 보시고

https://github.com/openai/openai-python

다음과 같은 방식으로 기존 코드를 수정해 주어야 합니다.

from openai import OpenAI

client = OpenAI(
    # defaults to os.environ.get("OPENAI_API_KEY")
    api_key="My API Key",
)

chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "Say this is a test",
        }
    ],
    model="gpt-3.5-turbo",
)

Pyperclip could not find a copy/paste mechanism for your system.

Pyperclip을 사용할 때 다음과 같은 에러가 발생할 때가 있다.

Pyperclip could not find a copy/paste mechanism for your system.

필요한 패키지가 리눅스에 설치되어 있지 않아서 그렇다.
필요한 패키지를 설치해주자.

sudo apt-get install xsel
sudo apt-get install xclip
pip install gtk
pip install PyQt4

이 패키지는 지저분한 패키지를 같이 설치한다.
그래서 꼭 써야하는 것이 아니라면 안쓰는 것이 좋다.

참조: https://pyperclip.readthedocs.io/en/latest/

GPT assistant file의 업로드 오류 메세지

OpenAI GPT API로 assistant file을 업로드하다 오류가 발생하면 아래와 같이 매우 장황한 설명을 합니다.

오류의 대부분은 다음과 같은 이유가 대부분입니다.

  • PDF형식이 이상해서 텍스트를 추출하지 못함
  • 파일이 깨짐
  • 파일 요량 초과

메세지는 기록을 위해서 여기에 저장해 둡니다.

It appears that the content extracted from the PDF file is not meaningful text, but rather a mix of symbols and characters, which likely means that the text within the PDF is either stored in a non-standard format, such as images or custom encoding, or the file may contain primarily images rather than text.

Unfortunately, without a more sophisticated PDF analysis tool that can handle optical character recognition (OCR) to interpret any images as text, or specific knowledge of the file’s encoding, we might not be able to extract readable content from the PDF in this environment.

Nonetheless, if the PDF file contains information on how to create an account and register app information with “xxxxxxxxx,” you would typically follow the instructions provided within the document, which usually involve navigating to a specific URL and filling out forms with the necessary information.

If you have a specific tool or method in mind for attempting to parse the PDF content further, or if the file should be used in a particular context, please let me know and I’ll do my best to assist you further.

*****************************************************************************

The hexadecimal representation of the first few bytes of the file is `’25504446’`, which corresponds to the magic number for a PDF (Portable Document Format) file. The magic number `0x25504446` stands for `%PDF` in ASCII, which is the signature for PDF files.

Now that we know it’s a PDF file, we can attempt to extract its text content (if it contains any) using a PDF reading library. Let’s try that next.

*****************************************************************************

The file does not have an extension, making it challenging to determine its type based on the name alone. Since I wasn’t able to open it as a text file directly due to an encoding issue, I will now attempt to use a different method to read the file as binary data and then analyze the first few bytes to infer the file type. This is often referred to as checking the “magic number” of the file, which can give us clues about the file format. Let’s proceed with this method.

*****************************************************************************

My apologies for the confusion, it seems that the python-magic module I intended to use to detect the file type is not available in this environment. Let me try another approach to determine the file type. I will first attempt to check the file extension and then try a different way to check the content type if necessary.

*****************************************************************************

It looks like the file may not be a text file or it might not be encoded in UTF-8. The next step is to try to infer the file type or encoding. Let’s start by attempting to detect the file type based on its content.

I will now attempt to analyze the file to identify its type and then proceed accordingly. If it is a binary file, such as an image or an executable, we won’t be able to directly view its content as text. If it’s an archive or a document, we might need to take additional steps to extract and view the content. Let’s determine the file type first.

우분투에 포스트그레스 설치 – Install PostgreSQL on Ubuntu Linux

아래의 순서로 하면됩니다.

# Create the file repository configuration:
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

# Import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

# Update the package lists:
sudo apt-get update

# Install the latest version of PostgreSQL.
# If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
sudo apt-get -y install postgresql

자세한 내용은 아래 원문을 참고하세요.

https://www.postgresql.org/download/linux/ubuntu/

Rstudio server에서 Copilot 사용하기

Rstudio 2023년 9월 28일 릴리즈 버전 이후부터는 Github copilot을 정식지원합니다.

neovim의 plugin을 이용해서 연동한 것인데 깔끔하게 잘 작동합니다.

Rstduio desktop을 설치하면 옵션에서 설정하고 로그인만한 하면 그냥 잘 작동하는데 Rstudio server는 옵션을 활성화하려고 하면 어드민이 허용을 해주지 않았다는 메세지가 나옵니다.

그래서 추가 설정이 필요합니다.

리눅스 서버에 ssh로 접속해서 /etc/rstudion/rsession.conf을 열어줍니다.

이 파일을 Rstudio server가 사용자별로 세션을 새로 로딩할 때 초기화하기 위해 사용하는 파일입니다.

sudo vim /etc/rstudio/rsession.conf

그리고 다음 줄을 추가해줍니다.

copilot-enabled=1

옵션에서 github copilot을 활성화하고 로그인을 합니다.

아래와 같이 나오면 된 것입니다.