FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
langfuse-python/tests/api_wrapper.py at main · code-haven/langfuse-python · GitHub
code-haven
/
langfuse-python
Public
forked from
langfuse/langfuse-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
langfuse-python
/
tests
/
api_wrapper.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (26 loc) · 1.36 KB
Breadcrumbs
langfuse-python
/
tests
/
api_wrapper.py
Copy path
File metadata and controls
32 lines (26 loc) · 1.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import
os
import
requests
class
LangfuseAPI
:
def
__init__
(
self
,
username
=
None
,
password
=
None
,
base_url
=
None
):
username
=
username
if
username
else
os
.
environ
[
"LANGFUSE_PUBLIC_KEY"
]
password
=
password
if
password
else
os
.
environ
[
"LANGFUSE_SECRET_KEY"
]
self
.
auth
=
(
username
,
password
)
self
.
BASE_URL
=
base_url
if
base_url
else
os
.
environ
[
"LANGFUSE_HOST"
]
def
get_observation
(
self
,
observation_id
):
url
=
f"
{
self
.
BASE_URL
}
/api/public/observations/
{
observation_id
}
"
response
=
requests
.
get
(
url
,
auth
=
self
.
auth
)
return
response
.
json
()
def
get_scores
(
self
,
page
=
None
,
limit
=
None
,
user_id
=
None
,
name
=
None
):
params
=
{
"page"
:
page
,
"limit"
:
limit
,
"userId"
:
user_id
,
"name"
:
name
}
url
=
f"
{
self
.
BASE_URL
}
/api/public/scores"
response
=
requests
.
get
(
url
,
params
=
params
,
auth
=
self
.
auth
)
return
response
.
json
()
def
get_traces
(
self
,
page
=
None
,
limit
=
None
,
user_id
=
None
,
name
=
None
):
params
=
{
"page"
:
page
,
"limit"
:
limit
,
"userId"
:
user_id
,
"name"
:
name
}
url
=
f"
{
self
.
BASE_URL
}
/api/public/traces"
response
=
requests
.
get
(
url
,
params
=
params
,
auth
=
self
.
auth
)
return
response
.
json
()
def
get_trace
(
self
,
trace_id
):
url
=
f"
{
self
.
BASE_URL
}
/api/public/traces/
{
trace_id
}
"
response
=
requests
.
get
(
url
,
auth
=
self
.
auth
)
return
response
.
json
()
Back
|
FazBrowse Home
|
New Git URL