API Calling: Web APIs
BLAST
Module for handling BLAST API interactions.
Provides functionality for building queries, fetching results, and interpreting BLAST (Basic Local Alignment Search Tool) sequence alignment data.
BlastFetcher
Bases: BaseFetcher
A class for retrieving API results from BLAST.
Retrieves results from BLAST given a parameterised BlastQuery.
TODO add a limit of characters to be returned from the response.text?
Source code in biochatter/api_agent/web/blast.py
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 |
|
_fetch_results(rid, question_uuid, retries=10000)
Fetch BLAST query data given RID.
The second function to be called for a BLAST query.
Source code in biochatter/api_agent/web/blast.py
_submit_query(request_data)
POST the BLAST query and retrieve the RID.
The method submits the structured BlastQuery object and returns the RID.
request_data: BlastQuery object containing the BLAST query
parameters.
str: The Request ID (RID) for the submitted BLAST query.
Source code in biochatter/api_agent/web/blast.py
fetch_results(query_models, retries=20)
Submit request and fetch results from BLAST API.
Wraps individual submission and retrieval of results.
query_models: list of Pydantic models of the queries
retries: the number of maximum retries
str: the result from the BLAST API
Source code in biochatter/api_agent/web/blast.py
BlastInterpreter
Bases: BaseInterpreter
A class for interpreting BLAST results.
Source code in biochatter/api_agent/web/blast.py
summarise_results(question, conversation_factory, response_text)
Extract the answer from the BLAST results.
question (str): The question to be answered.
conversation_factory: A BioChatter conversation object.
response_text (str): The response.text returned by NCBI.
str: The extracted answer from the BLAST results.
Source code in biochatter/api_agent/web/blast.py
BlastQueryBuilder
Bases: BaseQueryBuilder
A class for building a BlastQuery object.
Source code in biochatter/api_agent/web/blast.py
create_runnable(query_parameters, conversation)
Create a runnable object for executing queries.
Creates a runnable using the LangChain
create_structured_output_runnable
method.
query_parameters: A Pydantic data model that specifies the fields of
the API that should be queried.
conversation: A BioChatter conversation object.
A Callable object that can execute the query.
Source code in biochatter/api_agent/web/blast.py
parameterise_query(question, conversation)
Generate a BlastQuery object.
Generates the object based on the given question, prompt, and BioChatter conversation. Uses a Pydantic model to define the API fields. Creates a runnable that can be invoked on LLMs that are qualified to parameterise functions.
question (str): The question to be answered.
conversation: The conversation object used for parameterising the
BlastQuery.
BlastQuery: the parameterised query object (Pydantic model)
Source code in biochatter/api_agent/web/blast.py
BlastQueryParameters
Bases: BaseModel
Pydantic model for the parameters of a BLAST query request.
The class is used for configuring and sending a request to the NCBI BLAST query API. The fields are dynamically configured by the LLM based on the user's question.
Source code in biochatter/api_agent/web/blast.py
OncoKB
OncoKB API agent.
OncoKBFetcher
Bases: BaseFetcher
A class for retrieving API results.
Retrieve from OncoKB given a parameterized OncoKBQuery.
Source code in biochatter/api_agent/web/oncokb.py
fetch_results(request_data, retries=3)
Submit the OncoKB query and fetch the results directly.
No multi-step procedure, thus no wrapping of submission and retrieval in this case.
request_data: List of OncoKBQuery objects (Pydantic models)
containing the OncoKB query parameters.
retries: The number of retries to fetch the results.
str: The results of the OncoKB query.
Source code in biochatter/api_agent/web/oncokb.py
OncoKBInterpreter
Bases: BaseInterpreter
Source code in biochatter/api_agent/web/oncokb.py
summarise_results(question, conversation_factory, response_text)
Extract the answer from the BLAST results.
question (str): The question to be answered.
conversation_factory: A BioChatter conversation object.
response_text (str): The response.text returned by OncoKB.
str: The extracted answer from the BLAST results.
Source code in biochatter/api_agent/web/oncokb.py
OncoKBQueryBuilder
Bases: BaseQueryBuilder
A class for building an OncoKBQuery object.
Source code in biochatter/api_agent/web/oncokb.py
create_runnable(query_parameters, conversation)
Creates a runnable object for executing queries using the LangChain
create_structured_output_runnable
method.
query_parameters: A Pydantic data model that specifies the fields of
the API that should be queried.
conversation: A BioChatter conversation object.
A Callable object that can execute the query.
Source code in biochatter/api_agent/web/oncokb.py
parameterise_query(question, conversation)
Generate an OncoKBQuery object.
Generate based on the given question, prompt, and BioChatter conversation. Uses a Pydantic model to define the API fields. Creates a runnable that can be invoked on LLMs that are qualified to parameterise functions.
question (str): The question to be answered.
conversation: The conversation object used for parameterising the
OncoKBQuery.
OncoKBQueryParameters: the parameterised query object (Pydantic model)
Source code in biochatter/api_agent/web/oncokb.py
bio.tools
Module for interacting with the bio.tools API.
BioToolsFetcher
Bases: BaseFetcher
A class for retrieving API results from BioTools.
Retrieves API results given a parameterized BioToolsQuery.
Source code in biochatter/api_agent/web/bio_tools.py
__init__(api_token='demo')
Initialise the BioToolsFetcher.
api_token: The API token for the BioTools API.
Source code in biochatter/api_agent/web/bio_tools.py
fetch_results(request_data, retries=3)
Submit the BioTools query and fetch the results directly.
No multi-step procedure, thus no wrapping of submission and retrieval in this case.
request_data: List of BioToolsQuery objects (Pydantic models)
containing the BioTools query parameters.
retries: The number of retries to fetch the results.
str: The results of the BioTools query.
Source code in biochatter/api_agent/web/bio_tools.py
BioToolsInterpreter
Bases: BaseInterpreter
A class for interpreting BioTools results.
Source code in biochatter/api_agent/web/bio_tools.py
summarise_results(question, conversation_factory, response_text)
Extract the answer from the BLAST results.
question (str): The question to be answered.
conversation_factory: A BioChatter conversation object.
response_text (str): The response.text returned by bio.tools.
str: The extracted answer from the BLAST results.
Source code in biochatter/api_agent/web/bio_tools.py
BioToolsQueryBuilder
Bases: BaseQueryBuilder
A class for building an BioToolsQuery object.
Source code in biochatter/api_agent/web/bio_tools.py
create_runnable(query_parameters, conversation)
Create a runnable object for executing queries.
Create runnable using the LangChain create_structured_output_runnable
method.
query_parameters: A Pydantic data model that specifies the fields of
the API that should be queried.
conversation: A BioChatter conversation object.
A Callable object that can execute the query.
Source code in biochatter/api_agent/web/bio_tools.py
parameterise_query(question, conversation)
Generate an BioToolsQuery object.
Generate a BioToolsQuery object based on the given question, prompt, and BioChatter conversation. Uses a Pydantic model to define the API fields. Creates a runnable that can be invoked on LLMs that are qualified to parameterise functions.
question (str): The question to be answered.
conversation: The conversation object used for parameterising the
BioToolsQuery.
BioToolsQueryParameters: the parameterised query object (Pydantic
model)
Source code in biochatter/api_agent/web/bio_tools.py
BioToolsQueryParameters
Bases: BaseModel
Parameters for querying the bio.tools API.
Source code in biochatter/api_agent/web/bio_tools.py
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 |
|