File size: 745 Bytes
d1c897a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

import base64

from openai import OpenAI

endpoint = "<Insert your endpoint>" # Endpoint will be different depending on whether you will access from corp network (i.e. on your laptop in office or on VPN) or from pluto instances
key = "<Insert your key>" # e.g. sk-1234567890, to get one, use Slack command /get-llm-cred
model = "<Insert your model id>" # e.g llama-3-1-8b

# Initialize the client
client = OpenAI(
    api_key = "Bearer " + key,
    base_url = endpoint,
)

# Text input
chat_response = client.chat.completions.create(
    model = model,
    messages = [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Tell me a joke."},
    ]
)

print("Chat response:", chat_response)