Skip to content

Commit 0e6e2fb

Browse files
authored
missing re import (#12)
1 parent 9dd64b7 commit 0e6e2fb

8 files changed

Lines changed: 708 additions & 38 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,4 @@ packages/crow-integration-tests/errors/
146146

147147

148148
# Other
149-
./CLAUDE.md
149+
./CLAUDE.md

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ repos:
4040
rev: v0.24.2
4141
hooks:
4242
- id: toml-sort-fix
43+
exclude: ^uv\.lock$
4344
- repo: https://github.com/crate-ci/typos
4445
rev: v1.30.3
4546
hooks:

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ See our [blog](https://www.futurehouse.org/research-announcements/demonstrating-
66

77
- **Python:** Version 3.12 or higher.
88
- **API Keys:**
9-
- `EDISON_API_KEY`: For accessing Edison platform agents (Crow, Falcon - now called 'Literature'). Obtain from https://platform.edisonscientific.com/profile. You must first create an Edison profile, purchase credits and then create an API key (Account -> Profile -> API Tokens).
9+
- `EDISON_API_KEY`: For accessing Edison platform agents (Crow, Falcon - now called 'Literature'). Obtain from https://platform.edisonscientific.com/profile. You must first create an Edison profile, purchase credits and then create an API key (Account -> Profile -> API Tokens).
1010
- An API key for your chosen LLM provider (e.g., `OPENAI_API_KEY` if using OpenAI models). Robin uses LiteLLM, so it can support various providers.
1111
- The data analysis portion of this repo requires access to the Edison platform. Without access, all the hypothesis and experiment generation code can still be run.
1212

@@ -19,15 +19,18 @@ Docker is a tool that packages software into a self-contained "container" that r
1919
For a fully self-contained environment that avoids OS-level dependency conflicts, Docker is the recommended approach:
2020

2121
1. **Build the image:**
22+
2223
```bash
2324
docker build -t robin .
2425
```
2526

2627
2. **Set up API keys:**
28+
2729
```bash
2830
cp .env.example .env
2931
# Edit .env and fill in your EDISON_API_KEY and OPENAI_API_KEY
3032
```
33+
3134
Important: do **not** wrap values in quotes (e.g. `OPENAI_API_KEY=sk-abc123`, not `OPENAI_API_KEY="sk-abc123"`). Docker reads the file differently from Python and will include the quotes as part of the key.
3235

3336
3. **Run Jupyter:**
@@ -159,6 +162,6 @@ These example outputs are provided to help users to understand the depth, format
159162

160163
## Advanced Usage
161164

162-
A full example trajectory of both the initial therapeutic candidate generation and experimental data analysis can be found in the `robin_full.ipynb` notebook. This notebook includes the parameters and agents used in the paper.
165+
A full example trajectory of both the initial therapeutic candidate generation and experimental data analysis can be found in the `robin_full.ipynb` notebook. This notebook includes the parameters and agents used in the paper.
163166

164167
While this guide focuses on the `robin_demo.ipynb` notebook, the `robin` Python module (in the `robin/` directory) can be imported and its functions (`experimental_assay`, `therapeutic_candidates`, `data_analysis`) can be used programmatically in your own Python scripts for more customized workflows.

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ dependencies = [
2121
"aiofiles",
2222
"anthropic",
2323
"choix",
24+
"edison-client>=0.11",
2425
"fhaviary",
2526
"fhlmi",
26-
"edison-client>=0.11",
27-
"openai>=1",
28-
"pandas>=2",
29-
"pydantic>=2",
27+
"openai>=1",
28+
"pandas>=2",
29+
"pydantic>=2",
3030
"python-dotenv",
3131
"tqdm",
3232
]

robin/assays.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import logging
3+
import re
34
from pathlib import Path
45
from typing import cast
56

@@ -113,15 +114,17 @@ async def experimental_assay(configuration: RobinConfiguration) -> str | None:
113114

114115
response_text = cast(str, experimental_assay_ideas.text)
115116
if not response_text.strip():
116-
raise ValueError("LLM returned an empty response during assay proposal generation.")
117+
raise ValueError(
118+
"LLM returned an empty response during assay proposal generation."
119+
)
117120
try:
118121
assay_idea_json = json.loads(response_text)
119-
except json.JSONDecodeError:
122+
except json.JSONDecodeError as err:
120123
match = re.search(r"\[.*\]", response_text, re.DOTALL)
121124
if not match:
122125
raise ValueError(
123126
f"LLM response did not contain a JSON array. Response: {response_text[:200]}"
124-
)
127+
) from err
125128
assay_idea_json = json.loads(match.group())
126129
assay_idea_list = format_assay_ideas(assay_idea_json)
127130

robin/configuration.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
import os
33
import re
44
from datetime import datetime
5+
from typing import Any
56

67
from dotenv import load_dotenv
78
from edison_client import EdisonClient, JobNames
89
from lmi import LiteLLMModel
910
from pydantic import BaseModel, Field, PrivateAttr, model_validator
1011

11-
load_dotenv()
12-
1312
from .prompts import (
1413
ANALYSIS_QUERIES,
1514
ASSAY_HYPOTHESIS_FORMAT,
@@ -44,6 +43,8 @@
4443
SYNTHESIZE_USER_CONTENT,
4544
)
4645

46+
load_dotenv()
47+
4748
_DEFAULT_LLM_CONFIG_DATA = {
4849
"model_list": [
4950
{
@@ -58,9 +59,9 @@
5859
}
5960

6061

61-
def get_default_llm_config():
62+
def get_default_llm_config() -> dict[str, Any]:
6263
# Key is read on each instantiation so env vars set after import are picked up.
63-
data = copy.deepcopy(_DEFAULT_LLM_CONFIG_DATA)
64+
data: dict[str, Any] = copy.deepcopy(_DEFAULT_LLM_CONFIG_DATA)
6465
data["model_list"][0]["litellm_params"]["api_key"] = os.getenv(
6566
"OPENAI_API_KEY", "insert_openai_key_here"
6667
)

robin/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ def parse_custom_tuple_string(s): # noqa: PLR0911
558558
game_scores.append(None)
559559
else:
560560
game_scores.append(None)
561-
processed_ranking_results["Game Score"] = game_scores
561+
processed_ranking_results["Game Score"] = cast(Any, game_scores)
562562

563563
processed_ranking_results = processed_ranking_results.dropna(subset=["Game Score"])
564564

0 commit comments

Comments
 (0)