Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(integration): DEMO- NCERT-Tutor Agent Integration #340

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 161 additions & 0 deletions integrations/NCERT-Tutor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
*.pdf
22 changes: 22 additions & 0 deletions integrations/NCERT-Tutor/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Use Python 3.9 to install poetry and export requirements, since poetry itself is compatible with this version.
FROM python:3.9 as requirements-stage
WORKDIR /tmp
RUN pip install poetry
# Copy pyproject.toml and poetry.lock (if exists) into the temporary image
COPY ./pyproject.toml ./poetry.lock* /tmp/
# Export the project dependencies to a requirements.txt file
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes

# Now, switch to the Python 3.11 image for the final stage, as specified in your pyproject.toml
FROM python:3.11
WORKDIR /code
# Copy the requirements.txt from the previous stage
COPY --from=requirements-stage /tmp/requirements.txt /code/requirements.txt
# Install dependencies from the requirements.txt file without caching to keep the image small
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
# Copy your application code into the image
COPY ./src/agents/utils /code/

# Specify the command to run your FastAPI application using Uvicorn
# Given the project structure, adjust the Uvicorn command to reflect the correct path to main.py
CMD ["uvicorn", "ncert:app", "--proxy-headers", "--host", "0.0.0.0", "--port", "8080", "--reload"]
143 changes: 143 additions & 0 deletions integrations/NCERT-Tutor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Incognito Tab - Goa College of Engineering NCERT Tutor Video Demo

### You can watch a video demo of our project: [demo video](https://drive.google.com/drive/folders/175eGJjyQfFjJ36Qk0ACPx_CXWFQbdVnE?usp=drive_link)
- delta v compatible demo [here](https://github.com/fetchai/uAgents/pull/342)

## Vision of our project
- To simplify and improve learning attitude and aptitude
- To reach many students with all the help ncessary to ace thier exams
- To simplify and have the tedious tasks of memorizing and concept revision done easy with autonomous agents.

## Future scopes of your project
- To create a more conversational and seamless experience by allowing the user to ask further questions about the chapter and get those included in the notes aswell by implementing the experimental [Dialogue module](https://github.com/Quantaindew/uAgents/blob/main/integrations/fetch-ai-engine/src/ai_engine/chitchat.py)
- To implement an additional feature that lets the user also practice questions with the help of flashcards , this will be an interactive experience for the user to retain concepts and revise quicker .





## Project Information

### Abstract
Our project, NCERT Tutor, is designed to simplify the learning process by providing a personalized tutoring experience. It asks the user for their class, subject, and chapter they want to learn or have a doubt in, then fetches the corresponding chapter PDF from the NCERT website, summarizes the content, and creates notes along with important questions through a seamless interaction enabled via delta v. The agents in our project deployed on Agentverse is fully operational through Delta V.


### Agents used in our Project
- **Interact Agent**
- The first pillar and the initiator of the entire sequence of the workflow based on the user input done through delta v.
- Knows the preferences of the user based on previous interactions with agents
- Aims to maximize the educational value of the user while also providing the best options towards user query
``question.py``
- **NCERT Content Fetcher** (locally via mailbox)
- The second pillar runs locally by utilising fetch ai's mailbox feature and fetches the knowledge necessary in the form of chapter PDF from the NCERT website database based on user input if the PDF is already cached locally it uses that directly .
``ncertagent.py``
- **Content Summarizer**(locally via mailbox)
- The third pillar also runs locally via mailrbox . This summarizes the fetched content to provide a concise overview.
- This agent also provides the user with the entire analysis of the chapter, and provides questions bank with answer set in a pretty format via a cloudinary link which the user can use to download the file
``openai.py``
- **Conclusive agent**
- The final pillar of our command chain who completes the entire flow by giving the user the final content and the link to download the notes thus concluding the pursuits of user with a fulfilling end to end experience.
``end.py``

### Sample Flow of our NCERT Tutor
1. User inputs their class, subject, and chapter.
2. User Agent captures the input and calls the NCERT Content Fetcher to retrieve the chapter PDF.
3. NCERT Content Fetcher fetches the PDF and passes it to the Content Summarizer.
4. Content Summarizer summarizes the content also creates the notes in a pretty format for the user and provides a dynamic sharable link to download the content and passes it to the Ending Agent.
5. Ending Agent displays the sharable link to the notes along with the content to the user thus completing the end to end user experience .

## Content of PPt:
attached ppt [here](https://drive.google.com/file/d/1WZ_CiAbCPbJSSWeq6VmxXqZURk6ZH0Xh/view?usp=sharing)



## Technology Stack
- Python
- Fetch.ai
- uAgent Library
- Agentverse
- Mailroom
- Delta v

## Getting Started

### Installation
1. Clone the repository:

```
git clone https://github.com/Quantaindew/NCERT-Tutor.git
```

2. Install the required dependencies:
```
cd NCERT-Tutor
```

3.Initialize the environment:

```
poetry install
poetry shell
```
4.Run the backend server
```
cd src/agents/utils
uvicorn ncert:app --reload
```
5.Running the ecosystem of the agent :



```
cd src/uagents/ncert
poetry shell
python ncertagent.py
```




###
Reminder: the openai agent requires a gpt4 api key which needs to be put into the .env file in the same directory as the agent (you will find a .env-template file)
###

```
cd src/uagents/openai
poetry shell
python openai.py
```

```
cd src/uagents/ending
poetry shell
python end.py
```
```
cd src/uagents/conversation
poetry shell
python question.py
```
reminder: for the conversation agent demo to run locally , you will need to uncomment the hardcoded query 👇
``` python
@agent.on_event("startup")
async def startup(ctx: Context):
ctx.logger.info("Question System Agent Started")
ctx.logger.info(f"{agent.address}")

##Local Testing code snippet, uncomment the code below to run locally
#intentionally added typo to test levenshtien distance algorithm
chapter_name = "alice in wonland"
chapter_num = find_chapter_number(chapter_name)
standard = 4
ctx.logger.info(f"Chapter Name : {chapter_name}, Chapter number: {chapter_num}, standard: {standard}")

#await ctx.send("agent1qvwqu6a0km09mq4f6j6kmke9smswmgcergmml9a54av9449rqtmmxy4qwe6", Question(question = f"Can you provide a summary of the chapter {chapter_name} from standard {standard} English?", chapter = chapter_num, subject = "english", standard = standard, sender = agent.address))

# uncomment this ☝️ query to run the demo locally.

```




Run the above commands in order in different terminals
Loading
Loading