OpenAI API 키 설정

:bookmark: 이 가이드는 OpenAI의 API 키를 설정하여 제3자 LLM 키가 필요한 Discourse AI 기능을 활성화하는 방법을 설명합니다.

:person_raising_hand: 필요한 사용자 권한: 관리자

이 예제에서는 OpenAI를 사용하여 키를 생성합니다.

참고: 유료 플랜이 필요하며 사용량에 따라 요금이 부과될 수 있습니다. 최신 세부 정보 및 요금제를 확인하세요.

플랫폼은 항상 변경되므로 이 가이드가 100%의 과정을 반영하지 않을 수 있습니다.

:information_source: 특정 AI 모듈을 사용하려면 OpenAI(ChatGPT), Anthropic(Claude), Google(Gemini) 등의 제3자 제공업체에서 발급한 API 키가 필요합니다.

각 AI 모듈에서 어떤 제3자 제공업체를 사용할 수 있는지 확인하세요.

API 키 생성

  1. Open AI에 로그인합니다. API 키는 OpenAI Platform에서 얻을 수 있습니다.
  2. API 키를 생성합니다.
  3. 키가 생성되면 안전하고 안전한 곳에 저장하고 복사합니다.

Discourse AI에서 API 키 사용

Discourse AI는 API 키를 관리하기 위해 Secrets 시스템을 사용합니다. 개별 LLM 설정에 키를 직접 붙여 넣는 대신, 이름이 지정된 시크릿을 생성한 후 하나 이상의 LLM에서 이를 참조합니다.

시크릿 생성 (선택 사항, 인라인으로 수행 가능)

  1. AdminPluginsAISecrets 탭으로 이동합니다.
  2. New Secret을 클릭합니다.
  3. 시크릿의 이름을 입력합니다 (예: “OpenAI API Key”).
  4. API 키를 Secret 필드에 붙여 넣습니다.
  5. 시크릿을 저장합니다.

LLM 구성

  1. AdminPluginsAILLMs 탭으로 이동합니다.
  2. 사전 구성된 모델 템플릿(예: OpenAI 모델)을 선택하고 해당 Configure 버튼을 클릭하거나, 이미 구성된 LLM에서 Edit을 클릭합니다.
  3. API Key 필드에서 드롭다운 메뉴를 통해 생성한 시크릿을 선택합니다. 드롭다운 옆의 + 버튼을 클릭하여 새로운 시크릿을 인라인으로 생성할 수도 있습니다.
  4. LLM을 저장합니다.
6개의 좋아요

no matter what we do, it always says openai gpt-4 not configured.

what am i missing?

2개의 좋아요

Where is this popping up for you and I’m assuming you have inputted in the OpenAI key? where there any other settings you have changed? have you tried a refresh on the browser post inputting in the key - does that help?

we have three valid openai keys we use for other things so i know they work.

no matter what we do, this is an example of the rror we get:

What’s the output of running

curl https://api.openai.com/v1/chat/completions   -H "Content-Type: application/json"   -H "Authorization: Bearer $OPENAI_API_KEY"   -d '{
    "model": "gpt-4",
    "messages": [
      {
        "role": "system",
        "content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair."
      },
      {
        "role": "user",
        "content": "Compose a poem that explains the concept of recursion in programming."
      }
    ]
  }'

in your Discourse server? Don’t forget to place your API key on the command.

3개의 좋아요

will login to our server and check this out.

{
“id”: “chatcmpl-8vT2UYe6i5m9EO0N4KdG6klcO4dVJ”,
“object”: “chat.completion”,
“created”: 1708707014,
“model”: “gpt-4-0613”,
“choices”: [
{
“index”: 0,
“message”: {
“role”: “assistant”,
“content”: “A tale within a tale untold,\nAn echo of a mirrored call,\nSuch is used in software’s sprawl,\nA concept called recursion, all.\n\nImagine a box within a box,\nEach pregnant with the one before,\nEach step to the origin restores,\nInfinite layers, like paradox.\n\nLike Russian dolls, a dream within,\nEach smaller than the one outside,\nYet hiding life within they reside,\nA patterned approach to chaos, therein.\n\nFrom problem to sub-problem, there,\nEach atom is an image proud,\nOf the larger form that’s to be found,\nTwisted whirls of logic’s flare.\n\nConjuring functions that call their own,\nIt tumbles down, a spiral vast,\nBut in the base case, it rests at last,\nThe seeds of recursion thus are sown.\n\nIn every loop’s heart you’ll find,\nA recursion lightly spinning, twined.\nWith every thread of question lined,\nIt folds back on itself, yet unconfined.\n\nBut dear programmers, mind your step,\nInfinite loops are hell’s gateway,\nKeep thy base case in the array,\nThe art of recursion, now adept.\n\nRepeating tasks, yet ever smaller,\nWith each pass, yet closer to end,\nDecomposing problems, our trusted friend,\nRecursion in code, the infinite caller.”
},
“logprobs”: null,
“finish_reason”: “stop”
}
],
“usage”: {
“prompt_tokens”: 39,
“completion_tokens”: 265,
“total_tokens”: 304
},
“system_fingerprint”: null
}

claude-v2 does not return an error.

I’ve been prompted to use another model as they are moving away from GPT-3.5 Turbo from OpenAI. However, I’m getting this error message when I “Run Test,” and for the life of me, I can’t remember if I’m missing anything.

2개의 좋아요

This is now fixed. I removed all of the LLMs and restarted again. Most of the settings took a while to start again, especially having to undo them and then enable them again. But after a few attempts, it is all up and running using 4 Mini.

3개의 좋아요

It’s possible to use third-party OpenAI API services like https://api.aimlapi.com/v1/embeddings?

I get 500 errors when trying.

Did you debug using: