Missing Error
yjianpen opened this issue · 2 comments
yjianpen commented
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 commented