mirror of
https://github.com/bentoml/OpenLLM.git
synced 2026-01-22 06:19:35 -05:00
21 lines
822 B
Python
21 lines
822 B
Python
import openai
|
|
|
|
openai.api_base = "http://localhost:3000/v1"
|
|
openai.api_key = "na"
|
|
|
|
response = openai.Completion.create(model="gpt-3.5-turbo-instruct", prompt="Write a tagline for an ice cream shop.", max_tokens=256)
|
|
|
|
print(response)
|
|
|
|
for chunk in openai.Completion.create(model="gpt-3.5-turbo-instruct", prompt="Say this is a test", max_tokens=7, temperature=0, stream=True):
|
|
print(chunk)
|
|
|
|
completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"}])
|
|
|
|
print(completion)
|
|
|
|
completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"}], stream=True)
|
|
|
|
for chunk in completion:
|
|
print(chunk)
|