Created
March 7, 2024 18:04
-
-
Save tuhinsharma121/0417566f8b9390776647f8fe2f3c02b2 to your computer and use it in GitHub Desktop.
This file contains 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
from openai import OpenAI | |
openai_api_key = "EMPTY" | |
# openai_api_base = "http://localhost:8000/v1" | |
openai_api_base = "https://jarvisai-vllm.apps.int.stc.ai.dev.us-east-1.aws.paas.redhat.com/v1" | |
model = "mistralai/Mistral-7B-Instruct-v0.2" | |
prompt = "You are an expert programmer that writes simple, concise code and explanations. Write a python function to generate the nth fibonacci number." | |
client = OpenAI( | |
api_key=openai_api_key, | |
base_url=openai_api_base, | |
) | |
chat_completion = client.chat.completions.create( | |
messages=[ | |
{ | |
"role": "user", | |
"content": prompt, | |
} | |
], | |
model=model, | |
stream=True | |
) | |
for x in chat_completion: | |
print(x.choices[0].delta.content, end="") | |
print("Chat response:", chat_completion) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment