Commit Graph

90 Commits (main)

Author SHA1 Message Date
Harrison Chase 81abcae91a
Harrison/banana fix (#1311)
Co-authored-by: Erik Dunteman <44653944+erik-dunteman@users.noreply.github.com>
1 year ago
Harrison Chase 96db6ed073
cleanup (#1274) 1 year ago
Harrison Chase 7e8f832cd6
Harrison/cohere params (#1278)
Co-authored-by: Stefano Faraggi <40745694+stepp1@users.noreply.github.com>
1 year ago
Harrison Chase a8e88e1874
Harrison/logprobs (#1279)
Co-authored-by: Prateek Shah <97124740+prateekspanning@users.noreply.github.com>
1 year ago
Enrico Shippole 9becdeaadf
Add Writer, Banana, Modal, StochasticAI (#1270)
Add LLM wrappers and examples for Banana, Writer, Modal, Stochastic AI

Added rigid json format for Banana and Modal
1 year ago
Iskren Ivov Chernev 8e3cd3e0dd
Add DeepInfra LLM support (#1232)
DeepInfra is an Inference-as-a-Service provider. Add a simple wrapper
using HTTPS requests.
1 year ago
Dennis Antela Martinez 53c67e04d4
add aleph alpha llm (#1207)
Integrate Aleph Alpha's client into Langchain to provide access to the
luminous models - more info on latest benchmarks here:
https://www.aleph-alpha.com/luminous-performance-benchmarks
1 year ago
Harrison Chase d90a287d8f
Harrison/updating docs (#1196) 1 year ago
Konstantin Hebenstreit af94f1dd97
HuggingFaceEndpoint: Correct Example for ImportError (#1176)
When I try to import the Class HuggingFaceEndpoint I get an Import
Error: cannot import name 'HuggingFaceEndpoint' from 'langchain'.
(langchain version 0.0.88)
These two imports work fine: from langchain import HuggingFacePipeline
and from langchain import HuggingFaceHub.

So I corrected the import statement in the example. There is probably a
better solution to this, but this fixes the Error for me.
1 year ago
Zach Schillaci 159c560c95
Refactor some loops into list comprehensions (#1185) 1 year ago
Harrison Chase 9d6d8f85da
Harrison/self hosted runhouse (#1154)
Co-authored-by: Donny Greenberg <dongreenberg2@gmail.com>
Co-authored-by: John Dagdelen <jdagdelen@users.noreply.github.com>
Co-authored-by: Harrison Chase <harrisonchase@Harrisons-MBP.attlocal.net>
Co-authored-by: Andrew White <white.d.andrew@gmail.com>
Co-authored-by: Peng Qu <82029664+pengqu123@users.noreply.github.com>
Co-authored-by: Matt Robinson <mthw.wm.robinson@gmail.com>
Co-authored-by: jeff <tangj1122@gmail.com>
Co-authored-by: Harrison Chase <harrisonchase@Harrisons-MacBook-Pro.local>
Co-authored-by: zanderchase <zander@unfold.ag>
Co-authored-by: Charles Frye <cfrye59@gmail.com>
Co-authored-by: zanderchase <zanderchase@gmail.com>
Co-authored-by: Shahriar Tajbakhsh <sh.tajbakhsh@gmail.com>
Co-authored-by: Stefan Keselj <skeselj@princeton.edu>
Co-authored-by: Francisco Ingham <fpingham@gmail.com>
Co-authored-by: Dhruv Anand <105786647+dhruv-anand-aintech@users.noreply.github.com>
Co-authored-by: cragwolfe <cragcw@gmail.com>
Co-authored-by: Anton Troynikov <atroyn@users.noreply.github.com>
Co-authored-by: William FH <13333726+hinthornw@users.noreply.github.com>
Co-authored-by: Oliver Klingefjord <oliver@klingefjord.com>
Co-authored-by: blob42 <contact@blob42.xyz>
Co-authored-by: blob42 <spike@w530>
Co-authored-by: Enrico Shippole <henryshippole@gmail.com>
Co-authored-by: Ibis Prevedello <ibiscp@gmail.com>
Co-authored-by: jped <jonathanped@gmail.com>
Co-authored-by: Justin Torre <justintorre75@gmail.com>
Co-authored-by: Ivan Vendrov <ivan@anthropic.com>
Co-authored-by: Sasmitha Manathunga <70096033+mmz-001@users.noreply.github.com>
Co-authored-by: Ankush Gola <9536492+agola11@users.noreply.github.com>
Co-authored-by: Matt Robinson <mrobinson@unstructuredai.io>
Co-authored-by: Jeff Huber <jeffchuber@gmail.com>
Co-authored-by: Akshay <64036106+akshayvkt@users.noreply.github.com>
Co-authored-by: Andrew Huang <jhuang16888@gmail.com>
Co-authored-by: rogerserper <124558887+rogerserper@users.noreply.github.com>
Co-authored-by: seanaedmiston <seane999@gmail.com>
Co-authored-by: Hasegawa Yuya <52068175+Hase-U@users.noreply.github.com>
Co-authored-by: Ivan Vendrov <ivendrov@gmail.com>
Co-authored-by: Chen Wu (吴尘) <henrychenwu@cmu.edu>
Co-authored-by: Dennis Antela Martinez <dennis.antela@gmail.com>
Co-authored-by: Maxime Vidal <max.vidal@hotmail.fr>
Co-authored-by: Rishabh Raizada <110235735+rishabh-ti@users.noreply.github.com>
1 year ago
trigaten 6fafcd0a70
Strange behavior with LLM import requirements (#1104)
This import works fine:
```python
from langchain import Anthropic
```
This import does not:
```python
from langchain import AI21
```

```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'AI21' from 'langchain' (/opt/anaconda3/envs/fed_nlp/lib/python3.9/site-packages/langchain/__init__.py)
```

I think there is a slight documentation inconsistency here:
https://langchain.readthedocs.io/en/latest/reference/modules/llms.html

This PR starts to solve that. Should all the import examples be
`from langchain.llms import X` instead of `from langchain import X`?
1 year ago
Harrison Chase 19c2797bed
add anthropic example (#1041)
Co-authored-by: Ivan Vendrov <ivendrov@gmail.com>
Co-authored-by: Sasmitha Manathunga <70096033+mmz-001@users.noreply.github.com>
1 year ago
Jonathan Pedoeem 05ad399abe
Update PromptLayerOpenAI LLM to include support for ASYNC API (#1066)
This PR updates `PromptLayerOpenAI` to now support requests using the
[Async
API](https://langchain.readthedocs.io/en/latest/modules/llms/async_llm.html)
It also updates the documentation on Async API to let users know that
PromptLayerOpenAI also supports this.

`PromptLayerOpenAI` now redefines `_agenerate` a similar was to how it
redefines `_generate`
1 year ago
Harrison Chase 52753066ef
Harrison/handle stop tokens ai21 (#1077)
Co-authored-by: Andrew Huang <jhuang16888@gmail.com>
1 year ago
Ankush Gola caa8e4742e
Enable streaming for OpenAI LLM (#986)
* Support a callback `on_llm_new_token` that users can implement when
`OpenAI.streaming` is set to `True`
1 year ago
Harrison Chase 88bebb4caa
Harrison/llm integrations (#1039)
Co-authored-by: jped <jonathanped@gmail.com>
Co-authored-by: Justin Torre <justintorre75@gmail.com>
Co-authored-by: Ivan Vendrov <ivan@anthropic.com>
1 year ago
Enrico Shippole f30dcc6359
Add GooseAI, CerebriumAI, Petals, ForefrontAI (#981)
Add GooseAI, CerebriumAI, Petals, ForefrontAI
1 year ago
Oliver Klingefjord 20889205e8
Added retry for openai.error.ServiceUnavailableError (#1022)
Imho retries should be performed for ServiceUnavailableError (which
tends to happen to me quite often).
1 year ago
Harrison Chase 10e7297306
Harrison/fake llm (#990)
Co-authored-by: Stefan Keselj <skeselj@princeton.edu>
Co-authored-by: Harrison Chase <harrisonchase@Harrisons-MBP.attlocal.net>
1 year ago
Ankush Gola bc7e56e8df
Add asyncio support for LLM (OpenAI), Chain (LLMChain, LLMMathChain), and Agent (#841)
Supporting asyncio in langchain primitives allows for users to run them
concurrently and creates more seamless integration with
asyncio-supported frameworks (FastAPI, etc.)

Summary of changes:

**LLM**
* Add `agenerate` and `_agenerate`
* Implement in OpenAI by leveraging `client.Completions.acreate`

**Chain**
* Add `arun`, `acall`, `_acall`
* Implement them in `LLMChain` and `LLMMathChain` for now

**Agent**
* Refactor and leverage async chain and llm methods
* Add ability for `Tools` to contain async coroutine
* Implement async SerpaPI `arun`

Create demo notebook.

Open questions:
* Should all the async stuff go in separate classes? I've seen both
patterns (keeping the same class and having async and sync methods vs.
having class separation)
1 year ago
Harrison Chase bc53c928fc
Harrison/athropic (#921)
Co-authored-by: Mike Lambert <mlambert@gmail.com>
Co-authored-by: mrbean <sam@you.com>
Co-authored-by: mrbean <43734688+sam-h-bean@users.noreply.github.com>
Co-authored-by: Ivan Vendrov <ivendrov@gmail.com>
1 year ago
Harrison Chase ba5a2f06b9
Harrison/inference endpoint (#861)
Co-authored-by: Eno Reyes <enoreyes@gmail.com>
1 year ago
Bagatur 7658263bfb
Check type of LLM.generate `prompts` arg (#886)
Was passing prompt in directly as string and getting nonsense outputs.
Had to inspect source code to realize that first arg should be a list.
Could be nice if there was an explicit error or warning, seems like this
could be a common mistake.
1 year ago
Harrison Chase 777aaff841
fix routing to tiktoken encoder (#866) 1 year ago
Ankush Gola 933441cc52
Add retry to OpenAI llm (#849)
add ability to retry when certain exceptions are raised by
`openai.Completions.create`

Test plan: ran all OpenAI integration tests.
1 year ago
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
1 year ago
Harrison Chase 5f73d06502
Harrison/fix caching bug (#788)
Co-authored-by: thepok <richterthepok@yahoo.de>
1 year ago
Harrison Chase 966611bbfa
add model kwargs to handle stop token from cohere (#773) 1 year ago
Harrison Chase 5bb2952860
Harrison/hf pipeline (#780)
Co-authored-by: Parth Chadha <parth29@gmail.com>
1 year ago
Bill Kish 309d86e339
increase text-davinci-003 contextsize to 4097 (#748)
text-davinci-003 supports a context size of 4097 tokens so return 4097
instead of 4000 in modelname_to_contextsize() for text-davinci-003

Co-authored-by: Bill Kish <bill@cogniac.co>
1 year ago
Ankush Gola 57609845df
add tracing support to langchain (#741)
* add implementations of `BaseCallbackHandler` to support tracing:
`SharedTracer` which is thread-safe and `Tracer` which is not and is
meant to be used locally.
* Tracers persist runs to locally running `langchain-server`

Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
1 year ago
Harrison Chase 9194a8be89
add stop to stream (#729) 1 year ago
Harrison Chase 0ffeabd14f
Harrison/serialize llm chain (#671) 1 year ago
xloem 36b6b3cdf6
HuggingFacePipeline: Forward model_kwargs. (#696)
Since the tokenizer and model are constructed manually, model_kwargs
needs to
be passed to their constructors. Additionally, the pipeline has a
specific
named parameter to pass these with, which can provide forward
compatibility if
they are used for something other than tokenizer or model construction.
1 year ago
Harrison Chase cbc146720b
verbose flag (#683) 1 year ago
Harrison Chase 4d4cff0530
Harrison/cohere experimental (#638)
Co-authored-by: inyourhead <44607279+xettrisomeman@users.noreply.github.com>
1 year ago
Harrison Chase 823a44ef80
bump to 0058 (#556) 1 year ago
Benjamin 42d5d988fa
add openai logit bias (#553)
Add
[`logit_bias`](https://beta.openai.com/docs/api-reference/completions/create#completions/create-logit_bias)
params to OpenAI

See [here](https://beta.openai.com/tokenizer) for the tokenizer.

NB: I see that others (like Cohere) have the same parameter, but since I
don't have an access to it, I don't want to make a mistake.

---

Just to make sure the default "{}" works for openai:
```
from langchain.llms import OpenAI

OPENAI_API_KEY="XXX"

llm = OpenAI(openai_api_key=OPENAI_API_KEY)
llm.generate('Write "test":')

llm = OpenAI(openai_api_key=OPENAI_API_KEY, logit_bias={'9288': -100, '1332': -100, '14402': -100, '6208': -100})
llm.generate('Write "test":')
```
1 year ago
Harrison Chase 9833fcfe32
fix caching (#555) 1 year ago
Diwank Singh Tomer ba0cbb4a41
Add finish reason to Generation for usage downstream (#526)
Add `finish_reason` to `Generation` as well as extend
`BaseOpenAI._generate` to include it in the output. This can be useful
for usage in downstream tasks when we need to filter for only
generations that finished because of `"stop"` for example. Maybe we
should add this to `LLMChain` as well?

For more details, see
https://beta.openai.com/docs/guides/completion/best-practices

Signed-off-by: Diwank Singh Tomer <diwank.singh@gmail.com>
1 year ago
Harrison Chase 5aefc2b7ce
add handling on error (#541) 1 year ago
Harrison Chase 1631981f84
Harrison/fix and test caching (#538) 1 year ago
Yongtae723 f48ab642be
replace forbid into ignore (#539)
this is the second PR of #519.
in #519 I suggested deleting Extra.forbid.
I was very confused but I replaced Extra.forbid to Extra.ignore, which
is the default of pydantic.


Since the
[BaseLLM](4b7b8229de/langchain/llms/base.py (L20))
from which it is inherited is set in Extra.forbid, I wanted to avoid
having the Extra.forbid settings inherited by simply deleting it.
1 year ago
Yongtae723 4b7b8229de
add logger (#529)
As talking #519, I made 2 PRs.

this is the first PR for adding a logger.

I am concerned about the following two points and would appreciate your
opinion.

1. Since the logger is not formatted, the statement itself is output
like a print statement, and I thought it was difficult to understand
that it was a warning, so I put WARNING! at the beginning of the warning
statement. After the logger formatting is done properly, the word
WARNING can be repeated.
2. Statement `Please confirm that {field_name} is what you intended.`
can be replaced like `If {field_name} is intended parameters, enter it
to model_kwargs`
thank you!

Yongtae
1 year ago
Harrison Chase 9e04c34e20
Add BaseCallbackHandler and CallbackManager (#478)
Co-authored-by: Ankush Gola <9536492+agola11@users.noreply.github.com>
1 year ago
Keiji Kanazawa c5f0af9398
Minor docstring update (#507)
Update `model=` to `model_name=`.

No need to credit me for this 😄
1 year ago
Harrison Chase 3e41ab7bff
check keys before using (#475) 1 year ago
mrbean 136f759492
Mrbean/support timeout (#398)
Add support for passing in a request timeout to the API
1 year ago
Keiji Kanazawa 543db9c2df
Add Azure OpenAI LLM (#395)
Hi!  This PR adds support for the Azure OpenAI service to LangChain.

I've tried to follow the contributing guidelines.

Co-authored-by: Keiji Kanazawa <{ID}+{username}@users.noreply.github.com>
1 year ago