Compare commits

...

9 Commits

Author SHA1 Message Date
Eugene Yurtsev
e4eaa3a8a7 x 2023-10-23 15:31:23 -04:00
SakshiShorthillsAI
ca0f21e55c Update baidu_qianfan_endpoint.py (#94)
* Update modal.py

feat: Raise KeyError when 'prompt' key is missing in JSON response

This commit updates the error handling in the code to raise a KeyError when
the 'prompt' key is not found in the JSON response. This change makes the code
more explicit about the nature of the error, helping to improve clarity and
debugging.

* Update baidu_qianfan_endpoint.py

Import Error was used as Exception, but value error was raised so changed ValueError to ImportError

* Update databricks.py

Updated the raised ValueError to ImportError

---------

Co-authored-by: Aashish Saini <141953346+ShorthillsAI@users.noreply.github.com>
2023-10-19 12:34:47 +05:30
HarshGuptaShorthillsAI
4c4f4bdef9 Updated debugging.md with grammatical corrections (#96)
* Update modal.py

feat: Raise KeyError when 'prompt' key is missing in JSON response

This commit updates the error handling in the code to raise a KeyError when
the 'prompt' key is not found in the JSON response. This change makes the code
more explicit about the nature of the error, helping to improve clarity and
debugging.

* Updated debugging.md with grammatical corrections

"There's a number of callbacks" was grammatically incorrect and is replaced with "There are a...". There was a typographical error in the subheading. It was written as "set_vebose = True".

---------

Co-authored-by: Aashish Saini <141953346+ShorthillsAI@users.noreply.github.com>
2023-10-19 12:34:16 +05:30
AdityaKalraShorthillsAI
a316de60e3 fixed index.mdx (#92)
* Update modal.py

feat: Raise KeyError when 'prompt' key is missing in JSON response

This commit updates the error handling in the code to raise a KeyError when
the 'prompt' key is not found in the JSON response. This change makes the code
more explicit about the nature of the error, helping to improve clarity and
debugging.

* fixed index.mdx

Fixed grammatical error in file index.mdx.
Changed 'it's' to 'it is'.

I would like to emphasize that your feedback is immensely valuable to us and is truly treasured. We greatly appreciate your insights and input, as they help us improve and grow.

Gratitude
@baskaryan @hwchase17

---------

Co-authored-by: Aashish Saini <141953346+ShorthillsAI@users.noreply.github.com>
2023-10-19 12:33:27 +05:30
Shorthills AI
b850269e3f Merge branch 'langchain-ai:master' into master 2023-10-19 12:32:46 +05:30
HarshGuptaShorthillsAI
4a5a0cdedf Logical and grammatical error in prompt_llm_parser.ipynb (#95)
* Update modal.py

feat: Raise KeyError when 'prompt' key is missing in JSON response

This commit updates the error handling in the code to raise a KeyError when
the 'prompt' key is not found in the JSON response. This change makes the code
more explicit about the nature of the error, helping to improve clarity and
debugging.

* prompt_llm_parser.ipynb

---------

Co-authored-by: Aashish Saini <141953346+ShorthillsAI@users.noreply.github.com>
2023-10-19 12:32:27 +05:30
Shorthills AI
7ccdb59bee Merge branch 'langchain-ai:master' into master 2023-10-19 12:26:25 +05:30
UpneetShorthillsAI
4b1e80c837 Update faker_presidio_mapping.py (#93)
* Update modal.py

feat: Raise KeyError when 'prompt' key is missing in JSON response

This commit updates the error handling in the code to raise a KeyError when
the 'prompt' key is not found in the JSON response. This change makes the code
more explicit about the nature of the error, helping to improve clarity and
debugging.

* Update faker_presidio_mapping.py

lambda was written twice, I have corrected the same

* Update base_moderation.py

Rectified input to input_text

---------

Co-authored-by: Aashish Saini <141953346+ShorthillsAI@users.noreply.github.com>
2023-10-19 12:26:05 +05:30
Sanskar Tanwar
ef53b514a2 Update tavily_search_api.py (#87)
* Update modal.py

feat: Raise KeyError when 'prompt' key is missing in JSON response

This commit updates the error handling in the code to raise a KeyError when
the 'prompt' key is not found in the JSON response. This change makes the code
more explicit about the nature of the error, helping to improve clarity and
debugging.

* Update tavily_search_api.py

ValueError Must be ImportError

---------

Co-authored-by: Aashish Saini <141953346+ShorthillsAI@users.noreply.github.com>
2023-10-19 12:22:44 +05:30
8 changed files with 10 additions and 12 deletions

View File

@@ -30,7 +30,7 @@
"source": [
"## PromptTemplate + LLM\n",
"\n",
"The simplest composition is just combing a prompt and model to create a chain that takes user input, adds it to a prompt, passes it to a model, and returns the raw model input.\n",
"The simplest composition is just combing a prompt and model to create a chain that takes user input, adds it to a prompt, passes it to a model, and returns the raw model output.\n",
"\n",
"Note, you can mix and match PromptTemplate/ChatPromptTemplates and LLMs/ChatModels as you like here."
]
@@ -76,7 +76,7 @@
"id": "7eb9ef50",
"metadata": {},
"source": [
"Often times we want to attach kwargs that'll be passed to each model call. Here's a few examples of that:"
"Often times we want to attach kwargs that'll be passed to each model call. Here are a few examples of that:"
]
},
{

View File

@@ -376,7 +376,7 @@ agent.run("Who directed the 2023 film Oppenheimer and what is their age? What is
</details>
### `set_vebose(True)`
### `set_verbose(True)`
Setting the `verbose` flag will print out inputs and outputs in a slightly more readable format and will skip logging certain raw outputs (like the token usage stats for an LLM call) so that you can focus on application logic.
@@ -656,6 +656,6 @@ agent.run("Who directed the 2023 film Oppenheimer and what is their age? What is
## Other callbacks
`Callbacks` are what we use to execute any functionality within a component outside the primary component logic. All of the above solutions use `Callbacks` under the hood to log intermediate steps of components. There's a number of `Callbacks` relevant for debugging that come with LangChain out of the box, like the [FileCallbackHandler](/docs/modules/callbacks/how_to/filecallbackhandler). You can also implement your own callbacks to execute custom functionality.
`Callbacks` are what we use to execute any functionality within a component outside the primary component logic. All of the above solutions use `Callbacks` under the hood to log intermediate steps of components. There are a number of `Callbacks` relevant for debugging that come with LangChain out of the box, like the [FileCallbackHandler](/docs/modules/callbacks/how_to/filecallbackhandler). You can also implement your own callbacks to execute custom functionality.
See here for more info on [Callbacks](/docs/modules/callbacks/), how to use them, and customize them.

View File

@@ -1,6 +1,6 @@
# Deployment
In today's fast-paced technological landscape, the use of Large Language Models (LLMs) is rapidly expanding. As a result, it's crucial for developers to understand how to effectively deploy these models in production environments. LLM interfaces typically fall into two categories:
In today's fast-paced technological landscape, the use of Large Language Models (LLMs) is rapidly expanding. As a result, it is crucial for developers to understand how to effectively deploy these models in production environments. LLM interfaces typically fall into two categories:
- **Case 1: Utilizing External LLM Providers (OpenAI, Anthropic, etc.)**
In this scenario, most of the computational burden is handled by the LLM providers, while LangChain simplifies the implementation of business logic around these services. This approach includes features such as prompt templating, chat message generation, caching, vector embedding database creation, preprocessing, etc.

View File

@@ -59,7 +59,7 @@ class BaseModeration:
input_text = message.content
else:
raise ValueError(
f"Invalid input type {type(input)}. "
f"Invalid input type {type(input_text)}. "
"Must be a PromptValue, str, or list of BaseMessages."
)
return input_text

View File

@@ -47,9 +47,7 @@ def get_pseudoanonymizer_mapping(seed: Optional[int] = None) -> Dict[str, Callab
"IT_DRIVER_LICENSE": lambda _: fake.bothify(text="?A#######?").upper(),
"IT_VAT_CODE": lambda _: fake.bothify(text="IT???????????"),
"IT_PASSPORT": lambda _: str(fake.random_number(digits=9, fix_len=True)),
"IT_IDENTITY_CARD": lambda _: lambda _: str(
fake.random_number(digits=7, fix_len=True)
),
"IT_IDENTITY_CARD": lambda _: str(fake.random_number(digits=7, fix_len=True)),
# Singapore-specific entities
"SG_NRIC_FIN": lambda _: fake.bothify(text="????####?").upper(),
# Australia-specific entities

View File

@@ -96,7 +96,7 @@ class QianfanLLMEndpoint(LLM):
values["client"] = qianfan.Completion(**params)
except ImportError:
raise ValueError(
raise ImportError(
"qianfan package not found, please install it with "
"`pip install qianfan`"
)

View File

@@ -92,7 +92,7 @@ def get_repl_context() -> Any:
return get_context()
except ImportError:
raise ValueError(
raise ImportError(
"Cannot access dbruntime, not running inside a Databricks notebook."
)

View File

@@ -31,7 +31,7 @@ class TavilySearchAPIRetriever(BaseRetriever):
try:
from tavily import Client
except ImportError:
raise ValueError(
raise ImportError(
"Tavily python package not found. "
"Please install it with `pip install tavily-python`."
)