So how can I translate or is there just a different code for Swift?
from openai import OpenAI
client = OpenAI(
base_url="",
api_key=""
)
# Instruction for the API request:
instruction = "..."
text = "..."
chat_completion = client.chat.completions.create(
model="tgi",
messages=[
{"role": "system", "content": instruction},
{"role": "user", "content": text},
],
stream=True,
max_tokens=2000
)
# iterate and print stream
for message in chat_completion:
print(message.choices[0].delta.content, end="")
I have tried PythonKit(fails to run the app even with some default things) and OpenAIKit(there is no base_url field as far as I know)