Paul Garner
69698be3e6
consistently use getLogger(__name__), no root logger ( #2989 )
...
re
https://github.com/hwchase17/langchain/issues/439#issuecomment-1510442791
I think it's not polite for a library to use the root logger
both of these forms are also used:
```
logger = logging.getLogger(__name__)
logger = logging.getLogger(__file__)
```
I am not sure if there is any reason behind one vs the other? (...I am
guessing maybe just contributed by different people)
it seems to me it'd be better to consistently use
`logging.getLogger(__name__)`
this makes it easier for consumers of the library to set up log
handlers, e.g. for everything with `langchain.` prefix
2023-04-16 12:49:35 -07:00
Ankush Gola
ec59e9d886
Fix ChatAnthropic stop_sequences error ( #2919 ) ( #2920 )
...
Note to self: Always run integration tests, even on "that last minute
change you thought would be safe" :)
---------
Co-authored-by: Mike Lambert <mike.lambert@anthropic.com >
2023-04-14 17:22:01 -07:00
Mike Lambert
392f1b3218
Add Anthropic ChatModel to langchain ( #2293 )
...
* Adds an Anthropic ChatModel
* Factors out common code in our LLMModel and ChatModel
* Supports streaming llm-tokens to the callbacks on a delta basis (until
a future V2 API does that for us)
* Some fixes
2023-04-14 15:09:07 -07:00
rafael
1cc7ea333c
chat_models.openai: Set tenacity timeout to openai's recommendation ( #2768 )
...
[OpenAI's
cookbook](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_handle_rate_limits.ipynb )
suggest a tenacity backoff between 1 and 60 seconds. Currently
langchain's backoff is between 4 and 10 seconds, which causes frequent
timeout errors on my end.
This PR changes the timeout to the suggested values.
2023-04-13 22:08:46 -07:00
vinoyang
8073bc849f
Minor: Remove duplicated word in error message ( #2706 )
...
Removed the duplicated word "it" from the error message.
From:
`Please it install it with xxx`
To:
`Please install it with xxx`.
2023-04-11 13:10:33 -07:00
Joshua Snyder
f435f2267c
Use tiktoken for Python 3.8 ( #2709 )
...
Fixes issue #2677
`tiktoken` is supported for Python 3.8, so there is no need to use the
fallback GPT-2 tokenizer.
2023-04-11 11:02:28 -07:00
Yuchu Luo
40469eef7f
fix temperature parameter not used in chat models ( #2558 )
2023-04-08 08:47:50 -07:00
Shishin Mo
f7f118e021
use openai_organization as argument ( #2566 )
...
Added support for passing the openai_organization as an argument, as it
was only supported by the environment variable but openai_api_key was
supported by both environment variables and arguments.
`ChatOpenAI(temperature=0, model_name="gpt-4", openai_api_key="sk-****",
openai_organization="org-****")`
2023-04-07 22:02:02 -07:00
tmyjoe
c9f93f5f74
fix: token counting for chat openai. ( #2543 )
...
I noticed that the value of get_num_tokens_from_messages in `ChatOpenAI`
is always one less than the response from OpenAI's API. Upon checking
the official documentation, I found that it had been updated, so I made
the necessary corrections.
Then now I got the same value from OpenAI's API.
https://github.com/openai/openai-cookbook/commit/d972e7482ed71d36e12f5b058380a61d516bc6d0#diff-2d4485035b3a3469802dbad11d7b4f834df0ea0e2790f418976b303bc82c1874L474
2023-04-07 07:27:03 -07:00
Harrison Chase
704b0feb38
Harrison/allow org none ( #2527 )
2023-04-06 23:00:42 -07:00
Tiago De Gaspari
c2f21a519f
Add support to set up openai organizations ( #2514 )
...
Add support for defining the organization of OpenAI, similarly to what
is done in the reference code below:
```
import os
import openai
openai.organization = os.getenv("OPENAI_ORGANIZATION")
openai.api_key = os.getenv("OPENAI_API_KEY")
```
2023-04-06 22:23:16 -07:00
leo-gan
fd69cc7e42
Removed duplicate BaseModel dependencies ( #2471 )
...
Removed duplicate BaseModel dependencies in class inheritances.
Also, sorted imports by `isort`.
2023-04-06 12:45:16 -07:00
Shota Terashita
09085c32e3
Add temperature to ChatOpenAI ( #2152 )
...
Just add `temperature` parameter to ChatOpenAI class.
https://python.langchain.com/en/latest/getting_started/getting_started.html#building-a-language-model-application-chat-models
There are descriptions like `chat = ChatOpenAI(temperature=0)` in the
documents, but it is confusing because it is not supported as an
explicit parameter.
2023-03-29 16:04:44 -04:00
Harrison Chase
c58932e8fd
Harrison/better async ( #2112 )
...
Co-authored-by: Ammar Husain <ammo700@gmail.com >
2023-03-28 13:28:04 -07:00
Jonathan Pedoeem
725b668aef
Updating PromptLayer request in PromptLayer Models to be async in agenerate ( #2058 )
...
Currently in agenerate, the PromptLayer request is blocking and should
be make async. In this PR we update all of that in order to work as it
should
2023-03-27 15:24:53 -07:00
Harrison Chase
42d725223e
Harrison/num token calculation ( #2041 )
...
Co-authored-by: Aratako <127325395+Aratako@users.noreply.github.com >
2023-03-27 08:16:32 -07:00
Mario Kostelac
e7d6de6b1c
(ChatOpenAI) Add model_name to LLMResult.llm_output ( #1960 )
...
This makes sure OpenAI and ChatOpenAI have the same llm_output, and
allow tracking usage per model. Same work for OpenAI was done in
https://github.com/hwchase17/langchain/pull/1713 .
2023-03-24 08:51:16 -07:00
Eric Zhu
273e9bf296
Simplify AzureChatOpenAI implementation. ( #1902 )
...
Change AzureChatOpenAI class implementation as Azure just added support
for chat completion API. See:
https://learn.microsoft.com/en-us/azure/cognitive-services/openai/how-to/chatgpt?pivots=programming-language-chat-completions .
This should make the code much simpler.
2023-03-22 19:36:51 -07:00
Harrison Chase
f6d24d5740
fix bug with openai token count ( #1806 )
2023-03-20 07:51:18 -07:00
Daniel Chalef
b6ba989f2f
Add request timeout to ChatOpenAI ( #1798 )
...
Add request_timeout field to ChatOpenAI. Defaults to 60s.
---------
Co-authored-by: Daniel Chalef <daniel.chalef@private.org >
2023-03-19 20:19:42 -07:00
Harrison Chase
ef4945af6b
Harrison/chat token usage ( #1785 )
2023-03-19 10:32:31 -07:00
Harrison Chase
b1b4a4065a
change chat default ( #1782 )
...
Resolves https://github.com/hwchase17/langchain/issues/1532 , resolves
https://github.com/hwchase17/langchain/issues/1652 .
2023-03-19 10:01:59 -07:00
Eric Zhu
34840f3aee
AzureChatOpenAI for Azure Open AI's ChatGPT API ( #1673 )
...
Add support for Azure OpenAI's ChatGPT API, which uses ChatML markups to
format messages instead of objects.
Related issues: #1591 , #1659
2023-03-18 19:54:20 -07:00
Harrison Chase
276940fd9b
Harrison/official method ( #1728 )
...
Co-authored-by: Aratako <127325395+Aratako@users.noreply.github.com >
2023-03-16 23:20:08 -07:00
Jonathan Pedoeem
606605925d
Adding ability to return_pl_id to all PromptLayer Models in LangChain ( #1699 )
...
PromptLayer now has support for [several different tracking
features.](https://magniv.notion.site/Track-4deee1b1f7a34c1680d085f82567dab9 )
In order to use any of these features you need to have a request id
associated with the request.
In this PR we add a boolean argument called `return_pl_id` which will
add `pl_request_id` to the `generation_info` dictionary associated with
a generation.
We also updated the relevant documentation.
2023-03-16 17:05:23 -07:00
Pandazki
ced412e1c1
fix: correct a small mistake in SimpleChatModel. ( #1685 )
2023-03-15 08:00:26 -07:00
Harrison Chase
5903a93f3d
add convinence method to call chat model as an llm ( #1604 )
2023-03-11 15:04:57 -08:00
Harrison Chase
9f78717b3c
Harrison/callbacks ( #1587 )
2023-03-10 12:53:09 -08:00
Harrison Chase
3ee32a01ea
Harrison/prompt layer ( #1547 )
...
Co-authored-by: Jonathan Pedoeem <jonathanped@gmail.com >
Co-authored-by: AbuBakar <abubakarsohail123@gmail.com >
2023-03-08 21:24:27 -08:00
Ankush Gola
27104d4921
fix ChatOpenAI.agenerate ( #1504 )
2023-03-07 15:22:05 -08:00
Harrison Chase
0e21463f07
(rfc) chat models ( #1424 )
...
Co-authored-by: Ankush Gola <ankush.gola@gmail.com >
2023-03-06 08:34:24 -08:00