Skip to content

Commit 12aae2e

Browse files
author
Your Name
committed
[CLEANUP]
1 parent 5fd300f commit 12aae2e

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

medinsight/agent.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class MedInsightMetadataOutput(BaseModel):
5151
time_stamp: str = Field(time_stamp, description=None)
5252

5353

54-
5554
class PubMedQuery(BaseModel):
5655
analysis_of_request: str = Field(
5756
...,
@@ -61,10 +60,7 @@ class PubMedQuery(BaseModel):
6160
...,
6261
description="Formulate a precise PubMed query based on the analysis of the request. Ensure the query includes the disease or condition name, relevant keywords, and MeSH terms. Incorporate Boolean operators to enhance search accuracy and retrieve the most pertinent research articles, reviews, and clinical trials.",
6362
)
64-
max_articles: int = Field(
65-
...,
66-
description=None
67-
)
63+
max_articles: int = Field(..., description=None)
6864

6965

7066
# Create an instance of the OpenAIChat class with GPT-4
@@ -138,9 +134,7 @@ def __init__(
138134
# Initialize the metadata history log
139135
# self.metadata_log: List[MedInsightMetadata] = []
140136
self.metadata_log = MedInsightMetadataOutput(
141-
max_loops=max_loops,
142-
logs=[],
143-
task=""
137+
max_loops=max_loops, logs=[], task=""
144138
)
145139

146140
# Function to access Semantic Scholar data
@@ -163,20 +157,20 @@ def fetch_semantic_scholar_data(
163157

164158
def run(self, task: str, *args, **kwargs):
165159
logger.info(f"Running MedInsightPro agent for task: {task}")
166-
status = "success"
167-
# pubmed_data, semantic_scholar_data = {}, {}
168160
combined_summary = ""
169-
161+
170162
analysis = self.precise_query_agent.run(task)
171163
logger.info(f"Pubmed query: {analysis}")
172-
164+
173165
query = analysis["pubmed_query"]
174-
# num_articles = int(analysis["max_articles"])
175166

176167
try:
177168
# Fetch data from PubMed
178169
pubmed_data, pubmed_dict = query_pubmed_with_abstract(
179-
query=query, max_articles=self.max_articles, *args, **kwargs
170+
query=query,
171+
max_articles=self.max_articles,
172+
*args,
173+
**kwargs,
180174
)
181175
print(pubmed_dict)
182176
logger.info(f"PubMed data: {pubmed_data}")
@@ -205,26 +199,26 @@ def run(self, task: str, *args, **kwargs):
205199

206200
# Log metadata
207201
metadata = MedInsightMetadata(
208-
task = task,
202+
task=task,
209203
query_agent_analysis=analysis,
210204
pubmed_results=pubmed_dict,
211205
combined_summary=combined_summary,
212206
status="success",
213-
time_stamp=time_stamp
207+
time_stamp=time_stamp,
214208
)
215209
self.metadata_log.logs.append(metadata)
216210

217211
# Save log to a JSON file
218212
self.save_metadata_log()
219213

220214
# return combined_summary
221-
215+
222216
if self.return_json:
223217
return self.metadata_log.model_dump_json()
224-
218+
225219
else:
226220
return combined_summary
227-
221+
228222
# Method to save the metadata log to a JSON file
229223
def save_metadata_log(self):
230224
"""

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "medinsight"
7-
version = "0.0.4"
7+
version = "0.0.5"
88
description = "MedInsight - Swarms - "
99
license = "MIT"
1010
authors = ["Kye Gomez <[email protected]>"]
@@ -22,7 +22,7 @@ classifiers = [
2222
]
2323

2424
[tool.poetry.dependencies]
25-
python = "^3.10"
25+
python = "^3.12"
2626
swarms = "*"
2727
loguru = "*"
2828
pydantic = "*"

0 commit comments

Comments
 (0)