Created
September 14, 2023 20:01
-
-
Save jfjensen/1205d4444a565d4d77ebe46d94c00e39 to your computer and use it in GitHub Desktop.
Using the OpenAI API to access an LLM on a vLLM server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openai | |
base_url = "http://localhost:9999/v1" | |
openai.api_key = "***" | |
openai.api_base = base_url | |
models = openai.Model.list() | |
model = models["data"][0]["id"] | |
print(f"model: {model}") | |
prompt = "What is the capital of France?" | |
stream = False | |
completion = openai.Completion.create( | |
model=model, | |
prompt=prompt, | |
echo=False, | |
max_tokens=1500, | |
temperature=0.0, | |
frequency_penalty=1.1, | |
stream=stream) | |
print(completion["choices"][0]["text"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment