Skip to content

Commit

Permalink
Merge pull request #2 from AllenNeuralDynamics/dev
Browse files Browse the repository at this point in the history
added demo ipynb
  • Loading branch information
sreyakumar authored Oct 15, 2024
2 parents a550f53 + 2457dfa commit e3fe075
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 183 deletions.
141 changes: 141 additions & 0 deletions GAMER_workbook.ipynb

Large diffs are not rendered by default.

26 changes: 18 additions & 8 deletions demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,31 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"from metadata_chatbot.agents"
"from metadata_chatbot.agents.gamer import GAMER"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions src/metadata_chatbot/agents/GAMER.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import logging, asyncio

from async_workflow import async_app
from workflow import app
from metadata_chatbot.agents.async_workflow import async_app
from metadata_chatbot.agents.workflow import app


class GAMER(LLM):
Expand Down
155 changes: 0 additions & 155 deletions src/metadata_chatbot/agents/GAMER_workbook.ipynb

This file was deleted.

28 changes: 14 additions & 14 deletions src/metadata_chatbot/agents/async_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
sys.path.append(os.path.abspath("C:/Users/sreya.kumar/Documents/GitHub/metadata-chatbot"))
from metadata_chatbot.utils import ResourceManager

from docdb_retriever import DocDBRetriever
from agentic_graph import datasource_router, db_surveyor, query_grader, filter_generation_chain, doc_grader, rag_chain
from metadata_chatbot.agents.docdb_retriever import DocDBRetriever
from metadata_chatbot.agents.agentic_graph import datasource_router, db_surveyor, query_grader, filter_generation_chain, doc_grader, rag_chain

logging.basicConfig(filename='async_workflow.log', level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', filemode="w")

Expand Down Expand Up @@ -190,18 +190,18 @@ async def generate_async(state):

async_app = async_workflow.compile()

async def main():
query = "What was the age of the subject when receiving injections in asset SmartSPIM_675388_2023-05-24_04-10-19_stitched_2023-05-28_18-07-46?"
inputs = {"query": query}
result = async_app.astream(inputs)
# async def main():
# query = "What was the age of the subject when receiving injections in asset SmartSPIM_675388_2023-05-24_04-10-19_stitched_2023-05-28_18-07-46?"
# inputs = {"query": query}
# result = async_app.astream(inputs)

value = None
async for output in result:
for key, value in output.items():
logging.info(f"Currently on node '{key}':")
# value = None
# async for output in result:
# for key, value in output.items():
# logging.info(f"Currently on node '{key}':")

if value:
print(value['generation'])
# if value:
# print(value['generation'])

# Run the async function
asyncio.run(main())
# # Run the async function
# asyncio.run(main())
8 changes: 4 additions & 4 deletions src/metadata_chatbot/agents/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
sys.path.append(os.path.abspath("C:/Users/sreya.kumar/Documents/GitHub/metadata-chatbot"))
from metadata_chatbot.utils import ResourceManager

from docdb_retriever import DocDBRetriever
from agentic_graph import datasource_router, db_surveyor, query_grader, filter_generation_chain, doc_grader, rag_chain
from metadata_chatbot.agents.docdb_retriever import DocDBRetriever
from metadata_chatbot.agents.agentic_graph import datasource_router, db_surveyor, query_grader, filter_generation_chain, doc_grader, rag_chain

logging.basicConfig(filename='async_workflow.log', level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', filemode="w")

Expand Down Expand Up @@ -183,8 +183,8 @@ def generate(state):
workflow.add_edge("document_grading","generate")
workflow.add_edge("generate", END)

memory = MemorySaver()
app = workflow.compile(checkpointer=memory)

app = workflow.compile()

# query = "How old was the subject in SmartSPIM_675388_2023-05-24_04-10-19_stitched_2023-05-28_18-07-46"

Expand Down

0 comments on commit e3fe075

Please sign in to comment.