API Reference¶
nearai ¶
parse_location ¶
Create a EntryLocation from a string in the format namespace/name/version.
Source code in nearai/lib.py
agent ¶
Agent ¶
Bases: object
Source code in nearai/agent.py
load_agent_metadata ¶
Load agent details from metadata.json.
Source code in nearai/agent.py
cli ¶
AgentCli ¶
Source code in nearai/cli.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
|
inspect ¶
interactive ¶
interactive(agents: str, path: Optional[str] = '', record_run: str = 'true', env_vars: Optional[Dict[str, Any]] = None, load_env: str = '', local: bool = False, tool_resources: Optional[Dict[str, Any]] = None, print_system_log: bool = True) -> None
Runs agent interactively with environment from given path.
Source code in nearai/cli.py
run_remote ¶
run_remote(agents: str, new_message: str = '', environment_id: str = '', provider: str = 'aws_lambda', params: object = None) -> None
Invoke a Container based AWS lambda function to run agents on a given environment.
Source code in nearai/cli.py
save_folder ¶
Saves all subfolders with agent task runs (must contain non-empty chat.txt).
Source code in nearai/cli.py
save_from_history ¶
Reads piped history, finds agent task runs, writes start_command.log files, and saves to registry. For detailed usage, run: nearai agent save_from_history --help.
This command: 1. Finds agent task runs (must contain non-empty chat.txt) 2. Writes start_command.log files 3. Saves to registry
Only 'interactive' is supported. Assumes format: '
Source code in nearai/cli.py
task ¶
task(agents: str, task: str, path: Optional[str] = '', max_iterations: int = 10, record_run: str = 'true', env_vars: Optional[Dict[str, Any]] = None, load_env: str = '', local: bool = False) -> None
Runs agent non interactively with environment from given path.
Source code in nearai/cli.py
BenchmarkCli ¶
Source code in nearai/cli.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
|
__init__ ¶
list ¶
list(namespace: Optional[str] = None, benchmark: Optional[str] = None, solver: Optional[str] = None, args: Optional[str] = None, total: int = 32, offset: int = 0)
List all executed benchmarks.
Source code in nearai/cli.py
run ¶
run(dataset: str, solver_strategy: str, max_concurrent: int = -1, force: bool = False, subset: Optional[str] = None, check_compatibility: bool = True, record: bool = False, **solver_args: Any) -> None
Run benchmark on a dataset with a solver strategy.
It will cache the results in the database and subsequent runs will pull the results from the cache. If force is set to True, it will run the benchmark again and update the cache.
Source code in nearai/cli.py
CLI ¶
Source code in nearai/cli.py
location ¶
ConfigCli ¶
Source code in nearai/cli.py
get ¶
EvaluationCli ¶
Source code in nearai/cli.py
table ¶
table(namespace: str = '', tags: str = '', all_key_columns: bool = False, all_metrics: bool = False, num_columns: int = 6, metric_name_max_length: int = 30) -> None
Prints table of evaluations.
Source code in nearai/cli.py
HubCLI ¶
Source code in nearai/cli.py
chat ¶
Chat with model from NearAI hub.
query (str): User's query to model
endpoint (str): NearAI HUB's url
model (str): Name of a model
provider (str): Name of a provider
info (bool): Display system info
kwargs (Dict[str, Any]): All cli keyword arguments
Source code in nearai/cli.py
LoginCLI ¶
Source code in nearai/cli.py
__call__ ¶
Login with NEAR Mainnet account.
remote (bool): Remote login allows signing message with NEAR Account on a remote machine
auth_url (str): Url to the auth portal
accountId (str): AccountId in .near-credentials folder to signMessage
privateKey (str): Private Key to sign a message
kwargs (Dict[str, Any]): All cli keyword arguments
Source code in nearai/cli.py
save ¶
Save NEAR account authorization data.
accountId (str): Near Account
signature (str): Signature
publicKey (str): Public Key used to sign
callbackUrl (str): Callback Url
nonce (str): nonce
kwargs (Dict[str, Any]): All cli keyword arguments
Source code in nearai/cli.py
LogoutCLI ¶
Source code in nearai/cli.py
__call__ ¶
Clear NEAR account auth data.
Source code in nearai/cli.py
RegistryCli ¶
Source code in nearai/cli.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
download ¶
info ¶
Show information about an item.
Source code in nearai/cli.py
list ¶
list(namespace: str = '', category: str = '', tags: str = '', total: int = 32, offset: int = 0, show_all: bool = False, show_latest_version: bool = True, star: str = '') -> None
List available items.
Source code in nearai/cli.py
metadata_template ¶
Create a metadata template.
Source code in nearai/cli.py
update ¶
Update metadata of a registry item.
Source code in nearai/cli.py
check_update ¶
Check if there is a new version of nearai CLI available.
Source code in nearai/cli.py
completion ¶
InferenceRouter ¶
Bases: object
Source code in nearai/completion.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
completions ¶
completions(model: str, messages: Iterable[ChatCompletionMessageParam], stream: bool = False, temperature: Optional[float] = None, auth: Optional[AuthData] = None, max_tokens: Optional[int] = None, **kwargs: Any) -> Union[ModelResponse, CustomStreamWrapper]
Takes a model
and messages
and returns completions.
model
can be: 1. full path provider::model_full_path
. 2. model_short_name
. Default provider will be used.
Source code in nearai/completion.py
get_auth_str ¶
get_auth_str(auth: Optional[AuthData] = None) -> str
Get authentication string from provided auth or config object.
auth (Optional[AuthData]): Authentication data. If None, uses config auth.
str: JSON string containing authentication data.
Source code in nearai/completion.py
query_vector_store ¶
query_vector_store(vector_store_id: str, query: str, auth: Optional[AuthData] = None) -> List[SimilaritySearch]
Query a vector store.
Source code in nearai/completion.py
config ¶
AuthData ¶
Bases: BaseModel
Source code in nearai/config.py
generate_bearer_token ¶
Generates a JSON-encoded bearer token containing authentication data.
Source code in nearai/config.py
Config ¶
Bases: BaseModel
Source code in nearai/config.py
get ¶
update_with ¶
update_with(extra_config: Dict[str, Any], map_key: Callable[[str], str] = lambda x: x) -> Config
Update the config with the given dictionary.
Source code in nearai/config.py
NearAiHubConfig ¶
Bases: BaseModel
NearAiHub Config.
login_with_near (Optional[bool]): Indicates whether to attempt login using Near Auth.
api_key (Optional[str]): The API key to use if Near Auth is not being utilized
base_url (Optional[str]): NearAI Hub url
default_provider (Optional[str]): Default provider name
default_model (Optional[str]): Default model name
custom_llm_provider (Optional[str]): provider to be used by litellm proxy
Source code in nearai/config.py
dataset ¶
get_dataset ¶
Download the dataset from the registry and download it locally if it hasn't been downloaded yet.
:param name: The name of the entry to download the dataset. The format should be namespace/name/version. :return: The path to the downloaded dataset
Source code in nearai/dataset.py
load_dataset ¶
environment ¶
Environment ¶
Bases: object
Source code in nearai/environment.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 |
|
add_agent_log ¶
Add agent log with timestamp and log level.
Source code in nearai/environment.py
add_message ¶
Add a message to the chat file.
Source code in nearai/environment.py
add_system_log ¶
Add system log with timestamp and log level.
Source code in nearai/environment.py
call_agent ¶
clear_temp_agent_files ¶
Remove temp agent files created to be used in runpy
.
completion ¶
completion(messages: Iterable[ChatCompletionMessageParam] | str, model: Iterable[ChatCompletionMessageParam] | str = '', auth: Dict | Optional[AuthData] = None) -> str
Returns a completion for the given messages using the given model.
Source code in nearai/environment.py
completion_and_run_tools ¶
completion_and_run_tools(messages: Iterable[ChatCompletionMessageParam] | str, model: Iterable[ChatCompletionMessageParam] | str = '', tools: Optional[List] = None, **kwargs: Any) -> str
Returns a completion for the given messages using the given model and runs tools.
Source code in nearai/environment.py
completions ¶
completions(messages: Iterable[ChatCompletionMessageParam] | str, model: Iterable[ChatCompletionMessageParam] | str = '', stream: bool = False, **kwargs: Any) -> Union[ModelResponse, CustomStreamWrapper]
Returns all completions for given messages using the given model.
Source code in nearai/environment.py
completions_and_run_tools ¶
completions_and_run_tools(messages: Iterable[ChatCompletionMessageParam] | str, model: Iterable[ChatCompletionMessageParam] | str = '', tools: Optional[List] = None, **kwargs: Any) -> ModelResponse
Returns all completions for given messages using the given model and runs tools.
Source code in nearai/environment.py
create_snapshot ¶
Create an in memory snapshot.
Source code in nearai/environment.py
exec_command ¶
Executes a command in the environment and logs the output.
The environment does not allow running interactive programs. It will run a program for 1 second then will interrupt it if it is still running or if it is waiting for user input. command: The command to execute, like 'ls -l' or 'python3 tests.py'
Source code in nearai/environment.py
generate_folder_hash_id ¶
Returns id similar to _generate_run_id(), but based on files and their contents in path, including subfolders.
Source code in nearai/environment.py
get_model_for_inference ¶
Returns 'provider::model_full_path' or 'model_short_name' if provider is default or not given.
Source code in nearai/environment.py
get_path ¶
get_tool_registry ¶
get_tool_registry() -> ToolRegistry
list_files ¶
list_messages ¶
Returns messages from a specified file.
Source code in nearai/environment.py
list_terminal_commands ¶
load_snapshot ¶
Load Environment from Snapshot.
Source code in nearai/environment.py
query_vector_store ¶
Query a vector store.
vector_store_id: The id of the vector store to query. query: The query to search for.
Source code in nearai/environment.py
read_file ¶
Read a file from the environment.
filename: The name of the file to read.
Source code in nearai/environment.py
request_user_input ¶
run_interactive ¶
Run an interactive session within the given environment.
Source code in nearai/environment.py
run_task ¶
Runs a task within the given environment.
Source code in nearai/environment.py
save_to_registry ¶
save_to_registry(path: str, run_type: str, run_id: str, base_id: Optional[Union[str, int]] = None, run_name: Optional[str] = None) -> Optional[bytes]
Save Environment to Registry.
Source code in nearai/environment.py
set_next_actor ¶
Set the next actor / action in the dialogue.
verify_message ¶
verify_message(account_id: str, public_key: str, signature: str, message: str, nonce: str, callback_url: str) -> bool
Verify user message signed with NEAR Account.
Source code in nearai/environment.py
write_file ¶
Writes a file to the environment.
filename: The name of the file to write to content: The content to write to the file.
Source code in nearai/environment.py
evaluation ¶
evaluation_table ¶
evaluation_table(namespace: str = '', tags: str = '') -> Tuple[Dict[tuple[tuple[str, Any], ...], Dict[str, str]], List[str], List[str]]
Returns rows, columns, and important columns.
Source code in nearai/evaluation.py
print_evaluation_table ¶
print_evaluation_table(rows: Dict[tuple[tuple[str, Any], ...], Dict[str, str]], columns: List[str], important_columns: List[str], all_key_columns: bool, all_metrics: bool, num_columns: int, metric_name_max_length: int) -> None
Prints table of evaluations.
Source code in nearai/evaluation.py
record_evaluation_metrics ¶
record_evaluation_metrics(solver_strategy: SolverStrategy, metrics: Dict[str, Any], prepend_evaluation_name: bool = True) -> None
Uploads evaluation metrics into registry.
Source code in nearai/evaluation.py
record_single_score_evaluation ¶
record_single_score_evaluation(solver_strategy: SolverStrategy, score: float) -> None
Uploads single score evaluation into registry.
Source code in nearai/evaluation.py
upload_evaluation ¶
upload_evaluation(evaluation_name: str, metrics: Dict[str, Any], model: str = '', agent: str = '', namespace: str = '', version: str = '', provider: str = '') -> None
Uploads evaluation into registry.
evaluation_name
: a unique name for (benchmark, solver) tuple, e.g. "mbpp" or "live_bench" or "mmlu-5-shot". metrics
: metrics from evaluation. model
: model that was used. agent
: agent that was evaluated, in any. namespace
: namespace of evaluated agent or evaluated model. version
: version of evaluated agent or evaluated model. provider
: provider of model used; pass local
if running locally.
Source code in nearai/evaluation.py
finetune ¶
FinetuneCli ¶
Source code in nearai/finetune/__init__.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
start ¶
start(model: str, tokenizer: str, dataset: str, num_procs: int, format: str, upload_checkpoint: bool = True, num_nodes: int = 1, job_id: Optional[str] = None, checkpoint: Optional[str] = None, **dataset_kwargs: Any) -> None
Start a finetuning job on the current node.
model: Name of a model in the registry. Base model to finetune.
tokenizer: Name of a tokenizer in the registry. Using tokenizer.model format.
dataset: Name of a dataset in the registry.
num_procs: Number of GPUs to use for training
format: Name of the configuration file to use. For example llama3-70b, llama3-8b. Valid options are in etc/finetune.
upload_checkpoint: Whether to upload the checkpoint to the registry. Default is True.
num_nodes: Number of nodes to use for training. Default is 1.
job_id: Unique identifier for the job. Default is None.
checkpoint: Name of the model checkpoint to start from. Default is None.
dataset_kwargs: Additional keyword arguments to pass to the dataset constructor.
Source code in nearai/finetune/__init__.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
parse_line ¶
Example of line to be parsed.
Step 33 | loss:1.5400923490524292 lr:9.9e-05 tokens_per_second_per_gpu:101.22285588141214
Source code in nearai/finetune/__init__.py
text_completion ¶
TextCompletionDataset ¶
Bases: Dataset
Freeform dataset for any unstructured text corpus. Quickly load any dataset from Hugging Face or local disk and tokenize it for your model.
tokenizer (BaseTokenizer): Tokenizer used to encode data. Tokenize must implement an ``encode`` and ``decode`` method.
source (str): path string of dataset, anything supported by Hugging Face's ``load_dataset``
(https://huggingface.co/docs/datasets/en/package_reference/loading_methods#datasets.load_dataset.path)
column (str): name of column in the sample that contains the text data. This is typically required
for Hugging Face datasets or tabular data. For local datasets with a single column, use the default "text",
which is what is assigned by Hugging Face datasets when loaded into memory. Default is "text".
max_seq_len (Optional[int]): Maximum number of tokens in the returned input and label token id lists.
Default is None, disabling truncation. We recommend setting this to the highest you can fit in memory
and is supported by the model. For example, llama2-7B supports up to 4096 for sequence length.
**load_dataset_kwargs (Dict[str, Any]): additional keyword arguments to pass to ``load_dataset``.
Source code in nearai/finetune/text_completion.py
truncate ¶
Truncate a list of tokens to a maximum length. If eos_id is provided, the last token will be replaced with eos_id.
tokens (List[Any]): list of tokens to truncate
max_seq_len (int): maximum length of the list
eos_id (Optional[Any]): token to replace the last token with. If None, the
last token will not be replaced. Default is None.
List[Any]: truncated list of tokens
Source code in nearai/finetune/text_completion.py
hub ¶
Hub ¶
Bases: object
Source code in nearai/hub.py
chat ¶
Processes a chat request by sending parameters to the NearAI Hub and printing the response.
Source code in nearai/hub.py
parse_hub_chat_params ¶
Parses and sets instance attributes from the given keyword arguments, using default values if needed.
Source code in nearai/hub.py
lib ¶
parse_location ¶
Create a EntryLocation from a string in the format namespace/name/version.
Source code in nearai/lib.py
login ¶
AuthHandler ¶
Bases: SimpleHTTPRequestHandler
Source code in nearai/login.py
do_GET ¶
Webserver GET method.
Source code in nearai/login.py
find_open_port ¶
Finds and returns an open port number by binding to a free port on the local machine.
generate_and_save_signature ¶
Generates a signature for the given account ID and private key, then updates the auth configuration.
Source code in nearai/login.py
generate_callback_url ¶
generate_nonce ¶
login_with_file_credentials ¶
Logs in using credentials from a file for the specified account ID, generating and saving a signature.
Source code in nearai/login.py
login_with_near_auth ¶
Initiates the login process using NEAR authentication, either starting a local server to handle the callback or providing a URL for remote authentication.
Source code in nearai/login.py
print_login_status ¶
Prints the current authentication status if available in the config file.
Source code in nearai/login.py
print_url_message ¶
Prints a message instructing the user to visit the given URL to complete the login process.
update_auth_config ¶
Update authentication configuration if the provided signature is valid.
Source code in nearai/login.py
model ¶
get_model ¶
Download the model from the registry and download it locally if it hasn't been downloaded yet.
:param name: The name of the entry to download the model. The format should be namespace/name/version. :return: The path to the downloaded model
Source code in nearai/model.py
naming ¶
get_canonical_name ¶
Returns a name that can be used for matching entities.
Applies such transformations: 1. All letters lowercase. 2. Convert '.' between digits to 'p'. 3. Convert '
e.g. "llama-3.1-70b-instruct" -> "llama3p1_70binstruct"
Source code in nearai/naming.py
registry ¶
Registry ¶
Source code in nearai/registry.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
|
__init__ ¶
Create Registry object to interact with the registry programmatically.
Source code in nearai/registry.py
download ¶
download(entry_location: Union[str, EntryLocation], force: bool = False, show_progress: bool = False, verbose: bool = True) -> Path
Download entry from the registry locally.
Source code in nearai/registry.py
download_file ¶
Download a file from the registry.
Source code in nearai/registry.py
info ¶
Get metadata of a entry in the registry.
Source code in nearai/registry.py
list ¶
list(namespace: str, category: str, tags: str, total: int, offset: int, show_all: bool, show_latest_version: bool, starred_by: str = '') -> List[EntryInformation]
List and filter entries in the registry.
Source code in nearai/registry.py
list_all_visible ¶
list_files ¶
List files in from an entry in the registry.
Return the relative paths to all files with respect to the root of the entry.
Source code in nearai/registry.py
update ¶
Update metadata of a entry in the registry.
Source code in nearai/registry.py
upload ¶
upload(local_path: Path, metadata: Optional[EntryMetadata] = None, show_progress: bool = False) -> EntryLocation
Upload entry to the registry.
If metadata is provided it will overwrite the metadata in the directory, otherwise it will use the metadata.json found on the root of the directory.
Source code in nearai/registry.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
|
upload_file ¶
Upload a file to the registry.
Source code in nearai/registry.py
get_namespace ¶
Returns namespace of an item or user namespace.
Source code in nearai/registry.py
solvers ¶
DDOTSV0Solver ¶
Bases: SolverStrategy
Solver strategy for competitive programming problems live on DDOTS.
This dataset will run agents in an Agent environment previously prepared.
workspace/ .id -- Id of the problem PROBLEM.txt -- Description of the problem
The agent should call env.submit_python(code) to submit the code to the DDOTS server.
Source code in nearai/solvers/ddot_v0_solver.py
GSM8KSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the GSM8K dataset.
Source code in nearai/solvers/gsm8k_solver.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
HellaswagSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the MMLU dataset.
Source code in nearai/solvers/hellaswag_solver.py
LiveBenchSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the live bench dataset.
Source code in nearai/solvers/livebench_solver.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
|
MBPPSolverAgent ¶
Bases: SolverStrategy
Solver strategy for the MBPP dataset.
Source code in nearai/solvers/mbpp_agent_solver.py
MBPPSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the MBPP dataset.
Source code in nearai/solvers/mbpp_solver.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
MMLUSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the MMLU dataset.
Source code in nearai/solvers/mmlu_solver.py
SolverStrategy ¶
Bases: ABC
Abstract class for solver strategies.
Source code in nearai/solvers/__init__.py
agent_metadata abstractmethod
¶
compatible_datasets abstractmethod
¶
evaluated_entry_namespace abstractmethod
¶
evaluation_name abstractmethod
¶
Returns a unique name for (benchmark, solver) tuple, e.g. 'mbpp' or 'live_bench' or 'mmlu-5-shot'.
get_custom_tasks ¶
Custom tasks for custom benchmark.
Source code in nearai/solvers/__init__.py
get_evaluation_metrics ¶
Given results for all datums, returns evaluation metrics.
Not used by TrueOrFalseList scoring method. Do not prepend with evaluation_name. If hierarchical, use slashes /. Expected metrics is a dict of scores, e.g.: {"average":
Source code in nearai/solvers/__init__.py
model_metadata abstractmethod
¶
model_provider abstractmethod
¶
SolverStrategyMeta ¶
Bases: ABCMeta
Metaclass that automatically registers subclasses in the SolverStrategyRegistry.
Source code in nearai/solvers/__init__.py
ddot_v0_solver ¶
DDOTSEnvironment ¶
Bases: Environment
Source code in nearai/solvers/ddot_v0_solver.py
submit_python ¶
Returns True if the submission was accepted, False otherwise.
The second element of the tuple is the output of the checker if the submission was rejected.
Source code in nearai/solvers/ddot_v0_solver.py
DDOTSV0Solver ¶
Bases: SolverStrategy
Solver strategy for competitive programming problems live on DDOTS.
This dataset will run agents in an Agent environment previously prepared.
workspace/ .id -- Id of the problem PROBLEM.txt -- Description of the problem
The agent should call env.submit_python(code) to submit the code to the DDOTS server.
Source code in nearai/solvers/ddot_v0_solver.py
gsm8k_solver ¶
GSM8KSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the GSM8K dataset.
Source code in nearai/solvers/gsm8k_solver.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
hellaswag_solver ¶
HellaswagSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the MMLU dataset.
Source code in nearai/solvers/hellaswag_solver.py
livebench_solver ¶
LiveBenchSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the live bench dataset.
Source code in nearai/solvers/livebench_solver.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
|
mbpp_agent_solver ¶
MBPPSolverAgent ¶
Bases: SolverStrategy
Solver strategy for the MBPP dataset.
Source code in nearai/solvers/mbpp_agent_solver.py
mbpp_solver ¶
MBPPSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the MBPP dataset.
Source code in nearai/solvers/mbpp_solver.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
mmlu_solver ¶
MMLUSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the MMLU dataset.
Source code in nearai/solvers/mmlu_solver.py
tool_registry ¶
ToolRegistry ¶
A registry for tools that can be called by the agent.
Source code in nearai/tool_registry.py
call_tool ¶
get_all_tools ¶
get_tool ¶
get_tool_definition ¶
Get the definition of a tool by name.