Access anychat using python

The web version of anychat is developed using flask. I feel it has bugs and the experience is not good. It often returns empty strings, garbled characters, and sometimes blocks.

http://4207.fun/anychat

Using their Key-free interface, you can write a client or web version yourself and customize it according to your own needs.

AnyGPT API developer documentation · Yuque

You can use Python to write a client yourself, or you can create a customized online version for customers to use. The main thing is that you don’t have to remember the web page, and you can switch the source as needed.

# --*-- coding:utf-8 --*--
import requests
import json
login_url = "http://175.6.7.167:25678/free/"
data = {
        "key": "AnyGPT is all you need",
        "prompt": "讲个故事",
        "context": "human",
        "human_history": [],
        "assistant_history": [],
        "transcript_in": []
        }
headers = {
        "Content-Type": "application/json",
        "charset":"UTF-8"
        #"Authorization": f"Bearer {apiKey}",
    }
response = requests.post(url=login_url, data=json.dumps(data), headers=headers,timeout=(10, 20000),stream=True)
 
print(response.status_code)
print(response.url)
print(response.headers)
print(json.loads(response.text))

For running effects, you can also use other APIs. When you see a suitable reverse engineering interface, just research the interface and connect it.

 

environment:

vscode, python3.11, anaconda, vscode's python plug-in. If the library is missing, follow the prompts to install
conda instll requests.

Guess you like

Origin blog.csdn.net/blogercn/article/details/131098731