Skip to content

Commit

Permalink
[CLEANUP]
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Sep 21, 2024
1 parent 5fd300f commit 12aae2e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
32 changes: 13 additions & 19 deletions medinsight/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class MedInsightMetadataOutput(BaseModel):
time_stamp: str = Field(time_stamp, description=None)



class PubMedQuery(BaseModel):
analysis_of_request: str = Field(
...,
Expand All @@ -61,10 +60,7 @@ class PubMedQuery(BaseModel):
...,
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.",
)
max_articles: int = Field(
...,
description=None
)
max_articles: int = Field(..., description=None)


# Create an instance of the OpenAIChat class with GPT-4
Expand Down Expand Up @@ -138,9 +134,7 @@ def __init__(
# Initialize the metadata history log
# self.metadata_log: List[MedInsightMetadata] = []
self.metadata_log = MedInsightMetadataOutput(
max_loops=max_loops,
logs=[],
task=""
max_loops=max_loops, logs=[], task=""
)

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

def run(self, task: str, *args, **kwargs):
logger.info(f"Running MedInsightPro agent for task: {task}")
status = "success"
# pubmed_data, semantic_scholar_data = {}, {}
combined_summary = ""

analysis = self.precise_query_agent.run(task)
logger.info(f"Pubmed query: {analysis}")

query = analysis["pubmed_query"]
# num_articles = int(analysis["max_articles"])

try:
# Fetch data from PubMed
pubmed_data, pubmed_dict = query_pubmed_with_abstract(
query=query, max_articles=self.max_articles, *args, **kwargs
query=query,
max_articles=self.max_articles,
*args,
**kwargs,
)
print(pubmed_dict)
logger.info(f"PubMed data: {pubmed_data}")
Expand Down Expand Up @@ -205,26 +199,26 @@ def run(self, task: str, *args, **kwargs):

# Log metadata
metadata = MedInsightMetadata(
task = task,
task=task,
query_agent_analysis=analysis,
pubmed_results=pubmed_dict,
combined_summary=combined_summary,
status="success",
time_stamp=time_stamp
time_stamp=time_stamp,
)
self.metadata_log.logs.append(metadata)

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

# return combined_summary

if self.return_json:
return self.metadata_log.model_dump_json()

else:
return combined_summary

# Method to save the metadata log to a JSON file
def save_metadata_log(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "medinsight"
version = "0.0.4"
version = "0.0.5"
description = "MedInsight - Swarms - "
license = "MIT"
authors = ["Kye Gomez <[email protected]>"]
Expand All @@ -22,7 +22,7 @@ classifiers = [
]

[tool.poetry.dependencies]
python = "^3.10"
python = "^3.12"
swarms = "*"
loguru = "*"
pydantic = "*"
Expand Down

0 comments on commit 12aae2e

Please sign in to comment.