Open abhirupghosh opened 5 months ago
This is also an issue with langchainjs
.
Setting the Replicate model version was made optional some time ago, but the Langchain wrappers has not been updated to reflect this change. Public Replicate models should now be run without setting version.
Any update on correcting this? A lot of newer models (such as Llama 3) do not explicitly mention the version numbers on Replicate's end. To reiterate, to identify the version number, I queried https://api.replicate.com/v1/models/meta/meta-llama-3-70b-instruct as a GET request, and received the latest_version in the response. Upon feeding this latest_version into the 'version' variable, I still get the same error message.
I am temporarily being forced to use Replicate's API directly, which makes it more difficult to utilize inbuilt output parsers, amongst various other thing.
I have the exact same issue, no idea how to fix it...
same proble, would love to have this fixed
Same problem here as well. Unable to use Replicate models on python as well
Anyone taking care of this? The issue is still here. Updating models with version is a PITA.
the solution is to use langchain community, https://api.python.langchain.com/en/latest/community_api_reference.html https://pypi.org/project/langchain-community/
also facing same issue. simple curl request also not working
has anyone solved this problem?
Has any one know a way to use prompt templates(including variables) with replicate models? There is a way to use langchain with replicate?
The information from the author seems incorrect or outdated. There is a way to know the version on Replicate by clicking on "versions" and on the specific version.
You will get a URL like this in the navbar:
https://replicate.com/lucataco/phi-3-mini-128k-instruct/versions/45ba1bd0a3cf3d5254becd00d937c4ba0c01b13fa1830818f483a76aa844205e
Where the version is 45ba1bd0a3cf3d5254becd00d937c4ba0c01b13fa1830818f483a76aa844205e
.
To use that with langchain_community:
from langchain_community.llms import Replicate
Replicate(
model=lucataco/phi-3-mini-128k-instruct:45ba1bd0a3cf3d5254becd00d937c4ba0c01b13fa1830818f483a76aa844205e,
api_key=llm_api_key,
)
@geido not all models have a version tab, e.g. https://replicate.com/meta/meta-llama-3-70b-instruct
@adibenmati I am not sure what you mean, OP did use langchain community. Can you provide a functioning snippet that uses meta/meta-llama-3-70b-instruct
without specifying the model version?
@cicheck First of all the most important is to use the following import code:
from langchain_community.llms import Replicate
make sure you are using "langchain_community" recommended version is langchain-community > 0.2.2
def load_model(self): replicate_api_token = ConfigManager.get(ConfigKeys.replicate_token) os.environ["REPLICATE_API_TOKEN"] = replicate_api_token
llama_model_name = "meta/meta-llama-3.1-405b-instruct"
llm = Replicate(
model=llama_model_name,
model_kwargs={"temperature": 0.1, "top_p": 1, "max_new_tokens": 100},
api_token=replicate_api_token
)
def query_model(prompt, temperature=0.01, max_tokens=1000, attempts=2):
print(f"Querying model with prompt: {prompt[:50]}...") # Log the first 50 characters of the prompt
input = {
"prompt": prompt,
"temperature": temperature,
"max_tokens": max_tokens
}
responses = []
for attempt in range(attempts):
print(f"Query attempt {attempt + 1}")
response = ""
for event in replicate.stream(
"meta/meta-llama-3.1-405b-instruct",
input=input
):
response += event.data
responses.append(response.strip())
print(f"Response from attempt {attempt + 1}: {response[:50]}...") # Log the first 50 characters of the response
return responses
Yes it's not currently supported in the official langchain library, until then please use the community version. That should work hope it helps and everyone stop spamming my email :)
2) Worked for me, thanks, and enjoy your peace:P
This doesn't work for me. Getting this error, ValidationError: 1 validation error for Replicate model Field required [type=missing, input_value={'model_kwargs': {'model'...ing': False, 'stop': []}, input_type=dict] For further information visit https://errors.pydantic.dev/2.9/v/missing
Any update on correcting this? A lot of newer models (such as Llama 3) do not explicitly mention the version numbers on Replicate's end. To reiterate, to identify the version number, I queried https://api.replicate.com/v1/models/meta/meta-llama-3-70b-instruct as a GET request, and received the latest_version in the response. Upon feeding this latest_version into the 'version' variable, I still get the same error message.
I am temporarily being forced to use Replicate's API directly, which makes it more difficult to utilize inbuilt output parsers, amongst various other thing.
This also works but the version needs to be specified like this
from langchain_community.llms import Replicate
Replicate(
model=lucataco/phi-3-mini-128k-instruct:45ba1bd0a3cf3d5254becd00d937c4ba0c01b13fa1830818f483a76aa844205e,
api_key=llm_api_key,
)
Checked other resources
Example Code
This when compared to directly using Replicate's API within Python:
Error Message and Stack Trace (if applicable)
replicate.exceptions.ReplicateError: ReplicateError Details: title: Invalid version or not permitted status: 422 detail: The specified version does not exist (or perhaps you don't have permission to use it?)
Description
I am trying to use Langchain to use Llama 3 - however, there are no version numbers that are required when I am using Replicate's API directly. There are also no direct ways on the Replicate website to find which specific version number we are using when trying to use replicate.
To identify the version number, I queried
https://api.replicate.com/v1/models/meta/meta-llama-3-70b-instruct
as a GET request, and received thelatest_version
in the response. Upon feeding this latest_version into the 'version' variable, I still get the above error message.Two questions:
System Info
System Information
Package Information
Packages not installed (Not Necessarily a Problem)
The following packages were not found: