Views
No views yet
1from openai import OpenAI
2# Set OpenAI's API key and API base to use vLLM's API server.
3openai_api_key = "EMPTY"
4openai_api_base = "http://localhost:8000/v1"
5
6client = OpenAI(
7 api_key=openai_api_key,
8 base_url=openai_api_base,
9)
10
11system = """
12BEGININPUT
13BEGINCONTEXT
14date: 2021-01-01
15url: https://web.site/123
16ENDCONTEXT
17In a shocking turn of events, blueberries are now green, but will be sticking with the same name.
18ENDINPUT
19BEGININSTRUCTION
20{user}
21ENDINSTRUCTION
22"""
23
24user = "What is the new color of blueberries?"
25chat_response = client.chat.completions.create(
26 model="macadeliccc/airoboros-9b-3.2",
27 messages=[
28 {"role": "system", "content": system},
29 {"role": "user", "content": user},
30 ]
31)
32print("Chat response:", chat_response)Chat response: ChatCompletion(id='cmpl-6bce7c051ffd41878624683faea90719', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='Blueberries are now green.', role='assistant', function_call=None, tool_calls=None))], created=273292, model='macadeliccc/airoboros-9b-3.2', object='chat.completion', system_fingerprint=None, usage=CompletionUsage(completion_tokens=7, prompt_tokens=119, total_tokens=126))