Skip to content

Commit

Permalink
apichain完成,但具体应用 有时可以有时不行,生产的话有待考证
Browse files Browse the repository at this point in the history
  • Loading branch information
gtck520 committed Jan 16, 2024
1 parent d084d38 commit 8e5307d
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 26 deletions.
2 changes: 1 addition & 1 deletion server/agent/tools/search_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ class SearchApiInput(BaseModel):


if __name__ == "__main__":
result = search_api("明天福州天气")
result = search_api("陈康的用户信息,结果使用表格输出")
print("答案:",result)
2 changes: 1 addition & 1 deletion server/agent/tools/search_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ parameters:
properties:
query:
type: string
description: Query for api search
description: the name for search please use chinese
required:
- query
36 changes: 18 additions & 18 deletions server/agent/tools_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
description="Useful for when you need to answer questions about simple calculations",
args_schema=CalculatorInput,
),
Tool.from_function(
func=arxiv,
name="arxiv",
description="A wrapper around Arxiv.org for searching and retrieving scientific articles in various fields.",
args_schema=ArxivInput,
),
# Tool.from_function(
# func=arxiv,
# name="arxiv",
# description="A wrapper around Arxiv.org for searching and retrieving scientific articles in various fields.",
# args_schema=ArxivInput,
# ),
# Tool.from_function(
# func=weathercheck,
# name="weather_check",
Expand All @@ -28,12 +28,12 @@
description="Use Shell to execute Linux commands",
args_schema=ShellInput,
),
Tool.from_function(
func=search_knowledgebase_complex,
name="search_knowledgebase_complex",
description="Use Use this tool to search local knowledgebase and get information",
args_schema=KnowledgeSearchInput,
),
# Tool.from_function(
# func=search_knowledgebase_complex,
# name="search_knowledgebase_complex",
# description="Use Use this tool to search local knowledgebase and get information",
# args_schema=KnowledgeSearchInput,
# ),
# Tool.from_function(
# func=search_internet,
# name="search_internet",
Expand All @@ -52,12 +52,12 @@
description="Useful for when you need to calculate difficult formulas",
args_schema=WolframInput,
),
Tool.from_function(
func=search_youtube,
name="search_youtube",
description="use this tools to search youtube videos",
args_schema=YoutubeInput,
),
# Tool.from_function(
# func=search_youtube,
# name="search_youtube",
# description="use this tools to search youtube videos",
# args_schema=YoutubeInput,
# ),
]

tool_names = [tool.name for tool in tools]
25 changes: 19 additions & 6 deletions server/chat/personal_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from server.memory.conversation_db_buffer_memory import ConversationBufferDBMemory
from server.db.repository import add_message_to_db
from server.callback_handler.conversation_callback_handler import ConversationCallbackHandler
from server.ext_api import test
from server.ext_api import test,payment


async def personal_chat(query: str = Body(..., description="用户输入", examples=["恼羞成怒"]),
Expand Down Expand Up @@ -47,15 +47,28 @@ async def chat_iterator() -> AsyncIterable[str]:
callbacks=callbacks,
)

api_response_template = get_prompt_template("personal_chat", "default")

api_url_template = get_prompt_template("personal_chat", "url")
api_url_prompt = PromptTemplate.from_template(api_url_template)

api_response_template = get_prompt_template("personal_chat", "response")
api_response_prompt = PromptTemplate.from_template(api_response_template)

# headers = {"Authorization": f"Bearer {os.environ['TMDB_BEARER_TOKEN']}"} headers=headers
headers = {"api-key":"7leVZ5NZ6WNhyr4WwIczKfdqvNC_2doq"}
chain_new = APIChain.from_llm_and_api_docs(llm=model,
api_docs=test.TEST_DOCS,
api_docs=payment.PAYMENT_DOCS,
verbose=True,
limit_to_domains=["https://restapi.amap.com"],
api_response_prompt=api_response_prompt)
limit_to_domains=["http://127.0.0.1:8080"],
headers=headers,
api_response_prompt=api_response_prompt,
api_url_prompt=api_url_prompt)

# 无header的
# chain_new = APIChain.from_llm_and_api_docs(llm=model,
# api_docs=test.TEST_DOCS,
# verbose=True,
# limit_to_domains=["https://restapi.amap.com"],
# api_response_prompt=api_response_prompt)
# chain = LLMChain(prompt=chat_prompt, llm=model, memory=memory)

# Begin a task that runs in the background.
Expand Down
59 changes: 59 additions & 0 deletions server/ext_api/payment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# flake8: noqa
PAYMENT_DOCS = """
一、支付系统用户信息查询,用户银行卡信息查询
支付系统用户信息查询是一个简单的HTTP接口,根据用户输入的身份证号identity_card或者姓名real_name,查询用户的详细信息和用户的银行卡信息
用户信息查询API服务地址:
URL : http://127.0.0.1:8080/aiapi/member/GetUserInfo?real_name=<姓名>
URL : http://127.0.0.1:8080/aiapi/member/GetUserInfo?identity_card=<身份证号>
请求方式:GET
请求参数说明
real_name:代表姓名。为字符串
identity_card:代表身份证号,一般为数字开头
返回结果是一个json字符串,参数说明如下:
"success": 状态说明,不为true说明请求失败
"data": 返回的数据json
"id": 用户id
"platform_id":用户平台id
"realname": 姓名
"identity_no": 身份证
"mobile": 电话号码
"address": 地址
"gender": 性别,0代表男,1代表女,2代表未定义
"id_indate": 身份证到期日期
"bank_info":为银行信息数组
{
"bank_type": 银行类型
"bank_card": 卡类型
"bank_provinc":开户省
"bank_city": 开户城市
"bank_open": 开户行
"bank_no": 银行卡号
"binding_mobile":绑定手机号
"bank_pic_a":银行卡正面图片地址
"bank_pic_b":银行卡反面图片地址
},
请求示例
1、http://127.0.0.1:8080/aiapi/member/GetUserInfo?real_name=奥托夫斯基
1、http://127.0.0.1:8080/aiapi/member/GetUserInfo?identity_card=3522000198656542365
二、支付系统渠道信息列表
支付系统渠道信息列表是一个简单的HTTP接口,可以列出当前支付系统支持的所有渠道。
渠道信息列表API服务地址:
URL : http://127.0.0.1:8080/aiapi/member/GetPayterm
请求方式:GET
请求参数说明
不需要任何参数
返回结果参数说明
"success": true, //状态说明,不为true说明请求失败
"data": 返回的渠道列表数据
请求示例
1、http://127.0.0.1:8080/aiapi/member/GetPayterm
"""

0 comments on commit 8e5307d

Please sign in to comment.