Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -35,7 +35,7 @@ app = FastAPI()
|
|
35 |
async def read_root():
|
36 |
return {"Hello": "World!"}
|
37 |
|
38 |
-
def modelResp1(prompt):
|
39 |
messages = [
|
40 |
{"role": "system", "content": "You are a helpful assistant, Sia, developed by Sushma. You will response in polity and brief."},
|
41 |
{"role": "user", "content": "Who are you?"},
|
@@ -54,7 +54,9 @@ def modelResp1(prompt):
|
|
54 |
)
|
55 |
response = output['choices'][0]['text']
|
56 |
|
57 |
-
|
|
|
|
|
58 |
|
59 |
def modelResp2(prompt):
|
60 |
messages = [
|
@@ -99,18 +101,41 @@ def modelResp3(prompt):
|
|
99 |
|
100 |
@app.post("/modelapi1")
|
101 |
async def modelApi(data: dict):
|
|
|
102 |
prompt = data.get("prompt")
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
@app.post("/modelapi2")
|
107 |
async def modelApi(data: dict):
|
108 |
prompt = data.get("prompt")
|
109 |
-
response = modelResp2(prompt)
|
110 |
-
return
|
111 |
|
112 |
@app.post("/modelapi3")
|
113 |
async def modelApi1(data: dict):
|
114 |
prompt = data.get("prompt")
|
115 |
response = modelResp3(prompt)
|
116 |
-
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
async def read_root():
|
36 |
return {"Hello": "World!"}
|
37 |
|
38 |
+
def modelResp1(id, prompt):
|
39 |
messages = [
|
40 |
{"role": "system", "content": "You are a helpful assistant, Sia, developed by Sushma. You will response in polity and brief."},
|
41 |
{"role": "user", "content": "Who are you?"},
|
|
|
54 |
)
|
55 |
response = output['choices'][0]['text']
|
56 |
|
57 |
+
privatepayload['target'] = f"{id}"
|
58 |
+
privatepayload['content'] = response
|
59 |
+
requests.post(privateurl, headers=headers, data=privatepayload)
|
60 |
|
61 |
def modelResp2(prompt):
|
62 |
messages = [
|
|
|
101 |
|
102 |
@app.post("/modelapi1")
|
103 |
async def modelApi(data: dict):
|
104 |
+
id = data.get("target_id")
|
105 |
prompt = data.get("prompt")
|
106 |
+
modelResp1(id, prompt)
|
107 |
+
|
|
|
108 |
@app.post("/modelapi2")
|
109 |
async def modelApi(data: dict):
|
110 |
prompt = data.get("prompt")
|
111 |
+
#response = modelResp2(prompt)
|
112 |
+
return return {"Hello": "World!"}
|
113 |
|
114 |
@app.post("/modelapi3")
|
115 |
async def modelApi1(data: dict):
|
116 |
prompt = data.get("prompt")
|
117 |
response = modelResp3(prompt)
|
118 |
+
return response
|
119 |
+
|
120 |
+
|
121 |
+
headers = {
|
122 |
+
'Accept': 'application/json, text/javascript, */*; q=0.01',
|
123 |
+
'Accept-Encoding': 'gzip, deflate, br',
|
124 |
+
'Accept-Language': 'en-US,en;q=0.9',
|
125 |
+
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
126 |
+
'Cookie': 'PHPSESSID=g0r2los456eaalf7epddmehabi; bc_userid=52113; bc_utk=aef8ec9314d8b64477cd86c80591f7e0c90f3faa',
|
127 |
+
'Sec-Ch-Ua': '"Opera";v="95", "Chromium";v="109", "Not;A=Brand";v="24"',
|
128 |
+
'Sec-Ch-Ua-Mobile': '?0',
|
129 |
+
'Sec-Ch-Ua-Platform': '"Windows"',
|
130 |
+
'Sec-Fetch-Dest': 'empty',
|
131 |
+
'Sec-Fetch-Mode': 'cors',
|
132 |
+
'Sec-Fetch-Site': 'same-origin',
|
133 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 OPR/95.0.0.0',
|
134 |
+
'X-Requested-With': 'XMLHttpRequest'
|
135 |
+
}
|
136 |
+
|
137 |
+
payload = {
|
138 |
+
'target': ''
|
139 |
+
'content': ''
|
140 |
+
'token': ''
|
141 |
+
}
|