Commit Graph

506 Commits

Author SHA1 Message Date
John (Jet Token)
6b2f9a841a add to reference 2023-02-07 13:54:34 -08:00
John (Jet Token)
0e6447cad0 rename to Guards Module 2023-02-07 13:53:05 -08:00
John (Jet Token)
86be14d6f0 Rename module to Alignment, add guards as subtopic 2023-02-07 00:35:39 -08:00
John (Jet Token)
3ee9c65e24 wording 2023-02-06 17:21:34 -08:00
John (Jet Token)
6790933af2 reword 2023-02-06 16:40:19 -08:00
John (Jet Token)
e39ed641ba wording 2023-02-06 16:29:00 -08:00
John (Jet Token)
b021ac7fdf reword 2023-02-06 16:06:10 -08:00
John (Jet Token)
43450e8e85 test doc not needed; accidental commit 2023-02-06 15:49:41 -08:00
John (Jet Token)
5647274ad7 rogue print statement 2023-02-06 15:47:43 -08:00
John (Jet Token)
586c1cfdb6 restriction guard tests 2023-02-06 15:43:47 -08:00
John (Jet Token)
d6eba66191 guard tests 2023-02-06 15:09:47 -08:00
John (Jet Token)
a3237833fa missing type 2023-02-06 15:09:34 -08:00
John (Jet Token)
2c9e894f33 finish guard docs v1 2023-02-06 14:18:13 -08:00
John (Jet Token)
c357355575 custom guard getting started 2023-02-06 13:06:03 -08:00
John (Jet Token)
e8a4c88b52 forgot import in example 2023-02-06 13:05:51 -08:00
John (Jet Token)
6e69b5b2a4 typo 2023-02-06 12:49:50 -08:00
John (Jet Token)
9fc3121e2a docs (WIP) 2023-02-06 12:49:10 -08:00
John (Jet Token)
ad545db681 Add custom guard, base class 2023-02-04 17:08:01 -08:00
John (Jet Token)
d78b62c1b4 removing adding restrictions to template for now. Future feature. 2023-02-03 12:11:13 -08:00
John (Jet Token)
a25d9334a7 add normalization to docs 2023-02-03 02:47:09 -08:00
John (Jet Token)
bd3e5eca4b docs in progress 2023-02-03 02:41:25 -08:00
John (Jet Token)
313fd40fae guard directive 2023-02-03 02:37:27 -08:00
John (Jet Token)
b12aec69f1 linting 2023-02-03 02:37:14 -08:00
John (Jet Token)
3a3666ba76 formatting 2023-02-03 02:23:08 -08:00
John (Jet Token)
06464c2542 add @guard directive 2023-02-03 02:22:18 -08:00
John (Jet Token)
1475435096 add boolean normalization utility 2023-02-03 02:13:31 -08:00
Harrison Chase
fc0cfd7d1f docs (#848) 2023-02-02 11:35:36 -08:00
Harrison Chase
4d32441b86 bump version to 0076 (#847) v0.0.76 2023-02-02 10:05:39 -08:00
Harrison Chase
23d5f64bda Harrison/ngram example (#846)
Co-authored-by: Sean Spriggens <ssprigge@syr.edu>
2023-02-02 09:44:42 -08:00
Harrison Chase
0de55048b7 return code for pal (#844) 2023-02-02 08:47:20 -08:00
Harrison Chase
d564308e0f rfc: instruct embeddings (#811)
Co-authored-by: seanaedmiston <seane999@gmail.com>
2023-02-02 08:44:02 -08:00
Nick Furlotte
576609e665 Update PAL to allow passing local and global context to PythonREPL (#774)
Passing additional variables to the python environment can be useful for
example if you want to generate code to analyze a dataset.

I also added a tracker for the executed code - `code_history`.
2023-02-02 08:34:23 -08:00
Harrison Chase
3f952eb597 add from string method (#820) 2023-02-02 08:23:54 -08:00
Ikko Eltociear Ashimine
ba26a879e0 Fix typo in crawler.py (#842)
seperator -> separator
2023-02-02 08:23:38 -08:00
Eli Mernit
bfabd1d5c0 Added new deployment template (#835)
This PR introduces a new template for deploying LangChain apps as web
endpoints. It includes template code, and links to a detailed
code-walkthrough.
2023-02-01 23:38:36 -08:00
Jonas Ehrenstein
f3508228df Minor fix for google search util: it's uncertain if "snippet" in results exists (#830)
The results from Google search may not always contain a "snippet". 

Example:
`{'kind': 'customsearch#result', 'title': 'FEMA Flood Map', 'htmlTitle':
'FEMA Flood Map', 'link': 'https://msc.fema.gov/portal/home',
'displayLink': 'msc.fema.gov', 'formattedUrl':
'https://msc.fema.gov/portal/home', 'htmlFormattedUrl':
'https://<b>msc</b>.fema.gov/portal/home'}`

This will cause a KeyError at line 99
`snippets.append(result["snippet"])`.
2023-02-01 23:37:52 -08:00
Zach Schillaci
b4eb043b81 Minor fix to SQLDatabaseChain doc (#826) 2023-02-01 23:37:38 -08:00
Istora Mandiri
06438794e1 Fix typo in textsplitter docs (#825) 2023-02-01 23:32:35 -08:00
Raza Habib
9f8e05ffd4 Update __init__.py (#827)
Remove duplicate APIChain
2023-02-01 23:31:38 -08:00
Harrison Chase
b0d560be56 add to gallery (#824) 2023-02-01 07:10:15 -08:00
Johanna Appel
ebea40ce86 Add 'truncate' parameter for CohereEmbeddings (#798)
Currently, the 'truncate' parameter of the cohere API is not supported.

This means that by default, if trying to generate and embedding that is
too big, the call will just fail with an error (which is frustrating if
using this embedding source e.g. with GPT-Index, because it's hard to
handle it properly when generating a lot of embeddings).
With the parameter, one can decide to either truncate the START or END
of the text to fit the max token length and still generate an embedding
without throwing the error.

In this PR, I added this parameter to the class.

_Arguably, there should be a better way to handle this error, e.g. by
optionally calling a function or so that gets triggered when the token
limit is reached and can split the document or some such. Especially in
the use case with GPT-Index, its often hard to estimate the token counts
for each document and I'd rather sort out the troublemakers or simply
split them than interrupting the whole execution.
Thoughts?_

---------

Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
2023-02-01 07:09:03 -08:00
Harrison Chase
b9045f7e0d bump version to 0075 (#819) v0.0.75 2023-01-31 00:18:32 -08:00
Harrison Chase
7b4882a2f4 Harrison/tf embeddings (#817)
Co-authored-by: Ryohei Kuroki <10434946+yakigac@users.noreply.github.com>
2023-01-31 00:00:08 -08:00
Harrison Chase
5d4b6e4d4e conversational agent fix (#818) 2023-01-30 23:59:55 -08:00
Harrison Chase
94ae126747 return sql intermediate steps (#792) 2023-01-30 15:10:48 -08:00
bair82
ae5695ad32 Update cohere.py (#795)
When stop tokens are set in Cohere LLM constructor, they are currently
not stripped from the response, and they should be stripped
2023-01-30 14:55:44 -08:00
Johanna Appel
cacf4091c0 Fix documentation for 'model' parameter in CohereEmbeddings (#797)
Currently, the class parameter 'model_name' of the CohereEmbeddings
class is not supported, but 'model' is. The class documentation is
inconsistent with this, though, so I propose to either fix the
documentation (this PR right now) or fix the parameter.

It will create the following error:
```
ValidationError: 1 validation error for CohereEmbeddings
model_name
  extra fields not permitted (type=value_error.extra)
```
2023-01-30 14:55:08 -08:00
Jason Liu
54f9e4287f Pass kwargs from initialize_agent into agent classmethod (#799)
# Problem
I noticed that in order to change the prefix of the prompt in the
`zero-shot-react-description` agent
we had to dig around to subset strings deep into the agent's attributes.
It requires the user to inspect a long chain of attributes and classes.

`initialize_agent -> AgentExecutor -> Agent -> LLMChain -> Prompt from
Agent.create_prompt`

``` python
agent = initialize_agent(
    tools=tools,
    llm=fake_llm,
    agent="zero-shot-react-description"
)
prompt_str = agent.agent.llm_chain.prompt.template
new_prompt_str = change_prefix(prompt_str)
agent.agent.llm_chain.prompt.template = new_prompt_str
```

# Implemented Solution

`initialize_agent` accepts `**kwargs` but passes it to `AgentExecutor`
but not `ZeroShotAgent`, by simply giving the kwargs to the agent class
methods we can support changing the prefix and suffix for one agent
while allowing future agents to take advantage of `initialize_agent`.


```
agent = initialize_agent(
    tools=tools,
    llm=fake_llm,
    agent="zero-shot-react-description",
    agent_kwargs={"prefix": prefix, "suffix": suffix}
)
```

To be fair, this was before finding docs around custom agents here:
https://langchain.readthedocs.io/en/latest/modules/agents/examples/custom_agent.html?highlight=custom%20#custom-llmchain
but i find that my use case just needed to change the prefix a little.


# Changes

* Pass kwargs to Agent class method
* Added a test to check suffix and prefix

---------

Co-authored-by: Jason Liu <jason@jxnl.coA>
2023-01-30 14:54:09 -08:00
Roger Zurawicki
c331009440 docs: Update langchain link to PyPI (#800)
Simple one-line fix

CONTRIBUTING used a link that pointed to the `ruff` project.
2023-01-30 14:53:16 -08:00
Roy Williams
6086292252 Centralize logic for loading from LangChainHub, add ability to pin dependencies (#805)
It's generally considered to be a good practice to pin dependencies to
prevent surprise breakages when a new version of a dependency is
released. This commit adds the ability to pin dependencies when loading
from LangChainHub.

Centralizing this logic and using urllib fixes an issue identified by
some windows users highlighted in this video -
https://youtu.be/aJ6IQUh8MLQ?t=537
2023-01-30 14:52:17 -08:00