Skip to content

Commit 7aaf93b

Browse files
committed
moved to api_client
1 parent d49fb64 commit 7aaf93b

File tree

5 files changed

+46
-41
lines changed

5 files changed

+46
-41
lines changed

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@ $ pip install ragas_experimental
2222

2323
## Getting Started
2424

25-
First lets init a
25+
First do signup to [beta.app.ragas.io](https://beta.app.ragas.io/) and
26+
generate the App Token and put it in the as the env variable
27+
`RAGAS_APP_TOKEN`.
28+
29+
``` python
30+
import os
31+
# ideally you load this from a .env file so as to not commit it to the repo
32+
os.environ["RAGAS_APP_TOKEN"] = "api-key"
33+
```
34+
35+
Now lets init a
2636
[`Project`](https://explodinggradients.github.io/ragas_experimental/project/core.html#project)
27-
from notion.
37+
in the App
38+
39+
``` python
40+
from ragas_experimental import Project
41+
42+
project = Project.create("my-project")
43+
project
44+
```

nbs/dataset.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@
279279
}
280280
],
281281
"source": [
282-
"p = Project(project_id=\"3d9b529b-c23f-4e87-8a26-dd1923749aa7\", ragas_app_client=ragas_api_client)\n",
282+
"p = Project(project_id=\"3d9b529b-c23f-4e87-8a26-dd1923749aa7\", ragas_api_client=ragas_api_client)\n",
283283
"test_dataset = p.create_dataset(name=\"TestModel_with_long_text\", model=TestModel)\n",
284284
"test_dataset"
285285
]

nbs/index.ipynb

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
},
6363
{
6464
"cell_type": "code",
65-
"execution_count": 1,
65+
"execution_count": null,
6666
"metadata": {},
6767
"outputs": [],
6868
"source": [
@@ -93,21 +93,9 @@
9393
],
9494
"metadata": {
9595
"kernelspec": {
96-
"display_name": ".venv",
96+
"display_name": "python3",
9797
"language": "python",
9898
"name": "python3"
99-
},
100-
"language_info": {
101-
"codemirror_mode": {
102-
"name": "ipython",
103-
"version": 3
104-
},
105-
"file_extension": ".py",
106-
"mimetype": "text/x-python",
107-
"name": "python",
108-
"nbconvert_exporter": "python",
109-
"pygments_lexer": "ipython3",
110-
"version": "3.12.8"
11199
}
112100
},
113101
"nbformat": 4,

nbs/project/core.ipynb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@
7171
" def __init__(\n",
7272
" self,\n",
7373
" project_id: str,\n",
74-
" ragas_app_client: t.Optional[RagasApiClient] = None,\n",
74+
" ragas_api_client: t.Optional[RagasApiClient] = None,\n",
7575
" ):\n",
7676
" self.project_id = project_id\n",
77-
" if ragas_app_client is None:\n",
77+
" if ragas_api_client is None:\n",
7878
" self._ragas_api_client = RagasApiClientFactory.create()\n",
7979
" else:\n",
80-
" self._ragas_api_client = ragas_app_client\n",
80+
" self._ragas_api_client = ragas_api_client\n",
8181
"\n",
8282
" # create the project\n",
8383
" try:\n",
@@ -94,12 +94,12 @@
9494
" cls,\n",
9595
" name: str,\n",
9696
" description: str = \"\",\n",
97-
" ragas_app_client: t.Optional[RagasApiClient] = None,\n",
97+
" ragas_api_client: t.Optional[RagasApiClient] = None,\n",
9898
" ):\n",
99-
" ragas_app_client = RagasApiClientFactory.create()\n",
100-
" sync_version = async_to_sync(ragas_app_client.create_project)\n",
99+
" ragas_api_client = RagasApiClientFactory.create()\n",
100+
" sync_version = async_to_sync(ragas_api_client.create_project)\n",
101101
" new_project = sync_version(title=name, description=description)\n",
102-
" return cls(new_project[\"id\"], ragas_app_client)\n",
102+
" return cls(new_project[\"id\"], ragas_api_client)\n",
103103
"\n",
104104
" def delete(self):\n",
105105
" sync_version = async_to_sync(self._ragas_api_client.delete_project)\n",
@@ -153,22 +153,22 @@
153153
"source": [
154154
"# | export\n",
155155
"@patch(cls_method=True)\n",
156-
"def get(cls: Project, name: str, ragas_app_client: t.Optional[RagasApiClient] = None) -> Project:\n",
156+
"def get(cls: Project, name: str, ragas_api_client: t.Optional[RagasApiClient] = None) -> Project:\n",
157157
" \"\"\"Get an existing project by name.\"\"\"\n",
158158
" # Search for project with given name\n",
159-
" if ragas_app_client is None:\n",
160-
" ragas_app_client = RagasApiClientFactory.create()\n",
159+
" if ragas_api_client is None:\n",
160+
" ragas_api_client = RagasApiClientFactory.create()\n",
161161
"\n",
162162
" # get the project by name\n",
163-
" sync_version = async_to_sync(ragas_app_client.get_project_by_name)\n",
163+
" sync_version = async_to_sync(ragas_api_client.get_project_by_name)\n",
164164
" project_info = sync_version(\n",
165165
" project_name=name\n",
166166
" )\n",
167167
"\n",
168168
" # Return Project instance\n",
169169
" return Project(\n",
170170
" project_id=project_info[\"id\"],\n",
171-
" ragas_app_client=ragas_app_client,\n",
171+
" ragas_api_client=ragas_api_client,\n",
172172
" )"
173173
]
174174
},

ragas_experimental/project/core.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ class Project:
2525
def __init__(
2626
self,
2727
project_id: str,
28-
ragas_app_client: t.Optional[RagasApiClient] = None,
28+
ragas_api_client: t.Optional[RagasApiClient] = None,
2929
):
3030
self.project_id = project_id
31-
if ragas_app_client is None:
31+
if ragas_api_client is None:
3232
self._ragas_api_client = RagasApiClientFactory.create()
3333
else:
34-
self._ragas_api_client = ragas_app_client
34+
self._ragas_api_client = ragas_api_client
3535

3636
# create the project
3737
try:
@@ -48,12 +48,12 @@ def create(
4848
cls,
4949
name: str,
5050
description: str = "",
51-
ragas_app_client: t.Optional[RagasApiClient] = None,
51+
ragas_api_client: t.Optional[RagasApiClient] = None,
5252
):
53-
ragas_app_client = RagasApiClientFactory.create()
54-
sync_version = async_to_sync(ragas_app_client.create_project)
53+
ragas_api_client = RagasApiClientFactory.create()
54+
sync_version = async_to_sync(ragas_api_client.create_project)
5555
new_project = sync_version(title=name, description=description)
56-
return cls(new_project["id"], ragas_app_client)
56+
return cls(new_project["id"], ragas_api_client)
5757

5858
def delete(self):
5959
sync_version = async_to_sync(self._ragas_api_client.delete_project)
@@ -66,21 +66,21 @@ def __repr__(self):
6666
# %% ../../nbs/project/core.ipynb 8
6767
@patch(cls_method=True)
6868
def get(
69-
cls: Project, name: str, ragas_app_client: t.Optional[RagasApiClient] = None
69+
cls: Project, name: str, ragas_api_client: t.Optional[RagasApiClient] = None
7070
) -> Project:
7171
"""Get an existing project by name."""
7272
# Search for project with given name
73-
if ragas_app_client is None:
74-
ragas_app_client = RagasApiClientFactory.create()
73+
if ragas_api_client is None:
74+
ragas_api_client = RagasApiClientFactory.create()
7575

7676
# get the project by name
77-
sync_version = async_to_sync(ragas_app_client.get_project_by_name)
77+
sync_version = async_to_sync(ragas_api_client.get_project_by_name)
7878
project_info = sync_version(project_name=name)
7979

8080
# Return Project instance
8181
return Project(
8282
project_id=project_info["id"],
83-
ragas_app_client=ragas_app_client,
83+
ragas_api_client=ragas_api_client,
8484
)
8585

8686
# %% ../../nbs/project/core.ipynb 12

0 commit comments

Comments
 (0)