rishirajbal commited on
Commit
72fda4e
·
verified ·
1 Parent(s): 82768ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -22
app.py CHANGED
@@ -5,10 +5,8 @@ import numpy as np
5
  import requests
6
 
7
  from langchain_groq import ChatGroq
8
- from langchain.agents import initialize_agent
9
  from langchain.prompts import PromptTemplate
10
  from langchain.chains import LLMChain
11
- from langchain.tools import StructuredTool
12
 
13
 
14
  model_path = "unet_model.h5"
@@ -43,31 +41,11 @@ def rishigpt_handler(image_input, groq_api_key):
43
 
44
  mask = classify_image(image_input)
45
 
46
- # The LLM tool just reports a dummy text here for now
47
- def segment_brain_tool():
48
- return "A brain tumor mask was generated."
49
-
50
- tool = StructuredTool.from_function(
51
- segment_brain_tool,
52
- name="segment_brain",
53
- description="Segment brain MRI for tumor detection."
54
- )
55
-
56
  llm = ChatGroq(
57
  model="meta-llama/llama-4-scout-17b-16e-instruct",
58
  temperature=0.3
59
  )
60
 
61
- agent = initialize_agent(
62
- tools=[tool],
63
- llm=llm,
64
- agent="zero-shot-react-description",
65
- verbose=True
66
- )
67
-
68
- user_query = "I uploaded a brain MRI. What does the segmentation say?"
69
- classification = agent.run(user_query)
70
-
71
  prompt = PromptTemplate(
72
  input_variables=["result"],
73
  template="You are a medical imaging expert. Based on the result: {result}, explain what this means for diagnosis."
@@ -78,6 +56,7 @@ def rishigpt_handler(image_input, groq_api_key):
78
  prompt=prompt
79
  )
80
 
 
81
  description = llm_chain.run({"result": classification})
82
 
83
  return mask, description
 
5
  import requests
6
 
7
  from langchain_groq import ChatGroq
 
8
  from langchain.prompts import PromptTemplate
9
  from langchain.chains import LLMChain
 
10
 
11
 
12
  model_path = "unet_model.h5"
 
41
 
42
  mask = classify_image(image_input)
43
 
 
 
 
 
 
 
 
 
 
 
44
  llm = ChatGroq(
45
  model="meta-llama/llama-4-scout-17b-16e-instruct",
46
  temperature=0.3
47
  )
48
 
 
 
 
 
 
 
 
 
 
 
49
  prompt = PromptTemplate(
50
  input_variables=["result"],
51
  template="You are a medical imaging expert. Based on the result: {result}, explain what this means for diagnosis."
 
56
  prompt=prompt
57
  )
58
 
59
+ classification = "The brain tumor mask has been generated and segmentation is complete."
60
  description = llm_chain.run({"result": classification})
61
 
62
  return mask, description