Class: LlmLib::OpenAI

Inherits:
Object
  • Object
show all
Defined in:
lib/llm_lib/openai.rb

Class Method Summary collapse

Class Method Details

.send(apikey, model, prompt, max_tokens, temperature = 0, top_p = 1, n = 1, stream = false, stop = "\n") ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/llm_lib/openai.rb', line 5

def self.send(apikey, model, prompt, max_tokens, temperature=0, top_p=1, n=1, stream=false, stop="\n")

    return LlmLib::Restclient.post(
        body: {
      "model" => model,
            "messages" => [{ role: "user", content: prompt}],
            "max_tokens" => max_tokens,
            "temperature" => temperature,
            "top_p" => top_p,
            "n" => n,
            "stream" => stream,
            "stop" => stop,

        },
        url: "https://api.openai.com/v1/chat/completions",
        apikey: apikey
    )
end