## FAST API
akasha 提供get_response, ask_self, ask_whole_file, get_summary的api server
### 啟動
```bash!=
akasha api (–port {port} –host {host} –workers {num_of_workers})
```
### Example
```python!=
import requests
import os
HOST = os.getenv("API_HOST", "http://127.0.0.1")
PORT = os.getenv("API_PORT", "8000")
urls = {
"summary": f"{HOST}:{PORT}/get_summary",
"qa": f"{HOST}:{PORT}/get_response",
"self": f"{HOST}:{PORT}/ask_self",
"file": f"{HOST}:{PORT}/ask_whole_file",
}
openai_config = {
"azure_key": {your api key},
"azure_base": {your api base},
}
self_data = {
"prompt": "太陽電池技術?",
"info": "太陽能電池技術5塊錢",
"model": "openai:gpt-3.5-turbo",
"system_prompt": "",
"max_doc_len": 1500,
"temperature": 0.0,
"openai_config": openai_config
}
file_data = {
"doc_path": "docs/mic/20230317_5軸工具機因應市場訴求改變的發展態勢.pdf",
"prompt": "五軸是什麼?",
"chunk_size": 1000,
"model": "openai:gpt-3.5-turbo",
"embedding_model": "openai:text-embedding-ada-002",
"system_prompt": "",
"max_doc_len": 1500,
"temperature": 0.0,
"openai_config": openai_config
}
chat_data = {
"doc_path": "docs/pns/",
"prompt": "太陽電池技術?",
"chunk_size": 1000,
"model": "openai:gpt-3.5-turbo",
"embedding_model": "openai:text-embedding-ada-002",
"threshold": 0.1,
"search_type": 'auto',
"system_prompt": "",
"max_doc_len": 1500,
"temperature": 0.0,
"openai_config": openai_config
}
summary_data = {
"file_path": "docs/pns/2484.txt",
"model": "openai:gpt-3.5-turbo",
"summary_type": "reduce_map",
"summary_len": 500,
"system_prompt": "",
"openai_config": openai_config
}
# chat_response = requests.post(urls["qa"], json=chat_data).json()
# print(chat_response)
# sum_response = requests.post(
# urls["summary"],
# json=summary_data,
# ).json()
# print(sum_response)
self_response = requests.post(urls["self"], json=self_data).json()
print(self_response)
file_response = requests.post(urls["file"], json=file_data).json()
print(file_response)
```