-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add qianfanendpoint for langchain_intro.qmd
- Loading branch information
1 parent
e15fb43
commit 9ebdda9
Showing
5 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" | ||
@discribe: demo for the QianfanChatEndpoint. | ||
@author: [email protected] | ||
""" | ||
|
||
from langchain.chat_models import QianfanChatEndpoint | ||
from langchain.chains import LLMChain | ||
from langchain.prompts import ChatPromptTemplate | ||
|
||
system = "你是一个能力很强的机器人,你的名字叫 小叮当。" | ||
prompt = ChatPromptTemplate.from_messages( | ||
[ | ||
('system', system), | ||
("human", "{query}"), | ||
] | ||
) | ||
llm = QianfanChatEndpoint(model="ERNIE-Bot-4") | ||
chain = LLMChain(llm=llm, prompt=prompt, verbose=True) | ||
res = chain.run(query="你是谁?") | ||
print(res) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
@discribe: demo for the ErnieBotChat. | ||
@author: [email protected] | ||
""" | ||
|
||
from langchain.chains import LLMChain | ||
from langchain.chat_models import ErnieBotChat | ||
from langchain.prompts import ChatPromptTemplate | ||
|
||
system = "你是一个能力很强的机器人,你的名字叫 小叮当。" | ||
prompt = ChatPromptTemplate.from_messages( | ||
[ | ||
("human", "{query}"), | ||
] | ||
) | ||
llm = ErnieBotChat(model_name="ERNIE-Bot-4", system=system) | ||
chain = LLMChain(llm=llm, prompt=prompt, verbose=True) | ||
res = chain.run(query="你是谁?") | ||
print(res) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Sematic Kernel 简介 |