File size: 1,200 Bytes
37c870e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#%%
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)  
# %%