2023-08-03 17:24:51 +00:00
|
|
|
"""Test EdenAi API wrapper.
|
|
|
|
|
|
|
|
In order to run this test, you need to have an EdenAI api key.
|
|
|
|
You can get it by registering for free at https://app.edenai.run/user/register.
|
|
|
|
A test key can be found at https://app.edenai.run/admin/account/settings by
|
|
|
|
clicking on the 'sandbox' toggle.
|
|
|
|
(calls will be free, and will return dummy results)
|
|
|
|
|
|
|
|
You'll then need to set EDENAI_API_KEY environment variable to your api key.
|
|
|
|
"""
|
2023-12-11 21:53:30 +00:00
|
|
|
from langchain_community.llms import EdenAI
|
2023-08-03 17:24:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_edenai_call() -> None:
|
|
|
|
"""Test simple call to edenai."""
|
EdenAI LLM update. Add models name option (#8963)
This PR follows the **Eden AI (LLM + embeddings) integration**. #8633
We added an optional parameter to choose different AI models for
providers (like 'text-bison' for provider 'google', 'text-davinci-003'
for provider 'openai', etc.).
Usage:
```python
llm = EdenAI(
feature="text",
provider="google",
params={
"model": "text-bison", # new
"temperature": 0.2,
"max_tokens": 250,
},
)
```
You can also change the provider + model after initialization
```python
llm = EdenAI(
feature="text",
provider="google",
params={
"temperature": 0.2,
"max_tokens": 250,
},
)
prompt = """
hi
"""
llm(prompt, providers='openai', model='text-davinci-003') # change provider & model
```
The jupyter notebook as been updated with an example well.
Ping: @hwchase17, @baskaryan
---------
Co-authored-by: RedhaWassim <rwasssim@gmail.com>
Co-authored-by: sam <melaine.samy@gmail.com>
2023-09-01 19:11:33 +00:00
|
|
|
llm = EdenAI(provider="openai", temperature=0.2, max_tokens=250)
|
2023-08-03 17:24:51 +00:00
|
|
|
output = llm("Say foo:")
|
|
|
|
|
|
|
|
assert llm._llm_type == "edenai"
|
|
|
|
assert llm.feature == "text"
|
|
|
|
assert llm.subfeature == "generation"
|
|
|
|
assert isinstance(output, str)
|
|
|
|
|
|
|
|
|
|
|
|
async def test_edenai_acall() -> None:
|
|
|
|
"""Test simple call to edenai."""
|
EdenAI LLM update. Add models name option (#8963)
This PR follows the **Eden AI (LLM + embeddings) integration**. #8633
We added an optional parameter to choose different AI models for
providers (like 'text-bison' for provider 'google', 'text-davinci-003'
for provider 'openai', etc.).
Usage:
```python
llm = EdenAI(
feature="text",
provider="google",
params={
"model": "text-bison", # new
"temperature": 0.2,
"max_tokens": 250,
},
)
```
You can also change the provider + model after initialization
```python
llm = EdenAI(
feature="text",
provider="google",
params={
"temperature": 0.2,
"max_tokens": 250,
},
)
prompt = """
hi
"""
llm(prompt, providers='openai', model='text-davinci-003') # change provider & model
```
The jupyter notebook as been updated with an example well.
Ping: @hwchase17, @baskaryan
---------
Co-authored-by: RedhaWassim <rwasssim@gmail.com>
Co-authored-by: sam <melaine.samy@gmail.com>
2023-09-01 19:11:33 +00:00
|
|
|
llm = EdenAI(provider="openai", temperature=0.2, max_tokens=250)
|
2023-08-03 17:24:51 +00:00
|
|
|
output = await llm.agenerate(["Say foo:"])
|
|
|
|
assert llm._llm_type == "edenai"
|
|
|
|
assert llm.feature == "text"
|
|
|
|
assert llm.subfeature == "generation"
|
|
|
|
assert isinstance(output, str)
|
EdenAI LLM update. Add models name option (#8963)
This PR follows the **Eden AI (LLM + embeddings) integration**. #8633
We added an optional parameter to choose different AI models for
providers (like 'text-bison' for provider 'google', 'text-davinci-003'
for provider 'openai', etc.).
Usage:
```python
llm = EdenAI(
feature="text",
provider="google",
params={
"model": "text-bison", # new
"temperature": 0.2,
"max_tokens": 250,
},
)
```
You can also change the provider + model after initialization
```python
llm = EdenAI(
feature="text",
provider="google",
params={
"temperature": 0.2,
"max_tokens": 250,
},
)
prompt = """
hi
"""
llm(prompt, providers='openai', model='text-davinci-003') # change provider & model
```
The jupyter notebook as been updated with an example well.
Ping: @hwchase17, @baskaryan
---------
Co-authored-by: RedhaWassim <rwasssim@gmail.com>
Co-authored-by: sam <melaine.samy@gmail.com>
2023-09-01 19:11:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_edenai_call_with_old_params() -> None:
|
|
|
|
"""
|
|
|
|
Test simple call to edenai with using `params`
|
|
|
|
to pass optional parameters to api
|
|
|
|
"""
|
|
|
|
llm = EdenAI(provider="openai", params={"temperature": 0.2, "max_tokens": 250})
|
|
|
|
output = llm("Say foo:")
|
|
|
|
|
|
|
|
assert llm._llm_type == "edenai"
|
|
|
|
assert llm.feature == "text"
|
|
|
|
assert llm.subfeature == "generation"
|
|
|
|
assert isinstance(output, str)
|