mirror of
https://github.com/hwchase17/langchain.git
synced 2025-04-28 11:55:21 +00:00
Plus, some accompanying docs updates Some compelling usage: ```py from langchain_perplexity import ChatPerplexity chat = ChatPerplexity(model="llama-3.1-sonar-small-128k-online") response = chat.invoke( "What were the most significant newsworthy events that occurred in the US recently?", extra_body={"search_recency_filter": "week"}, ) print(response.content) # > Here are the top significant newsworthy events in the US recently: ... ``` Also, some confirmation of structured outputs: ```py from langchain_perplexity import ChatPerplexity from pydantic import BaseModel class AnswerFormat(BaseModel): first_name: str last_name: str year_of_birth: int num_seasons_in_nba: int messages = [ {"role": "system", "content": "Be precise and concise."}, { "role": "user", "content": ( "Tell me about Michael Jordan. " "Please output a JSON object containing the following fields: " "first_name, last_name, year_of_birth, num_seasons_in_nba. " ), }, ] llm = ChatPerplexity(model="llama-3.1-sonar-small-128k-online") structured_llm = llm.with_structured_output(AnswerFormat) response = structured_llm.invoke(messages) print(repr(response)) #> AnswerFormat(first_name='Michael', last_name='Jordan', year_of_birth=1963, num_seasons_in_nba=15) ``` |
||
---|---|---|
.. | ||
api_reference | ||
cassettes | ||
data | ||
docs | ||
scripts | ||
src | ||
static | ||
.gitignore | ||
.yarnrc.yml | ||
babel.config.js | ||
docusaurus.config.js | ||
ignore-step.sh | ||
Makefile | ||
package.json | ||
README.md | ||
sidebars.js | ||
vercel_overrides.txt | ||
vercel_requirements.txt | ||
vercel.json | ||
yarn.lock |
LangChain Documentation
For more information on contributing to our documentation, see the Documentation Contributing Guide