add feature bulding
This commit is contained in:
@@ -7,7 +7,7 @@ mcp = FastMCP(name='FastMCP',host='0.0.0.0',port=8000)
|
||||
def login_function(username:str, password:str) -> dict :
|
||||
"""
|
||||
功能:
|
||||
使用账号密码,调用登陆api进行登陆。
|
||||
接受账号密码,调用登陆api,发送调用结果,并展示调用输出。
|
||||
参数:
|
||||
username:用户的账号,或者是用户名称
|
||||
password:用户的密码
|
||||
@@ -16,7 +16,7 @@ def login_function(username:str, password:str) -> dict :
|
||||
'username':username,
|
||||
'password':password
|
||||
}
|
||||
url = 'http://localhost:8000/api/v1/login/access-token'
|
||||
url = 'http://192.168.50.11:8000/api/v1/login/access-token'
|
||||
response = requests.post(url,data=payload)
|
||||
|
||||
return response.text
|
||||
@@ -25,11 +25,15 @@ def login_function(username:str, password:str) -> dict :
|
||||
def register_function(username:str, password:str):
|
||||
"""
|
||||
功能:
|
||||
注册用户,调用注册api进行新用户注册。
|
||||
注册用户,调用注册api进行新用户注册。+
|
||||
参数:
|
||||
username:用户的账号,或者是用户名称
|
||||
password:用户的密码
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
mcp.run(transport='streamable-http')
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -17,12 +17,19 @@ llm = ChatOllama(
|
||||
store_mcp = MCPStore.setup_store()
|
||||
store_mcp.for_store().add_service(
|
||||
config=[
|
||||
{'name':'登陆助手','url':''}
|
||||
{'name':'登陆助手','url':'mcpdocker容器的地址:8000/mcp'}
|
||||
]
|
||||
)
|
||||
tools = store_mcp.for_store().for_langchain().list_tools()
|
||||
|
||||
|
||||
def get_model():
|
||||
return llm
|
||||
|
||||
def get_agent():
|
||||
return create_react_agent(model=llm, tools=tools)
|
||||
|
||||
if __name__=='__main__':
|
||||
agent = get_agent()
|
||||
|
||||
|
||||
|
||||
|
||||
41
src/webui.py
41
src/webui.py
@@ -0,0 +1,41 @@
|
||||
import streamlit as st
|
||||
from ollama_agent import get_agent
|
||||
from langchain_core.messages import HumanMessage
|
||||
|
||||
st.set_page_config(
|
||||
page_title='login client demo',
|
||||
page_icon=':smiley:',
|
||||
layout='wide'
|
||||
)
|
||||
|
||||
st.markdown(
|
||||
body="<h1 style='text-align: center'>MCP Client Demo</h1>",unsafe_allow_html=True
|
||||
)
|
||||
|
||||
st.markdown(
|
||||
body="<h3 style='text-align: center;'> welcome</h3>", unsafe_allow_html=True
|
||||
)
|
||||
|
||||
@st.cache_resource
|
||||
def get_my_agent():
|
||||
return get_agent()
|
||||
|
||||
agent = get_my_agent()
|
||||
|
||||
if 'history' not in st.session_state:
|
||||
st.session_state.history = []
|
||||
|
||||
st.sidebar.markdown('### 系统设置')
|
||||
if st.sidebar.button("清空对话"):
|
||||
st.session_state.history = []
|
||||
|
||||
for msg in st.session_state.history:
|
||||
with st.chat_message(name=msg.type):
|
||||
st.markdown(msg.content)
|
||||
|
||||
query = st.chat_input(placeholder='输入你的问题')
|
||||
if query:
|
||||
with st.chat_message(name='user'):
|
||||
st.markdown(query)
|
||||
st.session_state.history.append(HumanMessage(content=query))
|
||||
response =agent.invoke(input=[])
|
||||
Reference in New Issue
Block a user