Closed benman1 closed 1 year ago
Answer generated by a 🤖
From your description, it appears that you're encountering an "AuthenticationError: Invalid token" error when trying to use the JinaChat service in the LangChain framework. This error typically arises when the API key used for authentication is invalid.
To address this issue, I would suggest verifying the API key you're using. You've set the API key in the environment variable JINACHAT_API_KEY
as shown in your code:
os.environ["JINACHAT_API_KEY"] = "..." # from https://cloud.jina.ai/settings/tokens
Please ensure that the API key you're using is valid and correctly copied from your JinaChat account. You can usually find this in your account settings on the JinaChat website or service.
However, please note that this is just one potential solution based on the information provided. If you've verified the API key and are still encountering the same issue, it's possible that there might be a problem with the JinaChat service itself, or the key might have been revoked or expired.
If you believe this is a bug that could impact other users, feel free to make a pull request with a proposed fix. If the issue persists after trying these steps, I would recommend checking if you're using the latest version of LangChain, as the issue might have been resolved in a more recent update.
This response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
@benman1 did you get an api key from https://chat.jina.ai/api and set JINACHAT_API_KEY
env?
I tried replicating the same, and I confirm that I am also getting a similar error ( even after setting the JINA_API_KEY ). I assume that this model can't be implemented wrong, but for checking purpose - I just passed the API_KEY directly in my code - can that cause an error ? ( In case not, then @benman1 has a proper issue ).
@delgermurun thanks for clarifying,where to get the API keys for the chat. I found https://cloud.jina.ai/settings/tokens mentioned elsewhere, hence the confusion. I confirm it works with API key from the right place.
I've created a mini PR #7540 to clarify this in the Jina chat docstring.
@benman1 thanks a lot.
@dudesparsh just in case you missed it, the environment var key is JINACHAT_API_KEY
, not JINA_API_KEY
.
Hi, @benman1! I'm Dosu, and I'm helping the LangChain team manage our backlog. I wanted to let you know that we are marking this issue as stale.
From what I understand, the issue you reported was related to authentication in the JinaChat module. You encountered an "AuthenticationError: Invalid token" when running the code. However, it seems that the issue has been resolved. Another user named dosu-beta suggested verifying the API key used for authentication, and you confirmed that using the correct API key resolved the issue. In fact, you have even created a pull request to update the Jina chat docstring to clarify this solution.
Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on this issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.
Thank you for your contribution and for helping us improve LangChain!
I am trying to use Jina embedding model and facing authentication issue:
The given Jina auth token is invalid. Please check your Jina auth token. (type=value_error)
The sample python code given on Jina Embedding page is:
import requests
url = 'https://api.jina.ai/v1/embeddings'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer jina_xxxxxxxx-xx'
}
data = {
'input': ["Your text string goes here", "You can send multiple texts"],
'model': 'jina-embeddings-v2-base-en'
}
response = requests.post(url, headers=headers, json=data)
Its using Bearer token there. On the other hand, sample code given on Lang Chain is:
from langchain.embeddings import JinaEmbeddings
jina_auth_token = 'Bearer jina_xxxxxxxx-xx'
# jina_auth_token = 'jina_xxxxxxxx-xx'
embeddings = JinaEmbeddings(
jina_auth_token=jina_auth_token, model_name="ViT-B-32::openai"
)
I used both variations of token there i.e with and without Bearer but its giving me the authentication error.
I am trying to use Jina embedding model and facing authentication issue:
The given Jina auth token is invalid. Please check your Jina auth token. (type=value_error)
The sample python code given on Jina Embedding page is:
import requests url = 'https://api.jina.ai/v1/embeddings' headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer jina_xxxxxxxx-xx' } data = { 'input': ["Your text string goes here", "You can send multiple texts"], 'model': 'jina-embeddings-v2-base-en' } response = requests.post(url, headers=headers, json=data)
Its using Bearer token there. On the other hand, sample code given on Lang Chain is:
from langchain.embeddings import JinaEmbeddings jina_auth_token = 'Bearer jina_xxxxxxxx-xx' # jina_auth_token = 'jina_xxxxxxxx-xx' embeddings = JinaEmbeddings( jina_auth_token=jina_auth_token, model_name="ViT-B-32::openai" )
I used both variations of token there i.e with and without Bearer but its giving me the authentication error.
Hey @hammad26 ,
I am going to fix the implementation to be able to use JinaEmbeddings properly after the new platform release
System Info
langchain-0.0.229 python 3.10
Who can help?
@delgermurun
Information
Related Components
Reproduction
Expected behavior
Expected output: Je t'aime Actual output: