Alex
Alex
LLangfuse
Created by Alex on 9/18/2023 in #get-support
Hi y all I m having trouble logging
This seems to work as expected switching CreateScore for InitialScore, thanks!
4 replies
LLangfuse
Created by Alex on 9/18/2023 in #get-support
Hi y all I m having trouble logging
from langfuse import Langfuse
from langfuse.model import CreateTrace, CreateGeneration, CreateScore


langfuse = Langfuse(
public_key="...",
secret_key="...",
host="http://localhost:3000",
)


trace = langfuse.trace(CreateTrace())
generation = trace.generation(CreateGeneration(
name="testgeneration",
prompt=[{"role": "user", "content": "hello world"}],
completion="hi there",
))

print(f"{generation.id=}")

score = langfuse.score(CreateScore(name='testscore', value=0.5, observationId=generation.id))
from langfuse import Langfuse
from langfuse.model import CreateTrace, CreateGeneration, CreateScore


langfuse = Langfuse(
public_key="...",
secret_key="...",
host="http://localhost:3000",
)


trace = langfuse.trace(CreateTrace())
generation = trace.generation(CreateGeneration(
name="testgeneration",
prompt=[{"role": "user", "content": "hello world"}],
completion="hi there",
))

print(f"{generation.id=}")

score = langfuse.score(CreateScore(name='testscore', value=0.5, observationId=generation.id))
running this I get
generation.id='129ddebb-49a9-404d-8878-6b8467a381b4'
'CreateScore' object has no attribute 'observation_id'
Traceback (most recent call last):
File "/home/alex/repos/zenai/env/lib/python3.10/site-packages/langfuse/client.py", line 108, in score
if body.observation_id is not None:
AttributeError: 'CreateScore' object has no attribute 'observation_id'
1 validation error for ParsingModel[str]
__root__
str type expected (type=type_error.str)
Traceback (most recent call last):
File "/home/alex/repos/zenai/env/lib/python3.10/site-packages/langfuse/client.py", line 101, in task
return self.client.score.create(request=new_body)
File "/home/alex/repos/zenai/env/lib/python3.10/site-packages/langfuse/api/resources/score/client.py", line 55, in create
raise Error(pydantic.parse_obj_as(str, _response.json())) # type: ignore
File "pydantic/tools.py", line 38, in pydantic.tools.parse_obj_as
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for ParsingModel[str]
__root__
str type expected (type=type_error.str)
Task ecc00a13-ecb2-46e5-83e7-5045e03c44e1 failed with exception 1 validation error for ParsingModel[str]
__root__
str type expected (type=type_error.str)
generation.id='129ddebb-49a9-404d-8878-6b8467a381b4'
'CreateScore' object has no attribute 'observation_id'
Traceback (most recent call last):
File "/home/alex/repos/zenai/env/lib/python3.10/site-packages/langfuse/client.py", line 108, in score
if body.observation_id is not None:
AttributeError: 'CreateScore' object has no attribute 'observation_id'
1 validation error for ParsingModel[str]
__root__
str type expected (type=type_error.str)
Traceback (most recent call last):
File "/home/alex/repos/zenai/env/lib/python3.10/site-packages/langfuse/client.py", line 101, in task
return self.client.score.create(request=new_body)
File "/home/alex/repos/zenai/env/lib/python3.10/site-packages/langfuse/api/resources/score/client.py", line 55, in create
raise Error(pydantic.parse_obj_as(str, _response.json())) # type: ignore
File "pydantic/tools.py", line 38, in pydantic.tools.parse_obj_as
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for ParsingModel[str]
__root__
str type expected (type=type_error.str)
Task ecc00a13-ecb2-46e5-83e7-5045e03c44e1 failed with exception 1 validation error for ParsingModel[str]
__root__
str type expected (type=type_error.str)
4 replies
LLangfuse
Created by Max on 9/15/2023 in #get-support
observationId in Python SDK
very cool, thanks!
11 replies
LLangfuse
Created by Max on 9/15/2023 in #get-support
observationId in Python SDK
Or, does CreateGeneration communicate with the server under the hood?
11 replies
LLangfuse
Created by Max on 9/15/2023 in #get-support
observationId in Python SDK
Great, thanks! Just curious now, so the ids are generated directly by the sdk on the client side? No validation needed on the server?
11 replies
LLangfuse
Created by Max on 9/15/2023 in #get-support
observationId in Python SDK
I have langfuse.model.CreateGeneration objects handy
11 replies
LLangfuse
Created by Max on 9/15/2023 in #get-support
observationId in Python SDK
Normal SDK, no langchain
11 replies