Skip to content

Commit 475a997

Browse files
committed
changed ragas_annotator to ragas_experimental
1 parent 402d4c9 commit 475a997

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+823
-2174
lines changed

nbs/backends/factory.ipynb

Lines changed: 6 additions & 230 deletions
Original file line numberDiff line numberDiff line change
@@ -18,242 +18,14 @@
1818
"# | default_exp backends.factory"
1919
]
2020
},
21-
{
22-
"cell_type": "code",
23-
"execution_count": null,
24-
"metadata": {},
25-
"outputs": [],
26-
"source": [
27-
"# | export\n",
28-
"import typing as t\n",
29-
"import os\n",
30-
"\n",
31-
"from notion_client import Client as NotionClient\n",
32-
"from ragas_annotator.backends.mock_notion import MockNotionClient\n",
33-
"from ragas_annotator.backends.notion_backend import NotionBackend"
34-
]
35-
},
36-
{
37-
"cell_type": "code",
38-
"execution_count": null,
39-
"metadata": {},
40-
"outputs": [],
41-
"source": [
42-
"# | export\n",
43-
"class NotionClientFactory:\n",
44-
" \"\"\"Factory for creating Notion client instances.\"\"\"\n",
45-
"\n",
46-
" @staticmethod\n",
47-
" def create(\n",
48-
" use_mock: bool = False,\n",
49-
" api_key: t.Optional[str] = None,\n",
50-
" initialize_project: bool = False,\n",
51-
" root_page_id: t.Optional[str] = None,\n",
52-
" ) -> t.Union[NotionClient, MockNotionClient]:\n",
53-
" \"\"\"Create a Notion client.\n",
54-
"\n",
55-
" Args:\n",
56-
" use_mock: If True, create a mock client\n",
57-
" api_key: Notion API key (only used for real client)\n",
58-
" initialize_project: If True and using mock, initialize project structure\n",
59-
" root_page_id: Required if initialize_project is True\n",
60-
"\n",
61-
" Returns:\n",
62-
" Union[NotionClient, MockNotionClient]: A real or mock client\n",
63-
" \"\"\"\n",
64-
" if use_mock:\n",
65-
" client = MockNotionClient()\n",
66-
"\n",
67-
" # Optionally initialize project structure\n",
68-
" if initialize_project and root_page_id:\n",
69-
" # Create root page if it doesn't exist in the mock client\n",
70-
" if root_page_id not in client._pages:\n",
71-
" # Create root page\n",
72-
" root_page = {\n",
73-
" \"id\": root_page_id,\n",
74-
" \"object\": \"page\",\n",
75-
" \"created_time\": client._get_timestamp(),\n",
76-
" \"last_edited_time\": client._get_timestamp(),\n",
77-
" \"archived\": False,\n",
78-
" \"properties\": {\n",
79-
" \"title\": {\n",
80-
" \"type\": \"title\",\n",
81-
" \"title\": [\n",
82-
" {\n",
83-
" \"plain_text\": \"Root Page\",\n",
84-
" \"type\": \"text\",\n",
85-
" \"text\": {\"content\": \"Root Page\"},\n",
86-
" }\n",
87-
" ],\n",
88-
" }\n",
89-
" },\n",
90-
" }\n",
91-
" client.add_page(root_page)\n",
92-
"\n",
93-
" # Create required sub-pages\n",
94-
" for page_name in [\"Datasets\", \"Experiments\", \"Comparisons\"]:\n",
95-
" # Create page ID\n",
96-
" page_id = client._create_id()\n",
97-
"\n",
98-
" # Create page\n",
99-
" page = {\n",
100-
" \"id\": page_id,\n",
101-
" \"object\": \"page\",\n",
102-
" \"created_time\": client._get_timestamp(),\n",
103-
" \"last_edited_time\": client._get_timestamp(),\n",
104-
" \"archived\": False,\n",
105-
" \"properties\": {\n",
106-
" \"title\": {\n",
107-
" \"type\": \"title\",\n",
108-
" \"title\": [\n",
109-
" {\n",
110-
" \"plain_text\": page_name,\n",
111-
" \"type\": \"text\",\n",
112-
" \"text\": {\"content\": page_name},\n",
113-
" }\n",
114-
" ],\n",
115-
" }\n",
116-
" },\n",
117-
" \"parent\": {\"type\": \"page_id\", \"page_id\": root_page_id},\n",
118-
" }\n",
119-
" client.add_page(page)\n",
120-
"\n",
121-
" # Add child block to root\n",
122-
" child_block = {\n",
123-
" \"id\": client._create_id(),\n",
124-
" \"object\": \"block\",\n",
125-
" \"type\": \"child_page\",\n",
126-
" \"created_time\": client._get_timestamp(),\n",
127-
" \"last_edited_time\": client._get_timestamp(),\n",
128-
" \"child_page\": {\"title\": page_name},\n",
129-
" }\n",
130-
"\n",
131-
" client.add_children(root_page_id, [child_block])\n",
132-
"\n",
133-
" return client\n",
134-
" else:\n",
135-
" # For real client, use provided API key or environment variable\n",
136-
" if api_key is None:\n",
137-
" api_key = os.getenv(\"NOTION_API_KEY\")\n",
138-
"\n",
139-
" if api_key is None:\n",
140-
" raise ValueError(\n",
141-
" \"api_key must be provided or set as NOTION_API_KEY environment variable\"\n",
142-
" )\n",
143-
"\n",
144-
" return NotionClient(auth=api_key)"
145-
]
146-
},
147-
{
148-
"cell_type": "code",
149-
"execution_count": null,
150-
"metadata": {},
151-
"outputs": [
152-
{
153-
"data": {
154-
"text/plain": [
155-
"MockNotionClient(num_pages=0, num_databases=0, num_blocks=0)"
156-
]
157-
},
158-
"execution_count": null,
159-
"metadata": {},
160-
"output_type": "execute_result"
161-
}
162-
],
163-
"source": [
164-
"# create the mock notion client\n",
165-
"mock_notion_client = NotionClientFactory.create(use_mock=True)\n",
166-
"mock_notion_client"
167-
]
168-
},
169-
{
170-
"cell_type": "markdown",
171-
"metadata": {},
172-
"source": [
173-
"the `initialize_project` adds the project pages too for you."
174-
]
175-
},
176-
{
177-
"cell_type": "code",
178-
"execution_count": null,
179-
"metadata": {},
180-
"outputs": [
181-
{
182-
"data": {
183-
"text/plain": [
184-
"MockNotionClient(num_pages=4, num_databases=0, num_blocks=0)"
185-
]
186-
},
187-
"execution_count": null,
188-
"metadata": {},
189-
"output_type": "execute_result"
190-
}
191-
],
192-
"source": [
193-
"mock_notion_client = NotionClientFactory.create(\n",
194-
" use_mock=True, initialize_project=True, root_page_id=\"your_root_page_id\"\n",
195-
")\n",
196-
"mock_notion_client"
197-
]
198-
},
199-
{
200-
"cell_type": "code",
201-
"execution_count": null,
202-
"metadata": {},
203-
"outputs": [],
204-
"source": [
205-
"# | export\n",
206-
"class NotionBackendFactory:\n",
207-
" \"\"\"Factory for creating NotionBackend instances.\"\"\"\n",
208-
"\n",
209-
" @staticmethod\n",
210-
" def create(\n",
211-
" root_page_id: str,\n",
212-
" use_mock: bool = False,\n",
213-
" api_key: t.Optional[str] = None,\n",
214-
" initialize_project: bool = False,\n",
215-
" notion_client: t.Optional[t.Union[NotionClient, MockNotionClient]] = None,\n",
216-
" ) -> NotionBackend:\n",
217-
" \"\"\"Create a NotionBackend instance.\n",
218-
"\n",
219-
" Args:\n",
220-
" root_page_id: The ID of the root page\n",
221-
" use_mock: If True, create a backend with a mock client\n",
222-
" api_key: Notion API key (only used for real client)\n",
223-
" initialize_project: If True and using mock, initialize project structure\n",
224-
" notion_client: Optional pre-configured Notion client\n",
225-
"\n",
226-
" Returns:\n",
227-
" NotionBackend: A backend instance with either real or mock client\n",
228-
" \"\"\"\n",
229-
" # Use provided client or create one\n",
230-
" if notion_client is None:\n",
231-
" notion_client = NotionClientFactory.create(\n",
232-
" use_mock=use_mock,\n",
233-
" api_key=api_key,\n",
234-
" initialize_project=initialize_project,\n",
235-
" root_page_id=root_page_id,\n",
236-
" )\n",
237-
"\n",
238-
" # Create and return the backend\n",
239-
" return NotionBackend(root_page_id=root_page_id, notion_client=notion_client)"
240-
]
241-
},
242-
{
243-
"cell_type": "markdown",
244-
"metadata": {},
245-
"source": [
246-
"## Ragas API Client Factory"
247-
]
248-
},
24921
{
25022
"cell_type": "code",
25123
"execution_count": null,
25224
"metadata": {},
25325
"outputs": [],
25426
"source": [
25527
"#| export\n",
256-
"from ragas_annotator.backends.ragas_api_client import RagasApiClient"
28+
"from ragas_experimental.backends.ragas_api_client import RagasApiClient"
25729
]
25830
},
25931
{
@@ -298,9 +70,13 @@
29870
],
29971
"metadata": {
30072
"kernelspec": {
301-
"display_name": "python3",
73+
"display_name": ".venv",
30274
"language": "python",
30375
"name": "python3"
76+
},
77+
"language_info": {
78+
"name": "python",
79+
"version": "3.12.8"
30480
}
30581
},
30682
"nbformat": 4,

0 commit comments

Comments
 (0)