mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-06 13:33:37 +00:00
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>
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Eden AI is an AI consulting company that was founded to use its resources to empower people and create impactful products that use AI to improve the quality of life for individuals, businesses and societies at large."
|
||||
"Eden AI is revolutionizing the AI landscape by uniting the best AI providers, empowering users to unlock limitless possibilities and tap into the true potential of artificial intelligence. With an all-in-one comprehensive and hassle-free platform, it allows users to deploy AI features to production lightning fast, enabling effortless access to the full breadth of AI capabilities via a single API. (website: https://edenai.co/)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -56,7 +56,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -65,11 +65,11 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"llm = EdenAI(edenai_api_key=\"...\",provider=\"openai\", params={\"temperature\" : 0.2,\"max_tokens\" : 250})"
|
||||
"llm = EdenAI(edenai_api_key=\"...\",provider=\"openai\", temperature=0.2, max_tokens=250)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -85,7 +85,7 @@
|
||||
"source": [
|
||||
"The EdenAI API brings together various providers, each offering multiple models.\n",
|
||||
"\n",
|
||||
"To access a specific model, you can simply use the \"settings\" when calling.\n",
|
||||
"To access a specific model, you can simply add 'model' during instantiation.\n",
|
||||
"\n",
|
||||
"For instance, let's explore the models provided by OpenAI, such as GPT3.5 "
|
||||
]
|
||||
@@ -99,30 +99,30 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"\" No, a dog cannot drive a car.\\n\\nReasoning: \\n\\n1. A dog does not have the physical capability to operate a car. \\n2. A dog does not have the cognitive ability to understand the rules of the road and the mechanics of driving. \\n3. A dog does not have a driver's license, which is a legal requirement to operate a motor vehicle. \\n\\nTherefore, a dog cannot drive a car.\""
|
||||
"\" No, a dog cannot drive a car.\\n\\nReasoning: \\n1. Driving a car requires a driver's license, which is only issued to humans. \\n2. Dogs do not have the physical capability to operate a car, as they do not have hands to steer or feet to operate the pedals. \\n3. Dogs also do not have the mental capacity to understand the rules of the road and operate a car safely. \\n4. Therefore, a dog cannot drive a car.\""
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from langchain import PromptTemplate, LLMChain\n",
|
||||
"llm=EdenAI(feature=\"text\",provider=\"openai\", params={\"temperature\" : 0.2,\"max_tokens\" : 250})\n",
|
||||
"llm=EdenAI(feature=\"text\",provider=\"openai\",model=\"text-davinci-003\",temperature=0.2, max_tokens=250)\n",
|
||||
"\n",
|
||||
"prompt = \"\"\"\n",
|
||||
"User: Answer the following yes/no question by reasoning step by step. Can a dog drive a car?\n",
|
||||
"Assistant:\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"llm(prompt,settings={'openai' : 'text-davinci-003'})"
|
||||
"llm(prompt)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -165,9 +165,7 @@
|
||||
"text2image = EdenAI(\n",
|
||||
" feature=\"image\" ,\n",
|
||||
" provider= \"openai\",\n",
|
||||
" params={\n",
|
||||
" \"resolution\" : \"512x512\"\n",
|
||||
" }\n",
|
||||
" resolution=\"512x512\"\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
@@ -222,7 +220,7 @@
|
||||
"\n",
|
||||
"llm = EdenAI(\n",
|
||||
" callbacks=[StreamingStdOutCallbackHandler()],\n",
|
||||
" feature=\"text\",provider=\"openai\", params={\"temperature\" : 0.2,\"max_tokens\" : 250}\n",
|
||||
" feature=\"text\",provider=\"openai\", temperature=0.2,max_tokens=250\n",
|
||||
")\n",
|
||||
"prompt = \"\"\"\n",
|
||||
"User: Answer the following yes/no question by reasoning step by step. Can a dog drive a car?\n",
|
||||
@@ -256,10 +254,10 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"llm = EdenAI(\n",
|
||||
"feature=\"text\" ,provider=\"openai\" , params={\"temperature\" : 0.2,\"max_tokens\" : 250}\n",
|
||||
"feature=\"text\", provider=\"openai\", temperature=0.2, max_tokens=250\n",
|
||||
")\n",
|
||||
"text2image = EdenAI(\n",
|
||||
"feature=\"image\" ,provider=\"openai\", params={\"resolution\" : \"512x512\"}\n",
|
||||
"feature=\"image\", provider=\"openai\", resolution=\"512x512\"\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
@@ -314,13 +312,7 @@
|
||||
"text": [
|
||||
"\n",
|
||||
"\n",
|
||||
"\u001b[1m> Entering new SimpleSequentialChain chain...\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[1m> Entering new SimpleSequentialChain chain...\u001b[0m\n",
|
||||
"\u001b[36;1m\u001b[1;3m\n",
|
||||
"\n",
|
||||
"Headwear Haven\u001b[0m\n",
|
||||
@@ -352,7 +344,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -366,9 +358,8 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.11"
|
||||
},
|
||||
"orig_nbformat": 4
|
||||
"version": "3.10.12"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
|
@@ -11,7 +11,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Eden AI is an AI consulting company that was founded to use its resources to empower people and create impactful products that use AI to improve the quality of life for individuals, businesses and societies at large."
|
||||
"Eden AI is revolutionizing the AI landscape by uniting the best AI providers, empowering users to unlock limitless possibilities and tap into the true potential of artificial intelligence. With an all-in-one comprehensive and hassle-free platform, it allows users to deploy AI features to production lightning fast, enabling effortless access to the full breadth of AI capabilities via a single API. (website: https://edenai.co/)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user