id stringlengths 14 16 | text stringlengths 29 2.73k | source stringlengths 49 115 |
|---|---|---|
ecc8fb3e3b65-1 | bing_subscription_key = get_from_dict_or_env(
values, "bing_subscription_key", "BING_SUBSCRIPTION_KEY"
)
values["bing_subscription_key"] = bing_subscription_key
bing_search_url = get_from_dict_or_env(
values,
"bing_search_url",
"BING_SEARCH_URL",
... | https://python.langchain.com/en/latest/_modules/langchain/utilities/bing_search.html |
ecc8fb3e3b65-2 | "snippet": result["snippet"],
"title": result["name"],
"link": result["url"],
}
metadata_results.append(metadata_result)
return metadata_results
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https://python.langchain.com/en/latest/_modules/langchain/utilities/bing_search.html |
ac8eae3e64c4-0 | Source code for langchain.utilities.wolfram_alpha
"""Util that calls WolframAlpha."""
from typing import Any, Dict, Optional
from pydantic import BaseModel, Extra, root_validator
from langchain.utils import get_from_dict_or_env
[docs]class WolframAlphaAPIWrapper(BaseModel):
"""Wrapper for Wolfram Alpha.
Docs fo... | https://python.langchain.com/en/latest/_modules/langchain/utilities/wolfram_alpha.html |
ac8eae3e64c4-1 | res = self.wolfram_client.query(query)
try:
assumption = next(res.pods).text
answer = next(res.results).text
except StopIteration:
return "Wolfram Alpha wasn't able to answer it"
if answer is None or answer == "":
# We don't want to return the assu... | https://python.langchain.com/en/latest/_modules/langchain/utilities/wolfram_alpha.html |
1463fa50cf16-0 | Source code for langchain.utilities.arxiv
"""Util that calls Arxiv."""
import logging
from typing import Any, Dict, List
from pydantic import BaseModel, Extra, root_validator
from langchain.schema import Document
logger = logging.getLogger(__name__)
[docs]class ArxivAPIWrapper(BaseModel):
"""Wrapper around ArxivAPI... | https://python.langchain.com/en/latest/_modules/langchain/utilities/arxiv.html |
1463fa50cf16-1 | """Validate that the python package exists in environment."""
try:
import arxiv
values["arxiv_search"] = arxiv.Search
values["arxiv_exceptions"] = (
arxiv.ArxivError,
arxiv.UnexpectedEmptyPageError,
arxiv.HTTPError,
... | https://python.langchain.com/en/latest/_modules/langchain/utilities/arxiv.html |
1463fa50cf16-2 | """
Run Arxiv search and get the PDF documents plus the meta information.
See https://lukasschwab.me/arxiv.py/index.html#Search
Returns: a list of documents with the document.page_content in PDF format
"""
try:
import fitz
except ImportError:
raise... | https://python.langchain.com/en/latest/_modules/langchain/utilities/arxiv.html |
1463fa50cf16-3 | **add_meta,
}
),
)
docs.append(doc)
except FileNotFoundError as f_ex:
logger.debug(f_ex)
return docs
except self.arxiv_exceptions as ex:
logger.... | https://python.langchain.com/en/latest/_modules/langchain/utilities/arxiv.html |
185ee5b171ff-0 | Source code for langchain.utilities.google_places_api
"""Chain that calls Google Places API.
"""
import logging
from typing import Any, Dict, Optional
from pydantic import BaseModel, Extra, root_validator
from langchain.utils import get_from_dict_or_env
[docs]class GooglePlacesAPIWrapper(BaseModel):
"""Wrapper arou... | https://python.langchain.com/en/latest/_modules/langchain/utilities/google_places_api.html |
185ee5b171ff-1 | except ImportError:
raise ValueError(
"Could not import googlemaps python packge. "
"Please install it with `pip install googlemaps`."
)
return values
[docs] def run(self, query: str) -> str:
"""Run Places search and get k number of places that ... | https://python.langchain.com/en/latest/_modules/langchain/utilities/google_places_api.html |
185ee5b171ff-2 | "formatted_address", "Unknown"
)
phone_number = place_details.get("result", {}).get(
"formatted_phone_number", "Unknown"
)
website = place_details.get("result", {}).get("website", "Unknown")
formatted_details = (
f"{name}\nAddre... | https://python.langchain.com/en/latest/_modules/langchain/utilities/google_places_api.html |
78c9718abaea-0 | Source code for langchain.utilities.openweathermap
"""Util that calls OpenWeatherMap using PyOWM."""
from typing import Any, Dict, Optional
from pydantic import Extra, root_validator
from langchain.tools.base import BaseModel
from langchain.utils import get_from_dict_or_env
[docs]class OpenWeatherMapAPIWrapper(BaseMode... | https://python.langchain.com/en/latest/_modules/langchain/utilities/openweathermap.html |
78c9718abaea-1 | temperature = w.temperature("celsius")
rain = w.rain
heat_index = w.heat_index
clouds = w.clouds
return (
f"In {location}, the current weather is as follows:\n"
f"Detailed status: {detailed_status}\n"
f"Wind speed: {wind['speed']} m/s, direction: {wind... | https://python.langchain.com/en/latest/_modules/langchain/utilities/openweathermap.html |
261c5d7b32ad-0 | Source code for langchain.utilities.python
import sys
from io import StringIO
from typing import Dict, Optional
from pydantic import BaseModel, Field
[docs]class PythonREPL(BaseModel):
"""Simulates a standalone Python REPL."""
globals: Optional[Dict] = Field(default_factory=dict, alias="_globals")
locals: O... | https://python.langchain.com/en/latest/_modules/langchain/utilities/python.html |
f4bab1d85b5e-0 | Source code for langchain.utilities.google_serper
"""Util that calls Google Search using the Serper.dev API."""
from typing import Dict, Optional
import requests
from pydantic.class_validators import root_validator
from pydantic.main import BaseModel
from langchain.utils import get_from_dict_or_env
[docs]class GoogleSe... | https://python.langchain.com/en/latest/_modules/langchain/utilities/google_serper.html |
f4bab1d85b5e-1 | snippets = []
if results.get("answerBox"):
answer_box = results.get("answerBox", {})
if answer_box.get("answer"):
return answer_box.get("answer")
elif answer_box.get("snippet"):
return answer_box.get("snippet").replace("\n", " ")
el... | https://python.langchain.com/en/latest/_modules/langchain/utilities/google_serper.html |
f4bab1d85b5e-2 | )
response.raise_for_status()
search_results = response.json()
return search_results
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https://python.langchain.com/en/latest/_modules/langchain/utilities/google_serper.html |
5672f4845359-0 | Source code for langchain.utilities.searx_search
"""Utility for using SearxNG meta search API.
SearxNG is a privacy-friendly free metasearch engine that aggregates results from
`multiple search engines
<https://docs.searxng.org/admin/engines/configured_engines.html>`_ and databases and
supports the `OpenSearch
<https:... | https://python.langchain.com/en/latest/_modules/langchain/utilities/searx_search.html |
5672f4845359-1 | Other methods are are available for convenience.
:class:`SearxResults` is a convenience wrapper around the raw json result.
Example usage of the ``run`` method to make a search:
.. code-block:: python
s.run(query="what is the best search engine?")
Engine Parameters
-----------------
You can pass any `accept... | https://python.langchain.com/en/latest/_modules/langchain/utilities/searx_search.html |
5672f4845359-2 | .. code-block:: python
# select the github engine and pass the search suffix
s = SearchWrapper("langchain library", query_suffix="!gh")
s = SearchWrapper("langchain library")
# select github the conventional google search syntax
s.run("large language models", query_suffix="site:g... | https://python.langchain.com/en/latest/_modules/langchain/utilities/searx_search.html |
5672f4845359-3 | return {"language": "en", "format": "json"}
[docs]class SearxResults(dict):
"""Dict like wrapper around search api results."""
_data = ""
def __init__(self, data: str):
"""Take a raw result from Searx and make it into a dict like object."""
json_data = json.loads(data)
super().__init... | https://python.langchain.com/en/latest/_modules/langchain/utilities/searx_search.html |
5672f4845359-4 | .. code-block:: python
from langchain.utilities import SearxSearchWrapper
# note the unsecure parameter is not needed if you pass the url scheme as
# http
searx = SearxSearchWrapper(searx_host="http://localhost:8888",
un... | https://python.langchain.com/en/latest/_modules/langchain/utilities/searx_search.html |
5672f4845359-5 | if categories:
values["params"]["categories"] = ",".join(categories)
searx_host = get_from_dict_or_env(values, "searx_host", "SEARX_HOST")
if not searx_host.startswith("http"):
print(
f"Warning: missing the url scheme on host \
! assuming secure ht... | https://python.langchain.com/en/latest/_modules/langchain/utilities/searx_search.html |
5672f4845359-6 | ) as response:
if not response.ok:
raise ValueError("Searx API returned an error: ", response.text)
result = SearxResults(await response.text())
self._result = result
else:
async with self.aiosession.get(
... | https://python.langchain.com/en/latest/_modules/langchain/utilities/searx_search.html |
5672f4845359-7 | searx.run("what is the weather in France ?", engine="qwant")
# the same result can be achieved using the `!` syntax of searx
# to select the engine using `query_suffix`
searx.run("what is the weather in France ?", query_suffix="!qwant")
"""
_params = {
... | https://python.langchain.com/en/latest/_modules/langchain/utilities/searx_search.html |
5672f4845359-8 | ) -> str:
"""Asynchronously version of `run`."""
_params = {
"q": query,
}
params = {**self.params, **_params, **kwargs}
if self.query_suffix and len(self.query_suffix) > 0:
params["q"] += " " + self.query_suffix
if isinstance(query_suffix, str) an... | https://python.langchain.com/en/latest/_modules/langchain/utilities/searx_search.html |
5672f4845359-9 | categories: List of categories to use for the query.
**kwargs: extra parameters to pass to the searx API.
Returns:
Dict with the following keys:
{
snippet: The description of the result.
title: The title of the result.
link: T... | https://python.langchain.com/en/latest/_modules/langchain/utilities/searx_search.html |
5672f4845359-10 | self,
query: str,
num_results: int,
engines: Optional[List[str]] = None,
query_suffix: Optional[str] = "",
**kwargs: Any,
) -> List[Dict]:
"""Asynchronously query with json results.
Uses aiohttp. See `results` for more info.
"""
_params = {
... | https://python.langchain.com/en/latest/_modules/langchain/utilities/searx_search.html |
17f3f362f5a6-0 | Source code for langchain.utilities.wikipedia
"""Util that calls Wikipedia."""
from typing import Any, Dict, Optional
from pydantic import BaseModel, Extra, root_validator
WIKIPEDIA_MAX_QUERY_LENGTH = 300
[docs]class WikipediaAPIWrapper(BaseModel):
"""Wrapper around WikipediaAPI.
To use, you should have the ``w... | https://python.langchain.com/en/latest/_modules/langchain/utilities/wikipedia.html |
17f3f362f5a6-1 | summary = self.fetch_formatted_page_summary(search_results[i])
if summary is not None:
summaries.append(summary)
return "\n\n".join(summaries)
[docs] def fetch_formatted_page_summary(self, page: str) -> Optional[str]:
try:
wiki_page = self.wiki_client.page(titl... | https://python.langchain.com/en/latest/_modules/langchain/utilities/wikipedia.html |
18f8a2579749-0 | Source code for langchain.utilities.awslambda
"""Util that calls Lambda."""
import json
from typing import Any, Dict, Optional
from pydantic import BaseModel, Extra, root_validator
[docs]class LambdaWrapper(BaseModel):
"""Wrapper for AWS Lambda SDK.
Docs for using:
1. pip install boto3
2. Create a lambd... | https://python.langchain.com/en/latest/_modules/langchain/utilities/awslambda.html |
18f8a2579749-1 | answer = json.loads(payload_string)["body"]
except StopIteration:
return "Failed to parse response from Lambda"
if answer is None or answer == "":
# We don't want to return the assumption alone if answer is empty
return "Request failed."
else:
retu... | https://python.langchain.com/en/latest/_modules/langchain/utilities/awslambda.html |
b1483a59df4c-0 | Source code for langchain.utilities.duckduckgo_search
"""Util that calls DuckDuckGo Search.
No setup required. Free.
https://pypi.org/project/duckduckgo-search/
"""
from typing import Dict, List, Optional
from pydantic import BaseModel, Extra
from pydantic.class_validators import root_validator
[docs]class DuckDuckGoSe... | https://python.langchain.com/en/latest/_modules/langchain/utilities/duckduckgo_search.html |
b1483a59df4c-1 | )
if results is None or len(results) == 0:
return "No good DuckDuckGo Search Result was found"
snippets = [result["body"] for result in results]
return " ".join(snippets)
[docs] def results(self, query: str, num_results: int) -> List[Dict[str, str]]:
"""Run query through D... | https://python.langchain.com/en/latest/_modules/langchain/utilities/duckduckgo_search.html |
019e60d4ef95-0 | Source code for langchain.utilities.google_search
"""Util that calls Google Search."""
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Extra, root_validator
from langchain.utils import get_from_dict_or_env
[docs]class GoogleSearchAPIWrapper(BaseModel):
"""Wrapper for Google Search API.
... | https://python.langchain.com/en/latest/_modules/langchain/utilities/google_search.html |
019e60d4ef95-1 | - Under Search engine ID you’ll find the search-engine-ID.
4. Enable the Custom Search API
- Navigate to the APIs & Services→Dashboard panel in Cloud Console.
- Click Enable APIs and Services.
- Search for Custom Search API and click on it.
- Click Enable.
URL for it: https://console.cloud.googl... | https://python.langchain.com/en/latest/_modules/langchain/utilities/google_search.html |
019e60d4ef95-2 | from googleapiclient.discovery import build
except ImportError:
raise ImportError(
"google-api-python-client is not installed. "
"Please install it with `pip install google-api-python-client`"
)
service = build("customsearch", "v1", developerKey=go... | https://python.langchain.com/en/latest/_modules/langchain/utilities/google_search.html |
019e60d4ef95-3 | if "snippet" in result:
metadata_result["snippet"] = result["snippet"]
metadata_results.append(metadata_result)
return metadata_results
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https://python.langchain.com/en/latest/_modules/langchain/utilities/google_search.html |
abc32d127074-0 | Source code for langchain.utilities.serpapi
"""Chain that calls SerpAPI.
Heavily borrowed from https://github.com/ofirpress/self-ask
"""
import os
import sys
from typing import Any, Dict, Optional, Tuple
import aiohttp
from pydantic import BaseModel, Extra, Field, root_validator
from langchain.utils import get_from_dic... | https://python.langchain.com/en/latest/_modules/langchain/utilities/serpapi.html |
abc32d127074-1 | aiosession: Optional[aiohttp.ClientSession] = None
class Config:
"""Configuration for this pydantic object."""
extra = Extra.forbid
arbitrary_types_allowed = True
@root_validator()
def validate_environment(cls, values: Dict) -> Dict:
"""Validate that api key and python packag... | https://python.langchain.com/en/latest/_modules/langchain/utilities/serpapi.html |
abc32d127074-2 | """Use aiohttp to run query through SerpAPI and return the results async."""
def construct_url_and_params() -> Tuple[str, Dict[str, str]]:
params = self.get_params(query)
params["source"] = "python"
if self.serpapi_api_key:
params["serp_api_key"] = self.serpap... | https://python.langchain.com/en/latest/_modules/langchain/utilities/serpapi.html |
abc32d127074-3 | toret = res["answer_box"]["snippet"]
elif (
"answer_box" in res.keys()
and "snippet_highlighted_words" in res["answer_box"].keys()
):
toret = res["answer_box"]["snippet_highlighted_words"][0]
elif (
"sports_results" in res.keys()
and "g... | https://python.langchain.com/en/latest/_modules/langchain/utilities/serpapi.html |
22493564a07f-0 | Source code for langchain.utilities.bash
"""Wrapper around subprocess to run commands."""
from __future__ import annotations
import platform
import re
import subprocess
from typing import TYPE_CHECKING, List, Union
from uuid import uuid4
if TYPE_CHECKING:
import pexpect
def _lazy_import_pexpect() -> pexpect:
""... | https://python.langchain.com/en/latest/_modules/langchain/utilities/bash.html |
22493564a07f-1 | # Set the custom prompt
process.sendline("PS1=" + prompt)
process.expect_exact(prompt, timeout=10)
return process
[docs] def run(self, commands: Union[str, List[str]]) -> str:
"""Run commands and return final output."""
if isinstance(commands, str):
commands = [com... | https://python.langchain.com/en/latest/_modules/langchain/utilities/bash.html |
22493564a07f-2 | self.process.expect(self.prompt, timeout=10)
self.process.sendline("")
try:
self.process.expect([self.prompt, pexpect.EOF], timeout=10)
except pexpect.TIMEOUT:
return f"Timeout error while executing command {command}"
if self.process.after == pexpect.EOF:
... | https://python.langchain.com/en/latest/_modules/langchain/utilities/bash.html |
ac07df94837d-0 | Source code for langchain.utilities.powerbi
"""Wrapper around a Power BI endpoint."""
from __future__ import annotations
import logging
import os
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Union
import aiohttp
import requests
from aiohttp import ServerTimeoutError
from pydantic import BaseMo... | https://python.langchain.com/en/latest/_modules/langchain/utilities/powerbi.html |
ac07df94837d-1 | arbitrary_types_allowed = True
@root_validator(pre=True, allow_reuse=True)
def token_or_credential_present(cls, values: Dict[str, Any]) -> Dict[str, Any]:
"""Validate that at least one of token and credentials is present."""
if "token" in values or "credential" in values:
return valu... | https://python.langchain.com/en/latest/_modules/langchain/utilities/powerbi.html |
ac07df94837d-2 | """Get names of tables available."""
return self.table_names
[docs] def get_schemas(self) -> str:
"""Get the available schema's."""
if self.schemas:
return ", ".join([f"{key}: {value}" for key, value in self.schemas.items()])
return "No known schema's yet. Use the schema_p... | https://python.langchain.com/en/latest/_modules/langchain/utilities/powerbi.html |
ac07df94837d-3 | ) -> str:
"""Get information about specified tables."""
tables_requested = self._get_tables_to_query(table_names)
tables_todo = self._get_tables_todo(tables_requested)
for table in tables_todo:
try:
result = self.run(
f"EVALUATE TOPN({self.... | https://python.langchain.com/en/latest/_modules/langchain/utilities/powerbi.html |
ac07df94837d-4 | if "bad request" in str(exc).lower():
return SCHEMA_ERROR_RESPONSE
if "unauthorized" in str(exc).lower():
return UNAUTHORIZED_RESPONSE
return str(exc)
self.schemas[table] = json_to_md(result["results"][0]["tables"][0]["rows"])
r... | https://python.langchain.com/en/latest/_modules/langchain/utilities/powerbi.html |
ac07df94837d-5 | ) as response:
response.raise_for_status()
response_json = await response.json()
return response_json
def json_to_md(
json_contents: List[Dict[str, Union[str, int, float]]],
table_name: Optional[str] = None,
) -> str:
"""Converts a JSON object to a markdown ta... | https://python.langchain.com/en/latest/_modules/langchain/utilities/powerbi.html |
34e5a270a831-0 | Source code for langchain.utilities.apify
from typing import Any, Callable, Dict, Optional
from pydantic import BaseModel, root_validator
from langchain.document_loaders import ApifyDatasetLoader
from langchain.document_loaders.base import Document
from langchain.utils import get_from_dict_or_env
[docs]class ApifyWrapp... | https://python.langchain.com/en/latest/_modules/langchain/utilities/apify.html |
34e5a270a831-1 | *,
build: Optional[str] = None,
memory_mbytes: Optional[int] = None,
timeout_secs: Optional[int] = None,
) -> ApifyDatasetLoader:
"""Run an Actor on the Apify platform and wait for results to be ready.
Args:
actor_id (str): The ID or name of the Actor on the Apify... | https://python.langchain.com/en/latest/_modules/langchain/utilities/apify.html |
34e5a270a831-2 | memory_mbytes: Optional[int] = None,
timeout_secs: Optional[int] = None,
) -> ApifyDatasetLoader:
"""Run an Actor on the Apify platform and wait for results to be ready.
Args:
actor_id (str): The ID or name of the Actor on the Apify platform.
run_input (Dict): The inp... | https://python.langchain.com/en/latest/_modules/langchain/utilities/apify.html |
ac995eccf3d4-0 | .md
.pdf
Quickstart Guide
Contents
Installation
Environment Setup
Building a Language Model Application: LLMs
LLMs: Get predictions from a language model
Prompt Templates: Manage prompts for LLMs
Chains: Combine LLMs and prompts in multi-step workflows
Agents: Dynamically Call Chains Based on User Input
Memory: Add S... | https://python.langchain.com/en/latest/getting_started/getting_started.html |
ac995eccf3d4-1 | The most basic building block of LangChain is calling an LLM on some input.
Let’s walk through a simple example of how to do this.
For this purpose, let’s pretend we are building a service that generates a company name based on what the company makes.
In order to do this, we first need to import the LLM wrapper.
from l... | https://python.langchain.com/en/latest/getting_started/getting_started.html |
ac995eccf3d4-2 | template="What is a good name for a company that makes {product}?",
)
Let’s now see how this works! We can call the .format method to format it.
print(prompt.format(product="colorful socks"))
What is a good name for a company that makes colorful socks?
For more details, check out the getting started guide for prompts.
... | https://python.langchain.com/en/latest/getting_started/getting_started.html |
ac995eccf3d4-3 | There we go! There’s the first chain - an LLM Chain.
This is one of the simpler types of chains, but understanding how it works will set you up well for working with more complex chains.
For more details, check out the getting started guide for chains.
Agents: Dynamically Call Chains Based on User Input#
So far the cha... | https://python.langchain.com/en/latest/getting_started/getting_started.html |
ac995eccf3d4-4 | Now we can get started!
from langchain.agents import load_tools
from langchain.agents import initialize_agent
from langchain.agents import AgentType
from langchain.llms import OpenAI
# First, let's load the language model we're going to use to control the agent.
llm = OpenAI(temperature=0)
# Next, let's load some tools... | https://python.langchain.com/en/latest/getting_started/getting_started.html |
ac995eccf3d4-5 | > Finished chain.
Memory: Add State to Chains and Agents#
So far, all the chains and agents we’ve gone through have been stateless. But often, you may want a chain or agent to have some concept of “memory” so that it may remember information about its previous interactions. The clearest and simple example of this is wh... | https://python.langchain.com/en/latest/getting_started/getting_started.html |
ac995eccf3d4-6 | print(output)
> Entering new chain...
Prompt after formatting:
The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.
Current conversation:
Huma... | https://python.langchain.com/en/latest/getting_started/getting_started.html |
ac995eccf3d4-7 | chat([HumanMessage(content="Translate this sentence from English to French. I love programming.")])
# -> AIMessage(content="J'aime programmer.", additional_kwargs={})
You can also pass in multiple messages for OpenAI’s gpt-3.5-turbo and gpt-4 models.
messages = [
SystemMessage(content="You are a helpful assistant t... | https://python.langchain.com/en/latest/getting_started/getting_started.html |
ac995eccf3d4-8 | result.llm_output['token_usage']
# -> {'prompt_tokens': 71, 'completion_tokens': 18, 'total_tokens': 89}
Chat Prompt Templates#
Similar to LLMs, you can make use of templating by using a MessagePromptTemplate. You can build a ChatPromptTemplate from one or more MessagePromptTemplates. You can use ChatPromptTemplate’s f... | https://python.langchain.com/en/latest/getting_started/getting_started.html |
ac995eccf3d4-9 | ChatPromptTemplate,
SystemMessagePromptTemplate,
HumanMessagePromptTemplate,
)
chat = ChatOpenAI(temperature=0)
template = "You are a helpful assistant that translates {input_language} to {output_language}."
system_message_prompt = SystemMessagePromptTemplate.from_template(template)
human_template = "{text}"
hu... | https://python.langchain.com/en/latest/getting_started/getting_started.html |
ac995eccf3d4-10 | # Now let's test it out!
agent.run("Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?")
> Entering new AgentExecutor chain...
Thought: I need to use a search engine to find Olivia Wilde's boyfriend and a calculator to raise his age to the 0.23 power.
Action:
{
"action": "Search",
"a... | https://python.langchain.com/en/latest/getting_started/getting_started.html |
ac995eccf3d4-11 | from langchain.prompts import (
ChatPromptTemplate,
MessagesPlaceholder,
SystemMessagePromptTemplate,
HumanMessagePromptTemplate
)
from langchain.chains import ConversationChain
from langchain.chat_models import ChatOpenAI
from langchain.memory import ConversationBufferMemory
prompt = ChatPromptTempl... | https://python.langchain.com/en/latest/getting_started/getting_started.html |
ac995eccf3d4-12 | LLMs: Get predictions from a language model
Prompt Templates: Manage prompts for LLMs
Chains: Combine LLMs and prompts in multi-step workflows
Agents: Dynamically Call Chains Based on User Input
Memory: Add State to Chains and Agents
Building a Language Model Application: Chat Models
Get Message Completions from a Chat... | https://python.langchain.com/en/latest/getting_started/getting_started.html |
5e67be7764e6-0 | .md
.pdf
Pinecone
Contents
Installation and Setup
Wrappers
VectorStore
Pinecone#
This page covers how to use the Pinecone ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific Pinecone wrappers.
Installation and Setup#
Install the Python SDK with pip install ... | https://python.langchain.com/en/latest/ecosystem/pinecone.html |
6354dc2df30d-0 | .md
.pdf
Writer
Contents
Installation and Setup
Wrappers
LLM
Writer#
This page covers how to use the Writer ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific Writer wrappers.
Installation and Setup#
Get an Writer api key and set it as an environment varia... | https://python.langchain.com/en/latest/ecosystem/writer.html |
ec27e936a292-0 | .md
.pdf
ForefrontAI
Contents
Installation and Setup
Wrappers
LLM
ForefrontAI#
This page covers how to use the ForefrontAI ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific ForefrontAI wrappers.
Installation and Setup#
Get an ForefrontAI api key and set i... | https://python.langchain.com/en/latest/ecosystem/forefrontai.html |
f96b310d69ed-0 | .md
.pdf
NLPCloud
Contents
Installation and Setup
Wrappers
LLM
NLPCloud#
This page covers how to use the NLPCloud ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific NLPCloud wrappers.
Installation and Setup#
Install the Python SDK with pip install nlpcloud... | https://python.langchain.com/en/latest/ecosystem/nlpcloud.html |
534e168bb91e-0 | .md
.pdf
Modal
Contents
Installation and Setup
Define your Modal Functions and Webhooks
Wrappers
LLM
Modal#
This page covers how to use the Modal ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific Modal wrappers.
Installation and Setup#
Install with pip in... | https://python.langchain.com/en/latest/ecosystem/modal.html |
534e168bb91e-1 | @stub.webhook(method="POST")
def get_text(item: Item):
return {"prompt": run_gpt2.call(item.prompt)}
Wrappers#
LLM#
There exists an Modal LLM wrapper, which you can access with
from langchain.llms import Modal
previous
Milvus
next
MyScale
Contents
Installation and Setup
Define your Modal Functions and Webhooks
... | https://python.langchain.com/en/latest/ecosystem/modal.html |
ea451f6e4e4e-0 | .md
.pdf
Petals
Contents
Installation and Setup
Wrappers
LLM
Petals#
This page covers how to use the Petals ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific Petals wrappers.
Installation and Setup#
Install with pip install petals
Get a Hugging Face api k... | https://python.langchain.com/en/latest/ecosystem/petals.html |
64b0eff36fc2-0 | .md
.pdf
Cohere
Contents
Installation and Setup
Wrappers
LLM
Embeddings
Cohere#
This page covers how to use the Cohere ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific Cohere wrappers.
Installation and Setup#
Install the Python SDK with pip install coher... | https://python.langchain.com/en/latest/ecosystem/cohere.html |
0fc1e61dbe7d-0 | .ipynb
.pdf
ClearML Integration
Contents
Getting API Credentials
Setting Up
Scenario 1: Just an LLM
Scenario 2: Creating an agent with tools
Tips and Next Steps
ClearML Integration#
In order to properly keep track of your langchain experiments and their results, you can enable the ClearML integration. ClearML is an e... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-1 | llm = OpenAI(temperature=0, callbacks=callbacks)
The clearml callback is currently in beta and is subject to change based on updates to `langchain`. Please report any issues to https://github.com/allegroai/clearml/issues with the tag `langchain`.
Scenario 1: Just an LLM#
First, let’s just run a single LLM a few times a... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-2 | {'action': 'on_llm_start', 'name': 'OpenAI', 'step': 3, 'starts': 2, 'ends': 1, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 1, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'prompts': 'Tell me a poem'}
{'action': 'on_llm_start', 'name': 'OpenAI', '... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-3 | {'action': 'on_llm_start', 'name': 'OpenAI', 'step': 3, 'starts': 2, 'ends': 1, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 1, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'prompts': 'Tell me a joke'}
{'action': 'on_llm_start', 'name': 'OpenAI', '... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-4 | {'action': 'on_llm_end', 'token_usage_prompt_tokens': 24, 'token_usage_completion_tokens': 138, 'token_usage_total_tokens': 162, 'model_name': 'text-davinci-003', 'step': 4, 'starts': 2, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_st... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-5 | {'action': 'on_llm_end', 'token_usage_prompt_tokens': 24, 'token_usage_completion_tokens': 138, 'token_usage_total_tokens': 162, 'model_name': 'text-davinci-003', 'step': 4, 'starts': 2, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_st... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-6 | {'action': 'on_llm_end', 'token_usage_prompt_tokens': 24, 'token_usage_completion_tokens': 138, 'token_usage_total_tokens': 162, 'model_name': 'text-davinci-003', 'step': 4, 'starts': 2, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_st... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-7 | {'action': 'on_llm_end', 'token_usage_prompt_tokens': 24, 'token_usage_completion_tokens': 138, 'token_usage_total_tokens': 162, 'model_name': 'text-davinci-003', 'step': 4, 'starts': 2, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_st... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-8 | {'action': 'on_llm_end', 'token_usage_prompt_tokens': 24, 'token_usage_completion_tokens': 138, 'token_usage_total_tokens': 162, 'model_name': 'text-davinci-003', 'step': 4, 'starts': 2, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_st... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-9 | {'action': 'on_llm_end', 'token_usage_prompt_tokens': 24, 'token_usage_completion_tokens': 138, 'token_usage_total_tokens': 162, 'model_name': 'text-davinci-003', 'step': 4, 'starts': 2, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 0, 'chain_ends': 0, 'llm_starts': 2, 'llm_ends': 2, 'llm_streams': 0, 'tool_st... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-10 | 0 on_llm_start OpenAI 1 1 0 0 0 0
1 on_llm_start OpenAI 1 1 0 0 0 0
2 on_llm_start OpenAI 1 1 0 0 0 0
3 on_llm_start OpenAI 1 1 0 0 0 0
... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-11 | 14 on_llm_start OpenAI 3 2 1 0 0 0
15 on_llm_start OpenAI 3 2 1 0 0 0
16 on_llm_start OpenAI 3 2 1 0 0 0
17 on_llm_start OpenAI 3 2 1 0 0 0
... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-12 | 5 0 1 ... NaN NaN
6 0 1 ... 0.0 5.5
7 0 1 ... 2.0 6.5
8 0 1 ... 0.0 5.5
9 0 ... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-13 | 0 NaN NaN NaN NaN
1 NaN NaN NaN NaN
2 NaN NaN NaN NaN
3 NaN NaN NaN NaN
4 NaN N... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-14 | 21 8.28 6th and 7th grade 115.58 112.37
22 5.20 5th and 6th grade 133.58 131.54
23 8.28 6th and 7th grade 115.58 112.37
gutierrez_polini crawford gulpease_index osman
0 NaN NaN NaN ... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-15 | 19 54.83 1.4 72.1 100.17
20 62.30 -0.2 79.8 116.91
21 54.83 1.4 72.1 100.17
22 62.30 -0.2 79.8 116.91
23 54.83 1.4 72.1 100.17
[24 rows x 39 columns], 'session_an... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-16 | 2 \n\nQ: What did the fish say when it hit the w...
3 \n\nRoses are red,\nViolets are blue,\nSugar i...
4 \n\nQ: What did the fish say when it hit the w...
5 \n\nRoses are red,\nViolets are blue,\nSugar i...
6 \n\nQ: What did the fish say when it hit the w...
7 \n\nRoses are red,\nViolets are... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-17 | 1 138 83.66 4.8
2 138 109.04 1.3
3 138 83.66 4.8
4 138 109.04 1.3
... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-18 | 10 ... 0 5.5 5.20
11 ... 2 6.5 8.28
text_standard fernandez_huerta szigriszt_pazos gutierrez_polini \
0 5th and 6th grade 133.58 131.54 62.30
1 6th and 7th grade 115... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-19 | crawford gulpease_index osman
0 -0.2 79.8 116.91
1 1.4 72.1 100.17
2 -0.2 79.8 116.91
3 1.4 72.1 100.17
4 -0.2 79.8 116.91
5 1.4 72.1 100.17
6 -0.2 79.8 116.91
7 1.4 ... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-20 | Finally, if you enabled visualizations, these are stored as HTML files under debug samples.
Scenario 2: Creating an agent with tools#
To show a more advanced workflow, let’s create an agent with access to tools. The way ClearML tracks the results is not different though, only the table will look slightly different as t... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-21 | {'action': 'on_llm_start', 'name': 'OpenAI', 'step': 2, 'starts': 2, 'ends': 0, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 1, 'llm_ends': 0, 'llm_streams': 0, 'tool_starts': 0, 'tool_ends': 0, 'agent_ends': 0, 'prompts': 'Answer the following questions as best you can. You have access... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-22 | {'action': 'on_llm_end', 'token_usage_prompt_tokens': 189, 'token_usage_completion_tokens': 34, 'token_usage_total_tokens': 223, 'model_name': 'text-davinci-003', 'step': 3, 'starts': 2, 'ends': 1, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 1, 'llm_ends': 1, 'llm_streams': 0, 'tool_st... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-23 | I need to find out who sang summer of 69 and then find out who their wife is.
Action: Search
Action Input: "Who sang summer of 69"{'action': 'on_agent_action', 'tool': 'Search', 'tool_input': 'Who sang summer of 69', 'log': ' I need to find out who sang summer of 69 and then find out who their wife is.\nAction: Search\... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
0fc1e61dbe7d-24 | Observation: Bryan Adams - Summer Of 69 (Official Music Video).
Thought:{'action': 'on_tool_end', 'output': 'Bryan Adams - Summer Of 69 (Official Music Video).', 'step': 6, 'starts': 4, 'ends': 2, 'errors': 0, 'text_ctr': 0, 'chain_starts': 1, 'chain_ends': 0, 'llm_starts': 1, 'llm_ends': 1, 'llm_streams': 0, 'tool_sta... | https://python.langchain.com/en/latest/ecosystem/clearml_tracking.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.