File size: 3,292 Bytes
95a3954
 
 
 
 
 
 
 
 
 
 
7dd4554
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95a3954
b12c98b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
---
title: Ontograph
emoji: πŸ’»
colorFrom: red
colorTo: green
sdk: streamlit
sdk_version: 1.41.1
app_file: app.py
pinned: false
---

# 🌟 OntoGraph - Drug Interaction Analysis System

A sophisticated Python-based application that combines ontology reasoning with LLM capabilities to analyze drug interactions, conflicts, and alternatives. The system provides comprehensive analysis through both CLI and web interfaces.
![alt text](img/img.png)

## πŸš€ Key Features

- Dual Interface Options:
  - Web-based interface using Streamlit
  - Command-line interface for direct interaction
- Comprehensive Drug Analysis:
  - Drug interaction detection
  - Conflict identification
  - Similar drug suggestions
  - Alternative medication recommendations
- Advanced Technology Stack:
  - RDF/OWL ontology for knowledge representation
  - Groq LLM integration for natural language processing
  - Agent-based architecture using Langgraph for modular analysis
  - Structured logging system

## πŸ› οΈ Technical Requirements

- Python 3.x
- Groq API key
- Required Python packages:
  - rdflib
  - langchain
  - python-dotenv
  - langchain-community
  - langchain-groq
  - langgraph
  - streamlit

## πŸ“₯ Installation

1. Clone the repository:
```bash
git clone https://github.com/Manithj/onto_graph.git
cd onto_graph
```

2. Install dependencies:
```bash
pip install -r requirements.txt
```

3. Configure environment:
   - Create a `.env` file in the project root
   - Add your Groq API key:
```bash
GROQ_API_KEY=your_api_key_here
```

## πŸ’» Usage

### Web Interface
```bash
streamlit run app.py
```
Navigate to the displayed local URL to access the web interface.

### Command Line Interface
```bash
python appcli.py
```

## πŸ—οΈ Project Structure

```
onto_graph/
β”œβ”€β”€ app.py              # Streamlit web interface
β”œβ”€β”€ appcli.py          # Command line interface
β”œβ”€β”€ agents/            # Agent implementations
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ alternative_agent.py
β”‚   β”œβ”€β”€ base_agent.py
β”‚   β”œβ”€β”€ conflict_agent.py
β”‚   β”œβ”€β”€ interaction_agent.py
β”‚   └── similarity_agent.py
β”œβ”€β”€ analyzers/         # Analysis coordination
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── drug_interaction_analyzer.py
β”œβ”€β”€ ontology/         # Knowledge base
β”‚   └── DrugInteraction.owl
└── requirements.txt  # Project dependencies
```

## πŸ” Features in Detail

### Agent System
- **Base Agent**: Common functionality for ontology queries
- **Alternative Agent**: Identifies alternative medications
- **Similarity Agent**: Finds similar drugs
- **Conflict Agent**: Detects drug conflicts
- **Interaction Agent**: Analyzes drug interactions

### Analysis Pipeline
1. User input processing
2. Ontology querying
3. LLM-powered result synthesis
4. Structured response generation

## 🀝 Contributing

We welcome contributions! Please follow these steps:

1. Fork the repository
2. Create a feature branch
3. Commit your changes
4. Push to your branch
5. Create a Pull Request

## πŸ“ Logging

The system maintains detailed logs in `app.log`, capturing:
- Information level messages
- Warning and error states
- Query execution details
- System state changes

## πŸ“œ License

This project is licensed under the [Apache 2.0](LICENSE).