forked from MeoPBK/GUI_AI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPOST.py
More file actions
45 lines (38 loc) · 1.2 KB
/
POST.py
File metadata and controls
45 lines (38 loc) · 1.2 KB
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
43
44
45
# -*- coding: utf-8 -*-
"""
@author: meoai and iacop
"""
import requests
# URL to send in the POST request
OLLAMA_URL = "https://3b2b-93-35-170-99.ngrok-free.app/api/generate"
# URL to send in the GET request
# OLLAMA_URL_GET = "https://c6e7-93-35-170-99.ngrok-free.app"
MODEL = "mistral"
headers = {"Content-Type": "application/json"}
PROMPT = "invent a story about an horse named JusyPani"
# Data to send in the POST request
data = {
"model": MODEL,
"prompt": PROMPT,
"stream": False
}
#request, just for debugging
#try:
# response = requests.get(OLLAMA_URL_GET)
# if response.status_code == 200:
# print("Server is up and running!")
# else:
# print(f"Error: {response.status_code}, {response.text}")
#except Exception as e:
# print(f"An error occurred: {e}")
try:
# Make the POST request
response = requests.post(OLLAMA_URL, headers=headers, json=data)
# If the response is successful, print it
if response.status_code == 200:
response_data = response.json()
print("Model Response:", response_data['response'])
else:
print(f"Error: {response.status_code}, {response.text}")
except Exception as e:
print(f"Error occurred: {e}")