Class: Langsmith::Client
- Inherits:
-
Object
- Object
- Langsmith::Client
- Defined in:
- lib/langsmith/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#api_url ⇒ Object
readonly
Returns the value of attribute api_url.
Instance Method Summary collapse
-
#bulk_delete_runs(run_ids:) ⇒ Hash
Bulk delete runs.
-
#bulk_tag_runs(run_ids:, tag_ids:) ⇒ Hash
Bulk tag runs.
-
#bulk_untag_runs(run_ids:, tag_ids:) ⇒ Hash
Bulk untag runs.
-
#cancel_evaluation(id:) ⇒ Langsmith::Evaluation
Cancel an evaluation.
-
#create_annotation_queue(name:, description: nil, metadata: {}) ⇒ Hash
Create a new annotation queue.
-
#create_api_key(name:, expires_at: nil) ⇒ Hash
Create a new API key.
-
#create_dataset(name:, description: nil) ⇒ Langsmith::Dataset
Create a new dataset.
-
#create_event(name:, data:, metadata: nil) ⇒ Hash
Create an event.
-
#create_examples_batch(dataset_id:, examples:) ⇒ Array<Langsmith::Example>
Create multiple examples in batch.
-
#create_feedback(run_id:, key:, score:, comment: nil) ⇒ Langsmith::Feedback
Create feedback for a run.
-
#create_feedback_config(name:, type:, metadata: {}) ⇒ Hash
Create a new feedback config.
-
#create_project(name:, description: nil) ⇒ Langsmith::Project
Create a new project.
-
#create_prompt(name:, prompt_template:, metadata: {}) ⇒ Hash
Create a new prompt.
-
#create_run(name:, run_type:, project_name: nil, inputs: {}, extra: {}) ⇒ Langsmith::Run
Create a new run.
-
#create_run_comment(run_id:, comment:, metadata: nil) ⇒ Hash
Create a comment on a run.
-
#create_tag(name:) ⇒ Hash
Create a new tag.
-
#create_tenant(name:, config: {}) ⇒ Hash
Create a new tenant.
-
#create_tracer_session(name:, metadata: {}) ⇒ Hash
Create a new tracer session.
-
#create_webhook(url:, event_types:, metadata: nil) ⇒ Hash
Create a webhook.
- #delete(path) ⇒ Object
-
#delete_annotation_queue(id:) ⇒ Boolean
Delete an annotation queue.
-
#delete_api_key(id:) ⇒ Boolean
Delete an API key.
-
#delete_comment(comment_id:) ⇒ Boolean
Delete a comment.
-
#delete_dataset(id:) ⇒ Boolean
Delete a dataset.
-
#delete_evaluation(id:) ⇒ Boolean
Delete an evaluation.
-
#delete_example(id:) ⇒ Boolean
Delete an example.
-
#delete_feedback_config(id:) ⇒ Boolean
Delete a feedback config.
-
#delete_prompt(id:) ⇒ Boolean
Delete a prompt.
-
#delete_tag(id:) ⇒ Boolean
Delete a tag.
-
#delete_webhook(id:) ⇒ Boolean
Delete a webhook.
-
#get(path, params = {}) ⇒ Object
HTTP request methods.
-
#get_annotation_queue(id:) ⇒ Hash
Get an annotation queue by ID.
-
#get_api_info ⇒ Hash
Get API info.
-
#get_current_organization ⇒ Hash
Get current organization information.
-
#get_dataset(name:) ⇒ Langsmith::Dataset
Get a dataset by name.
-
#get_dataset_analytics(dataset_id:, start_time: nil, end_time: nil, group_by: nil, metrics: nil, filters: nil) ⇒ Hash
Get analytics for a dataset.
-
#get_dataset_by_id(id:) ⇒ Langsmith::Dataset
Get a dataset by ID.
-
#get_evaluation(id:) ⇒ Langsmith::Evaluation
Get an evaluation by ID.
-
#get_example(id:) ⇒ Langsmith::Example
Get an example by ID.
-
#get_feedback(run_id:) ⇒ Array<Langsmith::Feedback>
Get feedback for a run.
-
#get_feedback_config(id:) ⇒ Hash
Get a feedback config by ID.
-
#get_organization(id:) ⇒ Hash
Get organization by ID.
-
#get_project(name:) ⇒ Langsmith::Project
Get a project by name.
-
#get_project_analytics(project_id:, start_time: nil, end_time: nil, group_by: nil, metrics: nil, filters: nil) ⇒ Hash
Get analytics for a project.
-
#get_prompt(id:) ⇒ Hash
Get a prompt by ID.
-
#get_run(run_id:) ⇒ Langsmith::Run
Get a run by ID.
-
#get_settings ⇒ Hash
Get settings.
-
#get_tag(id:) ⇒ Hash
Get a tag by ID.
-
#get_tenant(id:) ⇒ Hash
Get tenant information.
-
#get_tracer_session(id:) ⇒ Hash
Get a tracer session by ID.
-
#get_usage_limits ⇒ Hash
Get usage limits.
-
#get_webhook(id:) ⇒ Hash
Get a webhook by ID.
-
#initialize(api_key: nil, api_url: nil) ⇒ Client
constructor
Initialize a new LangSmith client.
-
#invite_team_member(email:, role:, organization_id: nil) ⇒ Hash
Invite a team member.
-
#list_annotation_queues(limit: 100, offset: 0) ⇒ Array<Hash>
List annotation queues.
-
#list_api_keys ⇒ Array<Hash>
List API keys.
-
#list_datasets(limit: 100, offset: 0, name: nil, name_contains: nil) ⇒ Array<Langsmith::Dataset>
List datasets.
-
#list_evaluations(dataset_id: nil, evaluator_name: nil, run_id: nil, status: nil, limit: 100, offset: 0) ⇒ Array<Langsmith::Evaluation>
List evaluations with optional filters.
-
#list_events(name: nil, start_time: nil, end_time: nil, limit: 100, offset: 0) ⇒ Array<Hash>
List events.
-
#list_feedback_configs(limit: 100, offset: 0) ⇒ Array<Hash>
List feedback configs.
-
#list_organizations ⇒ Array<Hash>
List organizations the user belongs to.
-
#list_projects(limit: 100) ⇒ Array<Langsmith::Project>
List projects.
-
#list_prompts(limit: 100, offset: 0) ⇒ Array<Hash>
List prompts.
-
#list_run_comments(run_id:, limit: 100, offset: 0) ⇒ Array<Hash>
List comments on a run.
-
#list_runs(project_name: nil, run_type: nil, limit: 100) ⇒ Array<Langsmith::Run>
List runs with optional filters.
-
#list_tags(limit: 100, offset: 0) ⇒ Array<Hash>
List tags.
-
#list_team_members(organization_id: nil, limit: 100, offset: 0) ⇒ Array<Hash>
List team members.
-
#list_tenants ⇒ Array<Hash>
List tenants.
-
#list_tracer_sessions(limit: 100, offset: 0) ⇒ Array<Hash>
List tracer sessions with optional filters.
-
#list_webhooks(limit: 100, offset: 0) ⇒ Array<Hash>
List webhooks.
- #patch(path, data = {}) ⇒ Object
- #post(path, data = {}) ⇒ Object
-
#remove_team_member(user_id:, organization_id: nil) ⇒ Boolean
Remove a team member.
-
#update_annotation_queue(id:, name: nil, description: nil, metadata: nil) ⇒ Hash
Update an annotation queue.
-
#update_dataset(id:, name: nil, description: nil) ⇒ Langsmith::Dataset
Update a dataset.
-
#update_evaluation_metadata(id:, metadata:) ⇒ Langsmith::Evaluation
Update an evaluation’s metadata.
-
#update_example(id:, inputs: nil, outputs: nil, metadata: nil) ⇒ Langsmith::Example
Update an example.
-
#update_feedback_config(id:, name: nil, type: nil, metadata: nil) ⇒ Hash
Update a feedback config.
-
#update_prompt(id:, name: nil, prompt_template: nil, metadata: nil) ⇒ Hash
Update a prompt.
-
#update_run(run_id:, outputs: nil, end_time: nil, error: nil) ⇒ Langsmith::Run
Update a run.
-
#update_settings(settings:) ⇒ Hash
Update settings.
-
#update_tenant(id:, name: nil, config: nil) ⇒ Hash
Update a tenant.
-
#update_webhook(id:, url: nil, event_types: nil, metadata: nil, active: nil) ⇒ Hash
Update a webhook.
Constructor Details
#initialize(api_key: nil, api_url: nil) ⇒ Client
Initialize a new LangSmith client
14 15 16 17 18 19 |
# File 'lib/langsmith/client.rb', line 14 def initialize(api_key: nil, api_url: nil) @api_key = api_key || ENV["LANGSMITH_API_KEY"] || Langsmith.api_key @api_url = api_url || ENV["LANGSMITH_API_URL"] || Langsmith.api_url || Langsmith::DEFAULT_API_URL raise Langsmith::Errors::AuthenticationError, "API key is required" unless @api_key end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/langsmith/client.rb', line 8 def api_key @api_key end |
#api_url ⇒ Object (readonly)
Returns the value of attribute api_url.
8 9 10 |
# File 'lib/langsmith/client.rb', line 8 def api_url @api_url end |
Instance Method Details
#bulk_delete_runs(run_ids:) ⇒ Hash
Bulk delete runs
854 855 856 857 858 859 860 |
# File 'lib/langsmith/client.rb', line 854 def bulk_delete_runs(run_ids:) data = { run_ids: run_ids } post("/runs/bulk/delete", data) end |
#bulk_tag_runs(run_ids:, tag_ids:) ⇒ Hash
Bulk tag runs
827 828 829 830 831 832 833 834 |
# File 'lib/langsmith/client.rb', line 827 def bulk_tag_runs(run_ids:, tag_ids:) data = { run_ids: run_ids, tag_ids: tag_ids } post("/runs/bulk/tag", data) end |
#bulk_untag_runs(run_ids:, tag_ids:) ⇒ Hash
Bulk untag runs
841 842 843 844 845 846 847 848 |
# File 'lib/langsmith/client.rb', line 841 def bulk_untag_runs(run_ids:, tag_ids:) data = { run_ids: run_ids, tag_ids: tag_ids } post("/runs/bulk/untag", data) end |
#cancel_evaluation(id:) ⇒ Langsmith::Evaluation
Cancel an evaluation
292 293 294 295 |
# File 'lib/langsmith/client.rb', line 292 def cancel_evaluation(id:) response = post("/evaluations/#{id}/cancel") Langsmith::Evaluation.new(self, response) end |
#create_annotation_queue(name:, description: nil, metadata: {}) ⇒ Hash
Create a new annotation queue
564 565 566 567 568 569 570 571 |
# File 'lib/langsmith/client.rb', line 564 def create_annotation_queue(name:, description: nil, metadata: {}) data = { name: name, metadata: } data[:description] = description if description post("/annotation-queues", data) end |
#create_api_key(name:, expires_at: nil) ⇒ Hash
Create a new API key
403 404 405 406 407 |
# File 'lib/langsmith/client.rb', line 403 def create_api_key(name:, expires_at: nil) data = { name: name } data[:expires_at] = expires_at.iso8601 if expires_at post("/api-key", data) end |
#create_dataset(name:, description: nil) ⇒ Langsmith::Dataset
Create a new dataset
121 122 123 124 125 126 127 |
# File 'lib/langsmith/client.rb', line 121 def create_dataset(name:, description: nil) data = { name: name } data[:description] = description if description response = post("/datasets", data) Langsmith::Dataset.new(self, response) end |
#create_event(name:, data:, metadata: nil) ⇒ Hash
Create an event
777 778 779 780 781 782 783 784 785 |
# File 'lib/langsmith/client.rb', line 777 def create_event(name:, data:, metadata: nil) event_data = { name: name, data: data } event_data[:metadata] = if post("/events", event_data) end |
#create_examples_batch(dataset_id:, examples:) ⇒ Array<Langsmith::Example>
Create multiple examples in batch
230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/langsmith/client.rb', line 230 def create_examples_batch(dataset_id:, examples:) data = examples.map do |example| example_data = { dataset_id: dataset_id, inputs: example[:inputs] } example_data[:outputs] = example[:outputs] if example[:outputs] example_data[:metadata] = example[:metadata] if example[:metadata] example_data end response = post("/examples/batch", { examples: data }) response.map { |example_data| Langsmith::Example.new(self, example_data) } end |
#create_feedback(run_id:, key:, score:, comment: nil) ⇒ Langsmith::Feedback
Create feedback for a run
313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/langsmith/client.rb', line 313 def create_feedback(run_id:, key:, score:, comment: nil) data = { run_id: run_id, key: key, score: score } data[:comment] = comment if comment response = post("/feedback", data) Langsmith::Feedback.new(self, response) end |
#create_feedback_config(name:, type:, metadata: {}) ⇒ Hash
Create a new feedback config
624 625 626 627 628 629 630 631 |
# File 'lib/langsmith/client.rb', line 624 def create_feedback_config(name:, type:, metadata: {}) data = { name: name, type: type, metadata: } post("/feedback-configs", data) end |
#create_project(name:, description: nil) ⇒ Langsmith::Project
Create a new project
89 90 91 92 93 94 95 |
# File 'lib/langsmith/client.rb', line 89 def create_project(name:, description: nil) data = { name: name } data[:description] = description if description response = post("/projects", data) Langsmith::Project.new(self, response) end |
#create_prompt(name:, prompt_template:, metadata: {}) ⇒ Hash
Create a new prompt
504 505 506 507 508 509 510 511 |
# File 'lib/langsmith/client.rb', line 504 def create_prompt(name:, prompt_template:, metadata: {}) data = { name: name, prompt_template: prompt_template, metadata: } post("/prompts", data) end |
#create_run(name:, run_type:, project_name: nil, inputs: {}, extra: {}) ⇒ Langsmith::Run
Create a new run
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/langsmith/client.rb', line 29 def create_run(name:, run_type:, project_name: nil, inputs: {}, extra: {}) data = { name: name, run_type: run_type, inputs: inputs, extra: extra } data[:project_name] = project_name if project_name response = post("/runs", data) Langsmith::Run.new(self, response) end |
#create_run_comment(run_id:, comment:, metadata: nil) ⇒ Hash
Create a comment on a run
738 739 740 741 742 743 744 745 |
# File 'lib/langsmith/client.rb', line 738 def create_run_comment(run_id:, comment:, metadata: nil) data = { comment: comment } data[:metadata] = if post("/runs/#{run_id}/comments", data) end |
#create_tag(name:) ⇒ Hash
Create a new tag
463 464 465 466 |
# File 'lib/langsmith/client.rb', line 463 def create_tag(name:) data = { name: name } post("/tags", data) end |
#create_tenant(name:, config: {}) ⇒ Hash
Create a new tenant
438 439 440 441 442 443 444 |
# File 'lib/langsmith/client.rb', line 438 def create_tenant(name:, config: {}) data = { name: name, config: config } post("/tenant", data) end |
#create_tracer_session(name:, metadata: {}) ⇒ Hash
Create a new tracer session
340 341 342 343 344 345 346 |
# File 'lib/langsmith/client.rb', line 340 def create_tracer_session(name:, metadata: {}) data = { name: name, metadata: } post("/tracer-sessions", data) end |
#create_webhook(url:, event_types:, metadata: nil) ⇒ Hash
Create a webhook
868 869 870 871 872 873 874 875 876 |
# File 'lib/langsmith/client.rb', line 868 def create_webhook(url:, event_types:, metadata: nil) data = { url: url, event_types: event_types } data[:metadata] = if post("/webhooks", data) end |
#delete(path) ⇒ Object
995 996 997 998 |
# File 'lib/langsmith/client.rb', line 995 def delete(path) response = connection.delete(path) handle_response(response) end |
#delete_annotation_queue(id:) ⇒ Boolean
Delete an annotation queue
613 614 615 616 |
# File 'lib/langsmith/client.rb', line 613 def delete_annotation_queue(id:) delete("/annotation-queues/#{id}") true end |
#delete_api_key(id:) ⇒ Boolean
Delete an API key
413 414 415 416 |
# File 'lib/langsmith/client.rb', line 413 def delete_api_key(id:) delete("/api-key/#{id}") true end |
#delete_comment(comment_id:) ⇒ Boolean
Delete a comment
766 767 768 769 |
# File 'lib/langsmith/client.rb', line 766 def delete_comment(comment_id:) delete("/comments/#{comment_id}") true end |
#delete_dataset(id:) ⇒ Boolean
Delete a dataset
185 186 187 188 |
# File 'lib/langsmith/client.rb', line 185 def delete_dataset(id:) delete("/datasets/#{id}") true end |
#delete_evaluation(id:) ⇒ Boolean
Delete an evaluation
301 302 303 304 |
# File 'lib/langsmith/client.rb', line 301 def delete_evaluation(id:) delete("/evaluations/#{id}") true end |
#delete_example(id:) ⇒ Boolean
Delete an example
220 221 222 223 |
# File 'lib/langsmith/client.rb', line 220 def delete_example(id:) delete("/examples/#{id}") true end |
#delete_feedback_config(id:) ⇒ Boolean
Delete a feedback config
673 674 675 676 |
# File 'lib/langsmith/client.rb', line 673 def delete_feedback_config(id:) delete("/feedback-configs/#{id}") true end |
#delete_prompt(id:) ⇒ Boolean
Delete a prompt
553 554 555 556 |
# File 'lib/langsmith/client.rb', line 553 def delete_prompt(id:) delete("/prompts/#{id}") true end |
#delete_tag(id:) ⇒ Boolean
Delete a tag
493 494 495 496 |
# File 'lib/langsmith/client.rb', line 493 def delete_tag(id:) delete("/tags/#{id}") true end |
#delete_webhook(id:) ⇒ Boolean
Delete a webhook
922 923 924 925 |
# File 'lib/langsmith/client.rb', line 922 def delete_webhook(id:) delete("/webhooks/#{id}") true end |
#get(path, params = {}) ⇒ Object
HTTP request methods
976 977 978 979 |
# File 'lib/langsmith/client.rb', line 976 def get(path, params = {}) response = connection.get(path, params) handle_response(response) end |
#get_annotation_queue(id:) ⇒ Hash
Get an annotation queue by ID
577 578 579 |
# File 'lib/langsmith/client.rb', line 577 def get_annotation_queue(id:) get("/annotation-queues/#{id}") end |
#get_api_info ⇒ Hash
Get API info
688 689 690 |
# File 'lib/langsmith/client.rb', line 688 def get_api_info get("/info") end |
#get_current_organization ⇒ Hash
Get current organization information
372 373 374 |
# File 'lib/langsmith/client.rb', line 372 def get_current_organization get("/orgs/current") end |
#get_dataset(name:) ⇒ Langsmith::Dataset
Get a dataset by name
133 134 135 136 |
# File 'lib/langsmith/client.rb', line 133 def get_dataset(name:) response = get("/datasets/#{name}") Langsmith::Dataset.new(self, response) end |
#get_dataset_analytics(dataset_id:, start_time: nil, end_time: nil, group_by: nil, metrics: nil, filters: nil) ⇒ Hash
Get analytics for a dataset
721 722 723 724 725 726 727 728 729 730 |
# File 'lib/langsmith/client.rb', line 721 def get_dataset_analytics(dataset_id:, start_time: nil, end_time: nil, group_by: nil, metrics: nil, filters: nil) params = {} params[:start_time] = start_time.iso8601 if start_time params[:end_time] = end_time.iso8601 if end_time params[:group_by] = group_by if group_by params[:metrics] = metrics if metrics params[:filters] = filters if filters get("/datasets/#{dataset_id}/analytics", params) end |
#get_dataset_by_id(id:) ⇒ Langsmith::Dataset
Get a dataset by ID
161 162 163 164 |
# File 'lib/langsmith/client.rb', line 161 def get_dataset_by_id(id:) response = get("/datasets/#{id}") Langsmith::Dataset.new(self, response) end |
#get_evaluation(id:) ⇒ Langsmith::Evaluation
Get an evaluation by ID
249 250 251 252 |
# File 'lib/langsmith/client.rb', line 249 def get_evaluation(id:) response = get("/evaluations/#{id}") Langsmith::Evaluation.new(self, response) end |
#get_example(id:) ⇒ Langsmith::Example
Get an example by ID
194 195 196 197 |
# File 'lib/langsmith/client.rb', line 194 def get_example(id:) response = get("/examples/#{id}") Langsmith::Example.new(self, response) end |
#get_feedback(run_id:) ⇒ Array<Langsmith::Feedback>
Get feedback for a run
329 330 331 332 333 |
# File 'lib/langsmith/client.rb', line 329 def get_feedback(run_id:) params = { run_id: run_id } response = get("/feedback", params) response.map { |feedback_data| Langsmith::Feedback.new(self, feedback_data) } end |
#get_feedback_config(id:) ⇒ Hash
Get a feedback config by ID
637 638 639 |
# File 'lib/langsmith/client.rb', line 637 def get_feedback_config(id:) get("/feedback-configs/#{id}") end |
#get_organization(id:) ⇒ Hash
Get organization by ID
387 388 389 |
# File 'lib/langsmith/client.rb', line 387 def get_organization(id:) get("/orgs/#{id}") end |
#get_project(name:) ⇒ Langsmith::Project
Get a project by name
101 102 103 104 |
# File 'lib/langsmith/client.rb', line 101 def get_project(name:) response = get("/projects/#{name}") Langsmith::Project.new(self, response) end |
#get_project_analytics(project_id:, start_time: nil, end_time: nil, group_by: nil, metrics: nil, filters: nil) ⇒ Hash
Get analytics for a project
701 702 703 704 705 706 707 708 709 710 |
# File 'lib/langsmith/client.rb', line 701 def get_project_analytics(project_id:, start_time: nil, end_time: nil, group_by: nil, metrics: nil, filters: nil) params = {} params[:start_time] = start_time.iso8601 if start_time params[:end_time] = end_time.iso8601 if end_time params[:group_by] = group_by if group_by params[:metrics] = metrics if metrics params[:filters] = filters if filters get("/projects/#{project_id}/analytics", params) end |
#get_prompt(id:) ⇒ Hash
Get a prompt by ID
517 518 519 |
# File 'lib/langsmith/client.rb', line 517 def get_prompt(id:) get("/prompts/#{id}") end |
#get_run(run_id:) ⇒ Langsmith::Run
Get a run by ID
63 64 65 66 |
# File 'lib/langsmith/client.rb', line 63 def get_run(run_id:) response = get("/runs/#{run_id}") Langsmith::Run.new(self, response) end |
#get_settings ⇒ Hash
Get settings
810 811 812 |
# File 'lib/langsmith/client.rb', line 810 def get_settings get("/settings") end |
#get_tag(id:) ⇒ Hash
Get a tag by ID
472 473 474 |
# File 'lib/langsmith/client.rb', line 472 def get_tag(id:) get("/tags/#{id}") end |
#get_tenant(id:) ⇒ Hash
Get tenant information
422 423 424 |
# File 'lib/langsmith/client.rb', line 422 def get_tenant(id:) get("/tenant/#{id}") end |
#get_tracer_session(id:) ⇒ Hash
Get a tracer session by ID
352 353 354 |
# File 'lib/langsmith/client.rb', line 352 def get_tracer_session(id:) get("/tracer-sessions/#{id}") end |
#get_usage_limits ⇒ Hash
Get usage limits
681 682 683 |
# File 'lib/langsmith/client.rb', line 681 def get_usage_limits get("/usage-limits") end |
#get_webhook(id:) ⇒ Hash
Get a webhook by ID
882 883 884 |
# File 'lib/langsmith/client.rb', line 882 def get_webhook(id:) get("/webhooks/#{id}") end |
#invite_team_member(email:, role:, organization_id: nil) ⇒ Hash
Invite a team member
949 950 951 952 953 954 955 956 957 |
# File 'lib/langsmith/client.rb', line 949 def invite_team_member(email:, role:, organization_id: nil) data = { email: email, role: role } data[:organization_id] = organization_id if organization_id post("/team/invite", data) end |
#list_annotation_queues(limit: 100, offset: 0) ⇒ Array<Hash>
List annotation queues
586 587 588 589 590 591 592 |
# File 'lib/langsmith/client.rb', line 586 def list_annotation_queues(limit: 100, offset: 0) params = { limit: limit, offset: offset } get("/annotation-queues", params) end |
#list_api_keys ⇒ Array<Hash>
List API keys
394 395 396 |
# File 'lib/langsmith/client.rb', line 394 def list_api_keys get("/api-key") end |
#list_datasets(limit: 100, offset: 0, name: nil, name_contains: nil) ⇒ Array<Langsmith::Dataset>
List datasets
145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/langsmith/client.rb', line 145 def list_datasets(limit: 100, offset: 0, name: nil, name_contains: nil) params = { limit: limit, offset: offset } params[:name] = name if name params[:name_contains] = name_contains if name_contains response = get("/datasets", params) response.map { |dataset_data| Langsmith::Dataset.new(self, dataset_data) } end |
#list_evaluations(dataset_id: nil, evaluator_name: nil, run_id: nil, status: nil, limit: 100, offset: 0) ⇒ Array<Langsmith::Evaluation>
List evaluations with optional filters
263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/langsmith/client.rb', line 263 def list_evaluations(dataset_id: nil, evaluator_name: nil, run_id: nil, status: nil, limit: 100, offset: 0) params = { limit: limit, offset: offset } params[:dataset_id] = dataset_id if dataset_id params[:evaluator_name] = evaluator_name if evaluator_name params[:run_id] = run_id if run_id params[:status] = status if status response = get("/evaluations", params) response.map { |eval_data| Langsmith::Evaluation.new(self, eval_data) } end |
#list_events(name: nil, start_time: nil, end_time: nil, limit: 100, offset: 0) ⇒ Array<Hash>
List events
795 796 797 798 799 800 801 802 803 804 805 |
# File 'lib/langsmith/client.rb', line 795 def list_events(name: nil, start_time: nil, end_time: nil, limit: 100, offset: 0) params = { limit: limit, offset: offset } params[:name] = name if name params[:start_time] = start_time.iso8601 if start_time params[:end_time] = end_time.iso8601 if end_time get("/events", params) end |
#list_feedback_configs(limit: 100, offset: 0) ⇒ Array<Hash>
List feedback configs
646 647 648 649 650 651 652 |
# File 'lib/langsmith/client.rb', line 646 def list_feedback_configs(limit: 100, offset: 0) params = { limit: limit, offset: offset } get("/feedback-configs", params) end |
#list_organizations ⇒ Array<Hash>
List organizations the user belongs to
379 380 381 |
# File 'lib/langsmith/client.rb', line 379 def list_organizations get("/orgs") end |
#list_projects(limit: 100) ⇒ Array<Langsmith::Project>
List projects
110 111 112 113 114 |
# File 'lib/langsmith/client.rb', line 110 def list_projects(limit: 100) params = { limit: limit } response = get("/projects", params) response.map { |project_data| Langsmith::Project.new(self, project_data) } end |
#list_prompts(limit: 100, offset: 0) ⇒ Array<Hash>
List prompts
526 527 528 529 530 531 532 |
# File 'lib/langsmith/client.rb', line 526 def list_prompts(limit: 100, offset: 0) params = { limit: limit, offset: offset } get("/prompts", params) end |
#list_run_comments(run_id:, limit: 100, offset: 0) ⇒ Array<Hash>
List comments on a run
753 754 755 756 757 758 759 760 |
# File 'lib/langsmith/client.rb', line 753 def list_run_comments(run_id:, limit: 100, offset: 0) params = { limit: limit, offset: offset } get("/runs/#{run_id}/comments", params) end |
#list_runs(project_name: nil, run_type: nil, limit: 100) ⇒ Array<Langsmith::Run>
List runs with optional filters
74 75 76 77 78 79 80 81 82 |
# File 'lib/langsmith/client.rb', line 74 def list_runs(project_name: nil, run_type: nil, limit: 100) params = {} params[:project_name] = project_name if project_name params[:run_type] = run_type if run_type params[:limit] = limit response = get("/runs", params) response.map { |run_data| Langsmith::Run.new(self, run_data) } end |
#list_tags(limit: 100, offset: 0) ⇒ Array<Hash>
List tags
481 482 483 484 485 486 487 |
# File 'lib/langsmith/client.rb', line 481 def (limit: 100, offset: 0) params = { limit: limit, offset: offset } get("/tags", params) end |
#list_team_members(organization_id: nil, limit: 100, offset: 0) ⇒ Array<Hash>
List team members
933 934 935 936 937 938 939 940 941 |
# File 'lib/langsmith/client.rb', line 933 def list_team_members(organization_id: nil, limit: 100, offset: 0) params = { limit: limit, offset: offset } params[:organization_id] = organization_id if organization_id get("/team/members", params) end |
#list_tenants ⇒ Array<Hash>
List tenants
429 430 431 |
# File 'lib/langsmith/client.rb', line 429 def list_tenants get("/tenant") end |
#list_tracer_sessions(limit: 100, offset: 0) ⇒ Array<Hash>
List tracer sessions with optional filters
361 362 363 364 365 366 367 |
# File 'lib/langsmith/client.rb', line 361 def list_tracer_sessions(limit: 100, offset: 0) params = { limit: limit, offset: offset } get("/tracer-sessions", params) end |
#list_webhooks(limit: 100, offset: 0) ⇒ Array<Hash>
List webhooks
891 892 893 894 895 896 897 898 |
# File 'lib/langsmith/client.rb', line 891 def list_webhooks(limit: 100, offset: 0) params = { limit: limit, offset: offset } get("/webhooks", params) end |
#patch(path, data = {}) ⇒ Object
988 989 990 991 992 993 |
# File 'lib/langsmith/client.rb', line 988 def patch(path, data = {}) response = connection.patch(path) do |req| req.body = JSON.generate(data) end handle_response(response) end |
#post(path, data = {}) ⇒ Object
981 982 983 984 985 986 |
# File 'lib/langsmith/client.rb', line 981 def post(path, data = {}) response = connection.post(path) do |req| req.body = JSON.generate(data) end handle_response(response) end |
#remove_team_member(user_id:, organization_id: nil) ⇒ Boolean
Remove a team member
964 965 966 967 968 969 970 971 972 |
# File 'lib/langsmith/client.rb', line 964 def remove_team_member(user_id:, organization_id: nil) data = { user_id: user_id } data[:organization_id] = organization_id if organization_id post("/team/remove", data) true end |
#update_annotation_queue(id:, name: nil, description: nil, metadata: nil) ⇒ Hash
Update an annotation queue
601 602 603 604 605 606 607 |
# File 'lib/langsmith/client.rb', line 601 def update_annotation_queue(id:, name: nil, description: nil, metadata: nil) data = {} data[:name] = name if name data[:description] = description if description data[:metadata] = if patch("/annotation-queues/#{id}", data) end |
#update_dataset(id:, name: nil, description: nil) ⇒ Langsmith::Dataset
Update a dataset
172 173 174 175 176 177 178 179 |
# File 'lib/langsmith/client.rb', line 172 def update_dataset(id:, name: nil, description: nil) data = {} data[:name] = name if name data[:description] = description if description response = patch("/datasets/#{id}", data) Langsmith::Dataset.new(self, response) end |
#update_evaluation_metadata(id:, metadata:) ⇒ Langsmith::Evaluation
Update an evaluation’s metadata
282 283 284 285 286 |
# File 'lib/langsmith/client.rb', line 282 def (id:, metadata:) data = { metadata: } response = patch("/evaluations/#{id}", data) Langsmith::Evaluation.new(self, response) end |
#update_example(id:, inputs: nil, outputs: nil, metadata: nil) ⇒ Langsmith::Example
Update an example
206 207 208 209 210 211 212 213 214 |
# File 'lib/langsmith/client.rb', line 206 def update_example(id:, inputs: nil, outputs: nil, metadata: nil) data = {} data[:inputs] = inputs if inputs data[:outputs] = outputs if outputs data[:metadata] = if response = patch("/examples/#{id}", data) Langsmith::Example.new(self, response) end |
#update_feedback_config(id:, name: nil, type: nil, metadata: nil) ⇒ Hash
Update a feedback config
661 662 663 664 665 666 667 |
# File 'lib/langsmith/client.rb', line 661 def update_feedback_config(id:, name: nil, type: nil, metadata: nil) data = {} data[:name] = name if name data[:type] = type if type data[:metadata] = if patch("/feedback-configs/#{id}", data) end |
#update_prompt(id:, name: nil, prompt_template: nil, metadata: nil) ⇒ Hash
Update a prompt
541 542 543 544 545 546 547 |
# File 'lib/langsmith/client.rb', line 541 def update_prompt(id:, name: nil, prompt_template: nil, metadata: nil) data = {} data[:name] = name if name data[:prompt_template] = prompt_template if prompt_template data[:metadata] = if patch("/prompts/#{id}", data) end |
#update_run(run_id:, outputs: nil, end_time: nil, error: nil) ⇒ Langsmith::Run
Update a run
49 50 51 52 53 54 55 56 57 |
# File 'lib/langsmith/client.rb', line 49 def update_run(run_id:, outputs: nil, end_time: nil, error: nil) data = {} data[:outputs] = outputs if outputs data[:end_time] = end_time.iso8601 if end_time data[:error] = error if error response = patch("/runs/#{run_id}", data) Langsmith::Run.new(self, response) end |
#update_settings(settings:) ⇒ Hash
Update settings
818 819 820 |
# File 'lib/langsmith/client.rb', line 818 def update_settings(settings:) patch("/settings", settings) end |
#update_tenant(id:, name: nil, config: nil) ⇒ Hash
Update a tenant
452 453 454 455 456 457 |
# File 'lib/langsmith/client.rb', line 452 def update_tenant(id:, name: nil, config: nil) data = {} data[:name] = name if name data[:config] = config if config patch("/tenant/#{id}", data) end |
#update_webhook(id:, url: nil, event_types: nil, metadata: nil, active: nil) ⇒ Hash
Update a webhook
908 909 910 911 912 913 914 915 916 |
# File 'lib/langsmith/client.rb', line 908 def update_webhook(id:, url: nil, event_types: nil, metadata: nil, active: nil) data = {} data[:url] = url if url data[:event_types] = event_types if event_types data[:metadata] = if data[:active] = active unless active.nil? patch("/webhooks/#{id}", data) end |