langchain中langcorn的使用

pip install langcorn

main.py:

from langcorn import create_service
app = create_service("chains02:llm_chain")

chains02.py:

import ChatGLM
from langchain.chains import LLMChain
from langchain_core.prompts import ChatPromptTemplate
from langchain_community.tools.tavily_search import TavilySearchResults
from langchain.chains import LLMMathChain
# pip install numexpr

llm = ChatGLM.ChatGLM_LLM()
llm_chain = LLMMathChain.from_llm(llm)
print(llm_chain.invoke("the result of  1 +  2 "))

运行:

uvicorn main:app --host  0.0.0.0   --port  8000

访问:

http://127.0.0.1:8000/docs

你可能感兴趣的:(LangChain,langchain,python,linux)