Spaces:
Sleeping
Sleeping
Commit Β·
96ef1be
1
Parent(s): 875764e
Rename CapyRead to Noah
Browse files- .github/workflows/sync_hf.yml +1 -1
- README.md +6 -6
- agent/evaluations.py +6 -6
- agent/react_agent.py +3 -3
- app.py +2 -2
- run_evaluation.py +4 -4
- services/book_service.py +1 -1
- services/calendar_service.py +2 -2
- services/notion_service.py +1 -1
.github/workflows/sync_hf.yml
CHANGED
|
@@ -17,4 +17,4 @@ jobs:
|
|
| 17 |
- name: Push to hub
|
| 18 |
env:
|
| 19 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 20 |
-
run: git push https://HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/yuki-zmstr/
|
|
|
|
| 17 |
- name: Push to hub
|
| 18 |
env:
|
| 19 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 20 |
+
run: git push https://HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/yuki-zmstr/noah-read main
|
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
emoji: π¬
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: purple
|
|
@@ -7,14 +7,14 @@ sdk: gradio
|
|
| 7 |
sdk_version: 5.29.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
-
short_description:
|
| 11 |
---
|
| 12 |
|
| 13 |
An example chatbot using [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
|
| 14 |
|
| 15 |
-
# π
|
| 16 |
|
| 17 |
-
|
| 18 |
|
| 19 |
## β¨ Features
|
| 20 |
|
|
@@ -40,8 +40,8 @@ CapyRead is an AI-powered reading assistant that helps you discover books, manag
|
|
| 40 |
1. Clone the repo:
|
| 41 |
|
| 42 |
```bash
|
| 43 |
-
git clone https://huggingface.co/spaces/yuki-zmstr/
|
| 44 |
-
cd
|
| 45 |
```
|
| 46 |
|
| 47 |
2. Ensure you have python 3.10 or above installed (3.10 is recommended):
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Noah
|
| 3 |
emoji: π¬
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: purple
|
|
|
|
| 7 |
sdk_version: 5.29.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
short_description: Noah is an AI-powered chatbot that recommends books
|
| 11 |
---
|
| 12 |
|
| 13 |
An example chatbot using [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
|
| 14 |
|
| 15 |
+
# π Noah β Your AI Reading Companion
|
| 16 |
|
| 17 |
+
Noah is an AI-powered reading assistant that helps you discover books, manage your reading schedule, and track your reading journey. It integrates with OpenLibrary for book recommendations, Google Calendar for scheduling, and Notion for note-taking.
|
| 18 |
|
| 19 |
## β¨ Features
|
| 20 |
|
|
|
|
| 40 |
1. Clone the repo:
|
| 41 |
|
| 42 |
```bash
|
| 43 |
+
git clone https://huggingface.co/spaces/yuki-zmstr/noah-read
|
| 44 |
+
cd noah-read
|
| 45 |
```
|
| 46 |
|
| 47 |
2. Ensure you have python 3.10 or above installed (3.10 is recommended):
|
agent/evaluations.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
"""
|
| 2 |
-
Evaluation framework for
|
| 3 |
"""
|
| 4 |
|
| 5 |
import asyncio
|
|
@@ -12,15 +12,15 @@ import logging
|
|
| 12 |
|
| 13 |
logger = logging.getLogger(__name__)
|
| 14 |
|
| 15 |
-
class
|
| 16 |
-
"""Evaluator for
|
| 17 |
|
| 18 |
def __init__(self, langsmith_client: Client):
|
| 19 |
self.client = langsmith_client
|
| 20 |
|
| 21 |
def create_evaluation_dataset(self) -> str:
|
| 22 |
"""Create evaluation dataset with test cases"""
|
| 23 |
-
dataset_name = "
|
| 24 |
|
| 25 |
test_cases = [
|
| 26 |
# Book recommendation tests
|
|
@@ -88,7 +88,7 @@ class CapyReadEvaluator:
|
|
| 88 |
# Create dataset
|
| 89 |
dataset = self.client.create_dataset(
|
| 90 |
dataset_name=dataset_name,
|
| 91 |
-
description="Evaluation dataset for
|
| 92 |
)
|
| 93 |
|
| 94 |
# Add examples to dataset
|
|
@@ -261,7 +261,7 @@ async def run_evaluation(agent, dataset_id: str, langsmith_client: Client) -> Di
|
|
| 261 |
evaluate_response_quality,
|
| 262 |
evaluate_tool_usage
|
| 263 |
],
|
| 264 |
-
experiment_prefix="
|
| 265 |
client=langsmith_client
|
| 266 |
)
|
| 267 |
|
|
|
|
| 1 |
"""
|
| 2 |
+
Evaluation framework for Noah ReAct Agent
|
| 3 |
"""
|
| 4 |
|
| 5 |
import asyncio
|
|
|
|
| 12 |
|
| 13 |
logger = logging.getLogger(__name__)
|
| 14 |
|
| 15 |
+
class NoahEvaluator:
|
| 16 |
+
"""Evaluator for Noah agent performance"""
|
| 17 |
|
| 18 |
def __init__(self, langsmith_client: Client):
|
| 19 |
self.client = langsmith_client
|
| 20 |
|
| 21 |
def create_evaluation_dataset(self) -> str:
|
| 22 |
"""Create evaluation dataset with test cases"""
|
| 23 |
+
dataset_name = "noah-agent-eval"
|
| 24 |
|
| 25 |
test_cases = [
|
| 26 |
# Book recommendation tests
|
|
|
|
| 88 |
# Create dataset
|
| 89 |
dataset = self.client.create_dataset(
|
| 90 |
dataset_name=dataset_name,
|
| 91 |
+
description="Evaluation dataset for Noah ReAct Agent"
|
| 92 |
)
|
| 93 |
|
| 94 |
# Add examples to dataset
|
|
|
|
| 261 |
evaluate_response_quality,
|
| 262 |
evaluate_tool_usage
|
| 263 |
],
|
| 264 |
+
experiment_prefix="noah-agent",
|
| 265 |
client=langsmith_client
|
| 266 |
)
|
| 267 |
|
agent/react_agent.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
"""
|
| 2 |
-
ReAct Agent for
|
| 3 |
1. Recommend books using OpenLibrary
|
| 4 |
2. Schedule reading time in Google Calendar
|
| 5 |
3. Create book reviews in Notion
|
|
@@ -39,7 +39,7 @@ class AgentDecision(BaseModel):
|
|
| 39 |
|
| 40 |
|
| 41 |
class ReActAgent:
|
| 42 |
-
"""ReAct (Reasoning and Acting) Agent for
|
| 43 |
|
| 44 |
def __init__(self):
|
| 45 |
self.llm = ChatOpenAI(model="gpt-4o", temperature=0.1)
|
|
@@ -65,7 +65,7 @@ class ReActAgent:
|
|
| 65 |
|
| 66 |
def _get_system_prompt(self) -> str:
|
| 67 |
"""Get the system prompt for the ReAct agent"""
|
| 68 |
-
return """You are
|
| 69 |
|
| 70 |
You have access to the following tools:
|
| 71 |
1. book_recommendation - Get book recommendations from OpenLibrary
|
|
|
|
| 1 |
"""
|
| 2 |
+
ReAct Agent for Noah - A reasoning and acting agent that can:
|
| 3 |
1. Recommend books using OpenLibrary
|
| 4 |
2. Schedule reading time in Google Calendar
|
| 5 |
3. Create book reviews in Notion
|
|
|
|
| 39 |
|
| 40 |
|
| 41 |
class ReActAgent:
|
| 42 |
+
"""ReAct (Reasoning and Acting) Agent for Noah"""
|
| 43 |
|
| 44 |
def __init__(self):
|
| 45 |
self.llm = ChatOpenAI(model="gpt-4o", temperature=0.1)
|
|
|
|
| 65 |
|
| 66 |
def _get_system_prompt(self) -> str:
|
| 67 |
"""Get the system prompt for the ReAct agent"""
|
| 68 |
+
return """You are Noah, an AI reading assistant that helps users discover books, schedule reading time, and track their reading journey.
|
| 69 |
|
| 70 |
You have access to the following tools:
|
| 71 |
1. book_recommendation - Get book recommendations from OpenLibrary
|
app.py
CHANGED
|
@@ -32,9 +32,9 @@ def process_message(message: str, history: list) -> str:
|
|
| 32 |
# Create the Gradio interface
|
| 33 |
demo = gr.ChatInterface(
|
| 34 |
fn=process_message,
|
| 35 |
-
title="π
|
| 36 |
description="""
|
| 37 |
-
|
| 38 |
|
| 39 |
π **Book Recommendations**: Get personalized book suggestions from OpenLibrary
|
| 40 |
π
**Reading Scheduling**: Schedule reading sessions in your Google Calendar
|
|
|
|
| 32 |
# Create the Gradio interface
|
| 33 |
demo = gr.ChatInterface(
|
| 34 |
fn=process_message,
|
| 35 |
+
title="π Noah - Your AI Reading Assistant",
|
| 36 |
description="""
|
| 37 |
+
Hi, I'm Noah! Your intelligent reading companion powered by a ReAct agent. I can help you:
|
| 38 |
|
| 39 |
π **Book Recommendations**: Get personalized book suggestions from OpenLibrary
|
| 40 |
π
**Reading Scheduling**: Schedule reading sessions in your Google Calendar
|
run_evaluation.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
-
Run evaluation on the
|
| 4 |
"""
|
| 5 |
|
| 6 |
import asyncio
|
|
@@ -9,20 +9,20 @@ import json
|
|
| 9 |
from dotenv import load_dotenv
|
| 10 |
from langsmith import Client
|
| 11 |
from agent.react_agent import ReActAgent
|
| 12 |
-
from agent.evaluations import
|
| 13 |
|
| 14 |
# Load environment variables
|
| 15 |
load_dotenv()
|
| 16 |
|
| 17 |
async def main():
|
| 18 |
"""Main evaluation runner"""
|
| 19 |
-
print("π§ͺ Starting
|
| 20 |
|
| 21 |
# Initialize LangSmith client
|
| 22 |
langsmith_client = Client()
|
| 23 |
|
| 24 |
# Initialize evaluator
|
| 25 |
-
evaluator =
|
| 26 |
|
| 27 |
# Create evaluation dataset
|
| 28 |
print("π Creating evaluation dataset...")
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
+
Run evaluation on the Noah ReAct Agent
|
| 4 |
"""
|
| 5 |
|
| 6 |
import asyncio
|
|
|
|
| 9 |
from dotenv import load_dotenv
|
| 10 |
from langsmith import Client
|
| 11 |
from agent.react_agent import ReActAgent
|
| 12 |
+
from agent.evaluations import NoahEvaluator, run_evaluation, analyze_evaluation_results
|
| 13 |
|
| 14 |
# Load environment variables
|
| 15 |
load_dotenv()
|
| 16 |
|
| 17 |
async def main():
|
| 18 |
"""Main evaluation runner"""
|
| 19 |
+
print("π§ͺ Starting Noah Agent Evaluation...")
|
| 20 |
|
| 21 |
# Initialize LangSmith client
|
| 22 |
langsmith_client = Client()
|
| 23 |
|
| 24 |
# Initialize evaluator
|
| 25 |
+
evaluator = NoahEvaluator(langsmith_client)
|
| 26 |
|
| 27 |
# Create evaluation dataset
|
| 28 |
print("π Creating evaluation dataset...")
|
services/book_service.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
"""
|
| 2 |
-
Book Service for
|
| 3 |
"""
|
| 4 |
|
| 5 |
import requests
|
|
|
|
| 1 |
"""
|
| 2 |
+
Book Service for Noah - Handles book recommendations using OpenLibrary API
|
| 3 |
"""
|
| 4 |
|
| 5 |
import requests
|
services/calendar_service.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
"""
|
| 2 |
-
Calendar Service for
|
| 3 |
"""
|
| 4 |
|
| 5 |
import os
|
|
@@ -210,7 +210,7 @@ class CalendarService:
|
|
| 210 |
'summary': f"π Reading: {book_title}",
|
| 211 |
'description': f"Reading session for '{book_title}'\n\n"
|
| 212 |
f"Duration: {duration_minutes} minutes\n"
|
| 213 |
-
f"Scheduled via
|
| 214 |
'start': {
|
| 215 |
'dateTime': start_time.isoformat(),
|
| 216 |
'timeZone': self.timezone,
|
|
|
|
| 1 |
"""
|
| 2 |
+
Calendar Service for Noah - Handles Google Calendar integration for scheduling reading sessions
|
| 3 |
"""
|
| 4 |
|
| 5 |
import os
|
|
|
|
| 210 |
'summary': f"π Reading: {book_title}",
|
| 211 |
'description': f"Reading session for '{book_title}'\n\n"
|
| 212 |
f"Duration: {duration_minutes} minutes\n"
|
| 213 |
+
f"Scheduled via Noah AI Assistant",
|
| 214 |
'start': {
|
| 215 |
'dateTime': start_time.isoformat(),
|
| 216 |
'timeZone': self.timezone,
|
services/notion_service.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
"""
|
| 2 |
-
Notion Service for
|
| 3 |
"""
|
| 4 |
|
| 5 |
import os
|
|
|
|
| 1 |
"""
|
| 2 |
+
Notion Service for Noah - Handles Notion integration for book reviews and notes
|
| 3 |
"""
|
| 4 |
|
| 5 |
import os
|