Skip to content

Missing Error #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yjianpen opened this issue Aug 30, 2023 · 2 comments
Closed

Missing Error #148

yjianpen opened this issue Aug 30, 2023 · 2 comments

Comments

@yjianpen
Copy link

yjianpen commented Aug 30, 2023

Hello, I am a newbee to replicate-python and I met a missing error without telling me which fields are missing:

Here is error message:

exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //Data:IntelligenceCenter_test
-----------------------------------------------------------------------------
E
======================================================================
ERROR: test_llama2 (__main__.TestNewsNum)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/private/var/tmp/_bazel_javieryu/aaf029806d53299ea7c92c3aeb5caf78/sandbox/darwin-sandbox/39/execroot/__main__/bazel-out/darwin-fastbuild/bin/Data/IntelligenceCenter_test.runfiles/__main__/Data/IntelligenceCenter_test.py", line 31, in test_llama2
    response = agent.Generate("How do you feel about the weather today?")
  File "/private/var/tmp/_bazel_javieryu/aaf029806d53299ea7c92c3aeb5caf78/sandbox/darwin-sandbox/39/execroot/__main__/bazel-out/darwin-fastbuild/bin/Data/IntelligenceCenter_test.runfiles/__main__/Data/IntelligenceCenter.py", line 89, in Generate
    output = replicate.run("replicate/llama-7b:ac808388e2e9d8ed35a5bf2eaa7d83f0ad53f9e3df31a42e4eb0a0c3249b3165",input={"prompt": final_input})
  File "/opt/miniconda3/lib/python3.7/site-packages/replicate/client.py", line 127, in run
    prediction = self.predictions.create(version=version, **kwargs)
  File "/opt/miniconda3/lib/python3.7/site-packages/replicate/prediction.py", line 85, in create
    return self.prepare_model(obj)
  File "/opt/miniconda3/lib/python3.7/site-packages/replicate/collection.py", line 33, in prepare_model
    model = self.model(**attrs)
  File "/opt/miniconda3/lib/python3.7/site-packages/pydantic/main.py", line 165, in __init__
    __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 3 validation errors for Prediction
output
  Field required [type=missing, input_value={'id': 'aqykwezb7wkthhaui...ezb7wkthhauiba4t6sh2e'}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.3/v/missing
started_at
  Field required [type=missing, input_value={'id': 'aqykwezb7wkthhaui...ezb7wkthhauiba4t6sh2e'}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.3/v/missing
completed_at
  Field required [type=missing, input_value={'id': 'aqykwezb7wkthhaui...ezb7wkthhauiba4t6sh2e'}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.3/v/missing

----------------------------------------------------------------------
Ran 1 test in 0.350s

FAILED (errors=1)

Here is my code:

class Llama2Agent(Agent):
    def __init__(self, name:str):
        self.name = name
        os.environ["REPLICATE_API_TOKEN"] = llama2_api_key

    def Generate(self,query:str):
        pre_prompt = "You are a professional stock analyst. You do not respond as 'User' or pretend to be 'User'. You only respond once as a professional stock analyst."
        final_input = pre_prompt + " " + query
        output = replicate.run("replicate/llama-7b:ac808388e2e9d8ed35a5bf2eaa7d83f0ad53f9e3df31a42e4eb0a0c3249b3165",input={"prompt": final_input})
        for item in output:
            # https://replicate.com/a16z-infra/llama-2-13b-chat/versions/9dff94b1bed5af738655d4a7cbcdcde2bd503aa85c94334fe1f42af7f3dd5ee3/api#output-schema
            print(item)
        return outputp[0]`

Here is my unit test:

def test_llama2(self):
        agent = Llama2Agent("Sam")
        response = agent.Generate("How do you feel about the weather today?")
        print("Llama2 response", response)
        self.assertNotEqual(response, "")

Any idea what are missing right here?

@mattt
Copy link
Contributor

mattt commented Sep 5, 2023

Hi @yjianpen. It looks like this is an issue with Pydantic 2 (see #121). I also see that you're using Python 3.7, which isn't supported. Could you please update to Python >= 3.8 and confirm that you're using the latest release of replicate-python?

@mattt
Copy link
Contributor

mattt commented Sep 17, 2023

@yjianpen Please let me know if the suggested fix doesn't work for you, and I'd be happy to reopen. Thanks!

@mattt mattt closed this as not planned Won't fix, can't repro, duplicate, stale Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants