OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Open AI Embeddings

  • Thread starter Thread starter 6080_ Atharva_Kulkarni
  • Start date Start date
6

6080_ Atharva_Kulkarni

Guest
Code:
import openai
from langchain.embeddings.openai import OpenAIEmbeddings

embeddings = OpenAIEmbeddings(model_name="ada")

query_result = embeddings.embed_query("Hello world")
len(query_result)

When compiling the above code it gives the following error:​


Code:
> ValidationError                           Traceback (most recent call
> last) <ipython-input-60-3e1d76e373bd> in <cell line: 4>()
>       2 from langchain.embeddings.openai import OpenAIEmbeddings
>       3 
> ----> 4 embeddings = OpenAIEmbeddings(model_name="ada")
>       5 
>       6 query_result = embeddings.embed_query("Hello world")
> 
> /usr/local/lib/python3.10/dist-packages/pydantic/main.cpython-310-x86_64-linux-gnu.so
> in pydantic.main.BaseModel.__init__()
> 
> ValidationError: 1 validation error for OpenAIEmbeddings model_name  
> extra fields not permitted (type=value_error.extra)

I have tried using this :-

Code:
import os
from openai_embed import OpenAIEmbeddings

os.environ["OPENAI_API_KEY"] = "<OPENAPI_TOKEN>"
api_key = os.getenv("OPENAI_API_KEY")

embeddings = OpenAIEmbeddings(openai_api_key=api_key)

query_result = embeddings.embed_query("Hello world")
print(len(query_result))

But the error is not fixing
<pre><code>import openai
from langchain.embeddings.openai import OpenAIEmbeddings

embeddings = OpenAIEmbeddings(model_name="ada")

query_result = embeddings.embed_query("Hello world")
len(query_result)
</code></pre>
<h2>When compiling the above code it gives the following error:</h2>
<pre><code>> ValidationError Traceback (most recent call
> last) <ipython-input-60-3e1d76e373bd> in <cell line: 4>()
> 2 from langchain.embeddings.openai import OpenAIEmbeddings
> 3
> ----> 4 embeddings = OpenAIEmbeddings(model_name="ada")
> 5
> 6 query_result = embeddings.embed_query("Hello world")
>
> /usr/local/lib/python3.10/dist-packages/pydantic/main.cpython-310-x86_64-linux-gnu.so
> in pydantic.main.BaseModel.__init__()
>
> ValidationError: 1 validation error for OpenAIEmbeddings model_name
> extra fields not permitted (type=value_error.extra)
</code></pre>
<p>I have tried using this :-</p>
<pre><code>import os
from openai_embed import OpenAIEmbeddings

os.environ["OPENAI_API_KEY"] = "<OPENAPI_TOKEN>"
api_key = os.getenv("OPENAI_API_KEY")

embeddings = OpenAIEmbeddings(openai_api_key=api_key)

query_result = embeddings.embed_query("Hello world")
print(len(query_result))
</code></pre>
<p>But the error is not fixing</p>
 

Latest posts

M
Replies
0
Views
1
Muhammad Rafli Aditya. H
M
Top