|
@@ -0,0 +1,45 @@
|
|
|
+import requests
|
|
|
+
|
|
|
+
|
|
|
+def get_res(role_msg, qa):
|
|
|
+ headers = {
|
|
|
+ 'authority': '12037605098.gpt1.live',
|
|
|
+ 'accept': 'text/event-stream',
|
|
|
+ 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
|
|
+ 'cache-control': 'no-cache',
|
|
|
+ 'cookie': 'Hm_lvt_415448b475d5767ab10a708c6b7efd29=1686708328,1686794966; Hm_lpvt_415448b475d5767ab10a708c6b7efd29=1687658849',
|
|
|
+ 'origin': 'https://12037605098.gpt1.live',
|
|
|
+ 'pragma': 'no-cache',
|
|
|
+ 'referer': 'https://12037605098.gpt1.live/?node77',
|
|
|
+ 'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
|
|
|
+ 'sec-ch-ua-mobile': '?0',
|
|
|
+ 'sec-ch-ua-platform': '"macOS"',
|
|
|
+ 'sec-fetch-dest': 'empty',
|
|
|
+ 'sec-fetch-mode': 'cors',
|
|
|
+ 'sec-fetch-site': 'same-origin',
|
|
|
+ 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
|
|
|
+ 'x-requested-with': 'XMLHttpRequest',
|
|
|
+ }
|
|
|
+
|
|
|
+ json_data = {
|
|
|
+ 'messages': [
|
|
|
+ {
|
|
|
+ 'role': 'system',
|
|
|
+ 'content': f'Your name is Fengfeng and you are 18 years old. {role_msg}',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'role': 'user',
|
|
|
+ 'content': qa,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ 'stream': False,
|
|
|
+ 'model': 'gpt-3.5-turbo-16k',
|
|
|
+ 'temperature': 0.7,
|
|
|
+ 'presence_penalty': 0,
|
|
|
+ }
|
|
|
+
|
|
|
+ response = requests.post('https://12037605098.gpt1.live/api/openai/v1/chat/completions', headers=headers, json=json_data)
|
|
|
+ return response.json()['choices'][0]['message']['content']
|
|
|
+
|
|
|
+
|
|
|
+print(get_res("", "你知道周杰伦吗"))
|