ragaai-catalyst 1.0.7b4__tar.gz → 1.0.8b1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. {ragaai_catalyst-1.0.7b4/ragaai_catalyst.egg-info → ragaai_catalyst-1.0.8b1}/PKG-INFO +59 -21
  2. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/README.md +57 -19
  3. ragaai_catalyst-1.0.8b1/docs/dataset_management.md +100 -0
  4. ragaai_catalyst-1.0.8b1/docs/prompt_management.md +184 -0
  5. ragaai_catalyst-1.0.8b1/examples/prompt_management_litellm.ipynb +150 -0
  6. ragaai_catalyst-1.0.8b1/examples/prompt_management_openai.ipynb +151 -0
  7. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/pyproject.toml +4 -1
  8. ragaai_catalyst-1.0.8b1/ragaai_catalyst/dataset.py +227 -0
  9. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst/experiment.py +103 -6
  10. ragaai_catalyst-1.0.8b1/ragaai_catalyst/prompt_manager.py +382 -0
  11. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst/ragaai_catalyst.py +42 -46
  12. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst/tracers/exporters/raga_exporter.py +25 -1
  13. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst/tracers/tracer.py +28 -1
  14. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1/ragaai_catalyst.egg-info}/PKG-INFO +59 -21
  15. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst.egg-info/SOURCES.txt +5 -0
  16. ragaai_catalyst-1.0.7b4/ragaai_catalyst/dataset.py +0 -109
  17. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/.gitignore +0 -0
  18. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/__init__.py +0 -0
  19. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst/__init__.py +0 -0
  20. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst/_version.py +0 -0
  21. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst/tracers/__init__.py +0 -0
  22. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst/tracers/exporters/__init__.py +0 -0
  23. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst/tracers/exporters/file_span_exporter.py +0 -0
  24. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst/tracers/instrumentators/__init__.py +0 -0
  25. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst/tracers/instrumentators/langchain.py +0 -0
  26. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst/tracers/instrumentators/llamaindex.py +0 -0
  27. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst/tracers/instrumentators/openai.py +0 -0
  28. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst/tracers/utils/__init__.py +0 -0
  29. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst/tracers/utils/utils.py +0 -0
  30. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst/utils.py +0 -0
  31. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst.egg-info/dependency_links.txt +0 -0
  32. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst.egg-info/requires.txt +0 -0
  33. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/ragaai_catalyst.egg-info/top_level.txt +0 -0
  34. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/requirements.txt +0 -0
  35. {ragaai_catalyst-1.0.7b4 → ragaai_catalyst-1.0.8b1}/setup.cfg +0 -0
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ragaai_catalyst
3
- Version: 1.0.7b4
3
+ Version: 1.0.8b1
4
4
  Summary: RAGA AI CATALYST
5
- Author-email: Kiran Scaria <kiran.scaria@raga.ai>, Kedar Gaikwad <kedar.gaikwad@raga.ai>, Dushyant Mahajan <dushyant.mahajan@raga.ai>
5
+ Author-email: Kiran Scaria <kiran.scaria@raga.ai>, Kedar Gaikwad <kedar.gaikwad@raga.ai>, Dushyant Mahajan <dushyant.mahajan@raga.ai>, Siddhartha Kosti <siddhartha.kosti@raga.ai>, Ritika Goel <ritika.goel@raga.ai>, Vijay Chaurasia <vijay.chaurasia@raga.ai>
6
6
  Requires-Python: >=3.9
7
7
  Description-Content-Type: text/markdown
8
8
  Requires-Dist: aiohttp>=3.10.2
@@ -44,6 +44,7 @@ RagaAI Catalyst is a powerful tool for managing and optimizing LLM projects. It
44
44
  - [Trace Management](#trace-management)
45
45
  - [Experiment Management](#experiment-management)
46
46
  - [Dataset Management](#dataset-management)
47
+ - [Prompt Management](#prompt-management)
47
48
 
48
49
  ## Installation
49
50
 
@@ -63,9 +64,11 @@ from ragaai_catalyst import RagaAICatalyst
63
64
  catalyst = RagaAICatalyst(
64
65
  access_key="YOUR_ACCESS_KEY",
65
66
  secret_key="YOUR_SECRET_KEY",
66
- api_keys={"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY"}
67
+ base_url="BASE_URL"
67
68
  )
68
69
  ```
70
+ **Note**: Authetication to RagaAICatalyst is necessary to perform any operations below
71
+
69
72
 
70
73
  ## Usage
71
74
 
@@ -102,12 +105,12 @@ tracer = Tracer(
102
105
  "vector_store": "faiss",
103
106
  "embed_model": "text-embedding-ada-002",
104
107
  }
105
- ).start_trace()
108
+ ).start()
106
109
 
107
110
  # Your code here
108
111
 
109
112
  # Stop the trace recording
110
- tracer.stop_trace()
113
+ tracer.stop()
111
114
 
112
115
  # Alternatively, use a context manager
113
116
  with tracer.trace():
@@ -153,34 +156,69 @@ print("Experiment Status:", status)
153
156
  results = experiment_manager.get_results()
154
157
  print("Experiment Results:", results)
155
158
  ```
156
- ### Dataset Management
157
159
 
158
- Create and manage trace datasets for your projects.
159
160
 
160
161
 
161
- ```python
162
+ ## Dataset Management
163
+ Manage datasets efficiently for your projects:
164
+
165
+ ```py
162
166
  from ragaai_catalyst import Dataset
163
167
 
164
168
  # Initialize Dataset management for a specific project
165
- dataset_manager = Dataset(project_name="Test-RAG-App-1")
169
+ dataset_manager = Dataset(project_name="project_name")
166
170
 
167
171
  # List existing datasets
168
172
  datasets = dataset_manager.list_datasets()
169
- print("Exisiting Datasets:", datasets)
173
+ print("Existing Datasets:", datasets)
170
174
 
171
- # Create a new dataset with filters
172
- dataset_manager.create_dataset(
175
+ # Create a dataset from trace
176
+ dataset_manager.create_from_trace(
173
177
  dataset_name='Test-dataset-1',
174
178
  filter_list=[
175
- {
176
- "name": "llm_model",
177
- "values": ["gpt-3.5-turbo", "gpt-4"]
178
- },
179
- {
180
- "name": "prompt_length",
181
- "lte": 27,
182
- "gte": 23
183
- }
179
+ {"name": "llm_model", "values": ["gpt-3.5-turbo", "gpt-4"]},
180
+ {"name": "prompt_length", "lte": 27, "gte": 23}
184
181
  ]
185
182
  )
183
+
184
+ # Create a dataset from CSV
185
+ dataset_manager.create_from_csv(
186
+ csv_path='path/to/your.csv',
187
+ dataset_name='MyDataset',
188
+ schema_mapping={'column1': 'schema_element1', 'column2': 'schema_element2'}
189
+ )
186
190
  ```
191
+
192
+ For more detailed information on Dataset Management, including CSV schema handling and advanced usage, please refer to the [Dataset Management documentation](docs/dataset_management.md).
193
+
194
+ ## Prompt Management
195
+
196
+ Manage and use prompts efficiently in your projects:
197
+
198
+ ```py
199
+ from ragaai_catalyst.prompt_manager import PromptManager
200
+
201
+ # Initialize PromptManager
202
+ prompt_manager = PromptManager("your-project-name")
203
+
204
+ # List available prompts
205
+ prompts = prompt_manager.list_prompts()
206
+ print("Available prompts:", prompts)
207
+
208
+ # Get a specific prompt
209
+ prompt_name = "your_prompt_name"
210
+ prompt = prompt_manager.get_prompt(prompt_name)
211
+
212
+ # Compile a prompt with variables
213
+ compiled_prompt = prompt.compile(query="What's the weather?", context="sunny", llm_response="It's sunny today")
214
+ print("Compiled prompt:", compiled_prompt)
215
+
216
+ # Get prompt parameters
217
+ parameters = prompt.get_parameters()
218
+ print("Prompt parameters:", parameters)
219
+ ```
220
+
221
+ For more detailed information on Prompt Management, please refer to the [Prompt Management documentation](docs/prompt_management.md).
222
+
223
+
224
+
@@ -13,6 +13,7 @@ RagaAI Catalyst is a powerful tool for managing and optimizing LLM projects. It
13
13
  - [Trace Management](#trace-management)
14
14
  - [Experiment Management](#experiment-management)
15
15
  - [Dataset Management](#dataset-management)
16
+ - [Prompt Management](#prompt-management)
16
17
 
17
18
  ## Installation
18
19
 
@@ -32,9 +33,11 @@ from ragaai_catalyst import RagaAICatalyst
32
33
  catalyst = RagaAICatalyst(
33
34
  access_key="YOUR_ACCESS_KEY",
34
35
  secret_key="YOUR_SECRET_KEY",
35
- api_keys={"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY"}
36
+ base_url="BASE_URL"
36
37
  )
37
38
  ```
39
+ **Note**: Authetication to RagaAICatalyst is necessary to perform any operations below
40
+
38
41
 
39
42
  ## Usage
40
43
 
@@ -71,12 +74,12 @@ tracer = Tracer(
71
74
  "vector_store": "faiss",
72
75
  "embed_model": "text-embedding-ada-002",
73
76
  }
74
- ).start_trace()
77
+ ).start()
75
78
 
76
79
  # Your code here
77
80
 
78
81
  # Stop the trace recording
79
- tracer.stop_trace()
82
+ tracer.stop()
80
83
 
81
84
  # Alternatively, use a context manager
82
85
  with tracer.trace():
@@ -122,34 +125,69 @@ print("Experiment Status:", status)
122
125
  results = experiment_manager.get_results()
123
126
  print("Experiment Results:", results)
124
127
  ```
125
- ### Dataset Management
126
128
 
127
- Create and manage trace datasets for your projects.
128
129
 
129
130
 
130
- ```python
131
+ ## Dataset Management
132
+ Manage datasets efficiently for your projects:
133
+
134
+ ```py
131
135
  from ragaai_catalyst import Dataset
132
136
 
133
137
  # Initialize Dataset management for a specific project
134
- dataset_manager = Dataset(project_name="Test-RAG-App-1")
138
+ dataset_manager = Dataset(project_name="project_name")
135
139
 
136
140
  # List existing datasets
137
141
  datasets = dataset_manager.list_datasets()
138
- print("Exisiting Datasets:", datasets)
142
+ print("Existing Datasets:", datasets)
139
143
 
140
- # Create a new dataset with filters
141
- dataset_manager.create_dataset(
144
+ # Create a dataset from trace
145
+ dataset_manager.create_from_trace(
142
146
  dataset_name='Test-dataset-1',
143
147
  filter_list=[
144
- {
145
- "name": "llm_model",
146
- "values": ["gpt-3.5-turbo", "gpt-4"]
147
- },
148
- {
149
- "name": "prompt_length",
150
- "lte": 27,
151
- "gte": 23
152
- }
148
+ {"name": "llm_model", "values": ["gpt-3.5-turbo", "gpt-4"]},
149
+ {"name": "prompt_length", "lte": 27, "gte": 23}
153
150
  ]
154
151
  )
152
+
153
+ # Create a dataset from CSV
154
+ dataset_manager.create_from_csv(
155
+ csv_path='path/to/your.csv',
156
+ dataset_name='MyDataset',
157
+ schema_mapping={'column1': 'schema_element1', 'column2': 'schema_element2'}
158
+ )
155
159
  ```
160
+
161
+ For more detailed information on Dataset Management, including CSV schema handling and advanced usage, please refer to the [Dataset Management documentation](docs/dataset_management.md).
162
+
163
+ ## Prompt Management
164
+
165
+ Manage and use prompts efficiently in your projects:
166
+
167
+ ```py
168
+ from ragaai_catalyst.prompt_manager import PromptManager
169
+
170
+ # Initialize PromptManager
171
+ prompt_manager = PromptManager("your-project-name")
172
+
173
+ # List available prompts
174
+ prompts = prompt_manager.list_prompts()
175
+ print("Available prompts:", prompts)
176
+
177
+ # Get a specific prompt
178
+ prompt_name = "your_prompt_name"
179
+ prompt = prompt_manager.get_prompt(prompt_name)
180
+
181
+ # Compile a prompt with variables
182
+ compiled_prompt = prompt.compile(query="What's the weather?", context="sunny", llm_response="It's sunny today")
183
+ print("Compiled prompt:", compiled_prompt)
184
+
185
+ # Get prompt parameters
186
+ parameters = prompt.get_parameters()
187
+ print("Prompt parameters:", parameters)
188
+ ```
189
+
190
+ For more detailed information on Prompt Management, please refer to the [Prompt Management documentation](docs/prompt_management.md).
191
+
192
+
193
+
@@ -0,0 +1,100 @@
1
+ ## Dataset Management
2
+
3
+ Create and manage datasets easily for your projects using the `ragaai_catalyst` library. This guide provides steps to list, create, and manage datasets efficiently.
4
+
5
+ #### - Initialize Dataset Management
6
+
7
+ To start managing datasets for a specific project, initialize the `Dataset` class with your project name.
8
+
9
+ ```python
10
+ from ragaai_catalyst import Dataset
11
+
12
+ # Initialize Dataset management for a specific project
13
+ dataset_manager = Dataset(project_name="project_name")
14
+
15
+ # List existing datasets
16
+ datasets = dataset_manager.list_datasets()
17
+ print("Existing Datasets:", datasets)
18
+ ```
19
+
20
+ #### 1. Create a New Dataset from Trace
21
+
22
+ Create a dataset by applying filters to trace data. Below is an example of creating a dataset with specific criteria.
23
+
24
+ ```python
25
+ dataset_manager.create_from_trace(
26
+ dataset_name='Test-dataset-1',
27
+ filter_list=[
28
+ {
29
+ "name": "llm_model",
30
+ "values": ["gpt-3.5-turbo", "gpt-4"]
31
+ },
32
+ {
33
+ "name": "prompt_length",
34
+ "lte": 27,
35
+ "gte": 23
36
+ }
37
+ ]
38
+ )
39
+ ```
40
+
41
+ #### 2. Create a New Dataset from CSV
42
+
43
+ You can create a new dataset by uploading a CSV file and mapping its columns to the required schema elements.
44
+
45
+ ##### a. Retrieve CSV Schema Elements with `get_csv_schema()`
46
+
47
+ This function retrieves the valid schema elements that the CSV column names must map to. It helps ensure that your CSV column names align correctly with the expected schema.
48
+
49
+ ###### Returns
50
+
51
+ - A dictionary containing schema information:
52
+ - `success`: A Boolean indicating whether the schema elements were fetched successfully.
53
+ - `data['schemaElements']`: A list of valid schema column names.
54
+
55
+ ```python
56
+ schemaElements = dataset_manager.get_csv_schema()['data']['schemaElements']
57
+ print('Supported column names: ', schemaElements)
58
+ ```
59
+
60
+ ##### b. Create a Dataset from CSV with `create_from_csv()`
61
+
62
+ Uploads the CSV file to the server, performs schema mapping, and creates a new dataset.
63
+
64
+ ###### Parameters
65
+
66
+ - `csv_path` (str): Path to the CSV file.
67
+ - `dataset_name` (str): The name you want to assign to the new dataset created from the CSV.
68
+ - `schema_mapping` (dict): A dictionary that maps CSV columns to schema elements in the format `{csv_column: schema_element}`.
69
+
70
+ Example usage:
71
+
72
+ ```python
73
+ dataset_manager.create_from_csv(
74
+ csv_path='path/to/your.csv',
75
+ dataset_name='MyDataset',
76
+ schema_mapping={'column1': 'schema_element1', 'column2': 'schema_element2'}
77
+ )
78
+ ```
79
+
80
+ #### Understanding `schema_mapping`
81
+
82
+ The `schema_mapping` parameter is crucial when creating datasets from a CSV file. It ensures that the data in your CSV file correctly maps to the expected schema format required by the system.
83
+
84
+ ##### Explanation of `schema_mapping`
85
+
86
+ - **Keys**: The keys in the `schema_mapping` dictionary represent the column names in your CSV file.
87
+ - **Values**: The values correspond to the expected schema elements that the columns should map to. These schema elements define how the data is stored and interpreted in the dataset.
88
+
89
+ ##### Example of `schema_mapping`
90
+
91
+ Suppose your CSV file has columns `user_id` and `response_time`. If the valid schema elements for these are `user_identifier` and `response_duration`, your `schema_mapping` would look like this:
92
+
93
+ ```python
94
+ schema_mapping = {
95
+ 'user_id': 'user_identifier',
96
+ 'response_time': 'response_duration'
97
+ }
98
+ ```
99
+
100
+ This mapping ensures that when the CSV is uploaded, the data in `user_id` is understood as `user_identifier`, and `response_time` is understood as `response_duration`, aligning the data with the system's expectations.
@@ -0,0 +1,184 @@
1
+ # Prompt Management
2
+
3
+ The Prompt Management feature in RagaAI Catalyst allows you to efficiently manage, retrieve, and use prompts in your projects.
4
+
5
+ ## Table of Contents
6
+ 1. [Ideal Flow](#ideal-flow)
7
+ 2. [Error Cases](#error-cases)
8
+ 3. [FAQs](#faqs)
9
+
10
+ ## Ideal Flow
11
+
12
+ ### 1. Initialize RagaAICatalyst and PromptManager
13
+
14
+ First, set up your RagaAICatalyst instance and create a PromptManager for your project:
15
+
16
+ ```python
17
+ from ragaai_catalyst import RagaAICatalyst
18
+ from ragaai_catalyst.prompt_manager import PromptManager
19
+
20
+ catalyst = RagaAICatalyst(
21
+ access_key="your_access_key",
22
+ secret_key="your_secret_key",
23
+ base_url="https://your-api-base-url.com/api"
24
+ )
25
+ ```
26
+
27
+ Create a PromptManager for your project:
28
+
29
+ ```python
30
+ project_name = "your-project-name"
31
+ prompt_manager = PromptManager(project_name)
32
+ ```
33
+
34
+ ### 2. List Available Prompts
35
+
36
+ ```python
37
+ prompts = prompt_manager.list_prompts()
38
+ print("Available prompts:", prompts)
39
+ ```
40
+
41
+ ### 3. List Prompt Versions
42
+
43
+ ```python
44
+ prompt_name = "your_prompt_name"
45
+ versions = prompt_manager.list_prompt_versions(prompt_name)
46
+ ```
47
+
48
+ ### 4. Get a Prompt Object
49
+
50
+ Retrieve a prompt object by name:
51
+
52
+ ```python
53
+ prompt_name = "your_prompt_name"
54
+ prompt = prompt_manager.get_prompt(prompt_name)
55
+
56
+ ```
57
+
58
+ Retrieve a specific prompt object by name and version:
59
+
60
+ ```python
61
+ prompt_name = "your_prompt_name"
62
+ version = "your_version"
63
+ prompt = prompt_manager.get_prompt(prompt_name, version)
64
+ ```
65
+
66
+ ### 5. Get Prompt Variables
67
+
68
+ ```python
69
+ prompt_variables = prompt.get_variables()
70
+ print("prompt_variables: ",prompt_variables)
71
+ ```
72
+
73
+
74
+ ### 6. Compile Prompt
75
+
76
+ Once you have a prompt, you can compile it with variables:
77
+
78
+ ```python
79
+ compiled_prompt = prompt.compile(query="What's the weather?", context="sunny", llm_response="It's sunny today")
80
+ print("Compiled prompt:", compiled_prompt)
81
+ ```
82
+
83
+ ### 7. Get Parameters
84
+
85
+ ```python
86
+ parameters = prompt.get_parameters()
87
+ print("parameters: ",parameters)
88
+ ```
89
+
90
+
91
+ ## Error Cases
92
+
93
+ ### 1. Project Not Found
94
+
95
+ If the project you are trying to access does not exist, the `PromptManager` will raise a `ValueError`:
96
+
97
+ ```python
98
+ prompt_manager = PromptManager("non_existent_project")
99
+
100
+ # Error: Project not found. Please enter a valid project name
101
+ ```
102
+
103
+ ### 2. Prompt Not Found
104
+
105
+ If the prompt you are trying to access does not exist, the `get_prompt` method will raise a `ValueError`:
106
+
107
+ ```python
108
+ prompt = prompt_manager.get_prompt("non_existent_prompt")
109
+
110
+ # Error: Prompt not found. Please enter a valid Prompt name
111
+ ```
112
+
113
+ ### 3. Prompt Version Not Found
114
+
115
+ If the prompt version you are trying to access does not exist, the `get_prompt` method will raise a `ValueError`:
116
+
117
+ ```python
118
+ prompt = prompt_manager.get_prompt("your_prompt_name", "non_existent_version")
119
+
120
+ # Error: Version not found. Please enter a valid version name
121
+ ```
122
+
123
+ ### 4. Missing Variables in Compile
124
+
125
+ If the variables you are trying to compile the prompt with are not found, the `compile` method will raise a `ValueError`:
126
+
127
+ ```python
128
+ prompt = prompt_manager.get_prompt("your_prompt_name", "your_version")
129
+ prompt.get_variables()
130
+ compiled_prompt = prompt.compile(query="What's the weather?")
131
+
132
+ # Error: Missing variable(s): context, llm_response
133
+ ```
134
+
135
+ ### 5. Extra Variables in Compile
136
+
137
+ If the variables you are trying to compile the prompt with are not found, the `compile` method will raise a `ValueError`:
138
+
139
+ ```python
140
+ prompt = prompt_manager.get_prompt("your_prompt_name", "your_version")
141
+ compiled_prompt = prompt.compile(query="What's the weather?", context="sunny", llm_response="It's sunny today", expected_response="The weather is sunny")
142
+
143
+ # Error: Extra variable(s) provided: expected_response
144
+ ```
145
+
146
+ ### 6. Types of variable not str
147
+
148
+ If the variables you are trying to compile the prompt with are not 'str', the `compile` method will raise a `ValueError`:
149
+
150
+ ```python
151
+ prompt = prompt_manager.get_prompt("your_prompt_name", "your_version")
152
+ compiled_prompt = prompt.compile(query=True, context="sunny", llm_response="It's sunny today")
153
+
154
+ # Error: Value for variable 'query' must be a string, not bool
155
+ ```
156
+
157
+
158
+ ## FAQs
159
+
160
+ ### 1. How do I get the list of prompts in a project?
161
+
162
+ You can get the list of prompts in a project by using the `list_prompts()` method in the `PromptManager`. This method allows you to retrieve the list of prompts in a project.
163
+
164
+ ### 2. How do I get the versions of a prompt?
165
+
166
+ You can get the versions of a prompt by using the `list_prompt_versions(prompt_name)` method in the `PromptManager`. This method allows you to retrieve the versions of a prompt.
167
+
168
+ ### 3. How do I get the default version of a prompt?
169
+
170
+ You can get the default version of a prompt by using the `get_prompt(prompt_name)` method in the `PromptManager`. This method allows you to retrieve the default version of a prompt. Then you can use `compile` method to get the prompt with default variables.
171
+
172
+ ### 4. How do I get the specific versions of a prompt?
173
+
174
+ You can get the versions of a prompt by using the `get_prompt(prompt_name, version)` method in the `PromptManager`. This method allows you to retrieve the versions of a prompt. Then you can use `compile` method to get the prompt with default variables.
175
+
176
+
177
+ ### 5. How do I get the variables of a prompt?
178
+
179
+ You can get the variables of a prompt by using the `get_variables()` method. This method allows you to retrieve the variables of a prompt.
180
+
181
+ ### 6. How do I get my parameters?
182
+
183
+ You can get the parameters of a prompt by using the `get_parameters()` method. This method allows you to retrieve the parameters of a prompt.
184
+
@@ -0,0 +1,150 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# Using RagaAI Catalyst Prompt Management with LiteLLM"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": null,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "import litellm\n",
17
+ "\n",
18
+ "\n",
19
+ "from ragaai_catalyst.prompt_manager import PromptManager\n",
20
+ "from ragaai_catalyst import RagaAICatalyst"
21
+ ]
22
+ },
23
+ {
24
+ "cell_type": "code",
25
+ "execution_count": null,
26
+ "metadata": {},
27
+ "outputs": [],
28
+ "source": [
29
+ "OPENAI_API_KEY = \"YOUR_OPENAI_API_KEY\""
30
+ ]
31
+ },
32
+ {
33
+ "cell_type": "code",
34
+ "execution_count": null,
35
+ "metadata": {},
36
+ "outputs": [],
37
+ "source": [
38
+ "catalyst = RagaAICatalyst(\n",
39
+ " access_key=\"ACCESS_KEY\",\n",
40
+ " secret_key=\"SECRET_KEY\",\n",
41
+ ")"
42
+ ]
43
+ },
44
+ {
45
+ "cell_type": "code",
46
+ "execution_count": null,
47
+ "metadata": {},
48
+ "outputs": [],
49
+ "source": [
50
+ "prompt_manager = PromptManager(\"PROJECT_NAME\")\n",
51
+ "\n",
52
+ "# Get the prompt\n",
53
+ "prompt = prompt_manager.get_prompt(\"hallu\", version='v3')"
54
+ ]
55
+ },
56
+ {
57
+ "cell_type": "code",
58
+ "execution_count": null,
59
+ "metadata": {},
60
+ "outputs": [],
61
+ "source": [
62
+ "# Get prompt variables\n",
63
+ "prompt_variables = prompt.get_variables()\n",
64
+ "print(\"prompt_variables: \",prompt_variables)"
65
+ ]
66
+ },
67
+ {
68
+ "cell_type": "code",
69
+ "execution_count": null,
70
+ "metadata": {},
71
+ "outputs": [],
72
+ "source": [
73
+ "# Get parameters\n",
74
+ "parameters = prompt.get_parameters()\n",
75
+ "print(\"parameters: \",parameters)"
76
+ ]
77
+ },
78
+ {
79
+ "cell_type": "code",
80
+ "execution_count": null,
81
+ "metadata": {},
82
+ "outputs": [],
83
+ "source": [
84
+ "# Compile the prompt\n",
85
+ "compiled_prompt = prompt.compile(\n",
86
+ " query='What is the capital of France?',\n",
87
+ " llm_response=\"The capital of France is Paris.\",\n",
88
+ " context=\"France is a country in Western Europe. Its capital and largest city is Paris.\"\n",
89
+ ")\n",
90
+ "print(compiled_prompt)"
91
+ ]
92
+ },
93
+ {
94
+ "cell_type": "code",
95
+ "execution_count": null,
96
+ "metadata": {},
97
+ "outputs": [],
98
+ "source": [
99
+ "# Function to call LiteLLM API\n",
100
+ "def get_litellm_response(prompt):\n",
101
+ " response = litellm.completion(\n",
102
+ " model=\"gpt-4o-mini\",\n",
103
+ " messages=prompt\n",
104
+ " )\n",
105
+ " return response.choices[0].message.content"
106
+ ]
107
+ },
108
+ {
109
+ "cell_type": "code",
110
+ "execution_count": null,
111
+ "metadata": {},
112
+ "outputs": [],
113
+ "source": [
114
+ "# Get response from LiteLLM\n",
115
+ "litellm_response = get_litellm_response(compiled_prompt)\n",
116
+ "\n",
117
+ "print(\"LiteLLM Response:\")\n",
118
+ "print(litellm_response)"
119
+ ]
120
+ },
121
+ {
122
+ "cell_type": "code",
123
+ "execution_count": null,
124
+ "metadata": {},
125
+ "outputs": [],
126
+ "source": []
127
+ }
128
+ ],
129
+ "metadata": {
130
+ "kernelspec": {
131
+ "display_name": "raga_ai_catalyst",
132
+ "language": "python",
133
+ "name": "python3"
134
+ },
135
+ "language_info": {
136
+ "codemirror_mode": {
137
+ "name": "ipython",
138
+ "version": 3
139
+ },
140
+ "file_extension": ".py",
141
+ "mimetype": "text/x-python",
142
+ "name": "python",
143
+ "nbconvert_exporter": "python",
144
+ "pygments_lexer": "ipython3",
145
+ "version": "3.10.14"
146
+ }
147
+ },
148
+ "nbformat": 4,
149
+ "nbformat_minor": 2
150
+ }