evelyn / testing_ui_interface /llm_API_model.py
evelyn-lo's picture
Upload folder using huggingface_hub
37c870e verified
#%%
import requests
import json
url = "https://foxbrainopenaiapieastus.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-02-15-preview"
api_key = "f8c3f26d14ff4876ab9a7d23251337d5"
headers = {
"Content-Type": "application/json",
"api-key": api_key
}
message_from_app="Tell me a joke about writing the web app write it via 100 words"
data = {
"messages": [
{"role": "system", "content": "You are an AI assistant that helps people find information."},
# {"role": "user", "content": ""},
# {"role": "assistant", "content": "Hello! How can I assist you today?"},
{"role": "user", "content":f"user message:{message_from_app}"}, # "can you write the simple gradio chat bot code for me"
],
"max_tokens": 4096,
"temperature": 1,
"frequency_penalty": 0,
"presence_penalty": 0,
"top_p": 0.95,
"stop": None
}
response = requests.post(
url,
headers=headers,
data=json.dumps(data)
)
reply = response.json()
#model_output=response.choices[0].text
reply = response.json()
message_out=reply['choices'][0]['message']['content']
print(message_out)
# %%