目录
1.打开google colab,配置GPU
https://dashboard.ngrok.com/get-started/your-authtoken
生成的ngrok-free.app链接就是推理服务的公网地址
import requests
def format_prompt(prompt: str) -> str:
return f'##提问:\n{prompt}\n##回答:\n'
def ask_phi2(query: str) -> str:
url = "http://1111-11-111-11-11.ngrok-free.app/generate"
body = {
"query": format_prompt(query)
}
response = requests.post(url=url, json=body)
if response.status_code == 200:
print("Response from server:", response.text)
else:
print("Failed to get response from server, status code:", response.status_code)
if __name__ == '__main__':
ask_phi2("你好")