xonecas.io
53129
Pa

PAT / commit 7bb5408

feat: initial commit

xonecas2025-12-15 7bb5408f8964a4622b5273249026cfffd68ebcca

18 files changed

This diff is too big to show in full. The first 1000 lines are below, and every file is listed with its counts.

.gitignore+3−0
@@ -0,0 +1,3 @@
1+node_modules
2+.next
3+.env
AGENTS.md+10−0
@@ -0,0 +1,10 @@
1+# AGENTS.md
2+
3+This is a personal assistant project, that renders a simple assistant chat layout as a web page, and provides access to an agentic model running locally via ollama. The project uses Next.js for it's typescript framework TailwindCSS for it's styling, and Ollama's typescript/javascript library itself for querying the model. This project is also responsible for augmenting the model's prompt with search results from DuckDuckGo.
4+
5+## Dependencies
6+
7+- **DuckDuckGo Instant Answer API** | Unlimited (no key) | Very lightweight; returns JSON with snippets for most queries. | <https://api.duckduckgo.com/api>
8+- **Ollama** | locally or via an API, running your model of choice (gpt-oss is a good starter) | <https://ollama.com>
9+- **Next.js** | typescript framework for the web UI/server | <https://nextjs.org/docs>
10+- **TailwindCSS** | UI styling | <https://tailwindcss.com/>
TODO.md+15−0
@@ -0,0 +1,15 @@
1+# TODO:
2+
3+## Must haves:
4+
5+- The agent's reply UI needs to be as wide as it can in the browser window, and handle markdown and code snippets correctly
6+- When a message is sent to the agent, the text in the message box should be cleared.
7+- The up and down arrows when focused on the chatbox should bring up past sent messages in chronological order.
8+- The title at the top is not necessary.
9+- The UI closely resembles Google's material UI, let's make it more rounded and use a hotter color (instead of the blue seen on the buttons)
10+- The UI needs to support both dark and light modes.
11+
12+## New features:
13+
14+- Text input, we should be able to press a button and record a prompt.
15+- Text to voice, we should have a button to have the models replies be read with text to voice.
_planning/search-api-wrapper.md+214−0
@@ -0,0 +1,214 @@
1+>>> Are there open source and free search apis already?
2+Thinking...
3+The user asks if there are open source and free search APIs. We should explain options: free tiers of APIs, open-source search engines
4+like Vespa, Meilisearch, ElasticSearch (open source but not free for cloud), open-source web crawling like Scrapy, or open-source
5+semantic search like Qdrant. Also mention free tier APIs like DuckDuckGo Instant Answer API, BGG, maybe search APIs that are open
6+source: Bing API is not open source. There are open-source search APIs like OpenSearch, Algolia free tier. Or mention using Google
7+Custom Search has free quota. The answer should provide a listc, pros/cons, links. Also mention how to integrate. Let's provide
8+suggestions:
9+
10+- DuckDuckGo Instant Answer API – free, no key.
11+- Google Custom Search JSON API – free for 100 queries/day.
12+- Bing Search API – free tier 1000 queries/day maybe? Not sure, but there's free tier.
13+- OpenSearch server from Amazon but you can host locally; not an API provider but you can run locally.
14+
15+- Open-source search backends: Meilisearch (full text search, simple API), Typesense, ElasticSearch (open source but licensing). These
16+are not "search APIs" for web content but for your own index.
17+
18+- There are open-source web crawling and indexing solutions: Scrapy + Whoosh, or Apache Nutch.
19+
20+- For semantic search: Qdrant.
21+
22+Also mention that some "search APIs" are not open source but have free tiers.
23+
24+We should respond with helpful explanation and references. Also ask if they want to search the web or internal indexing. Provide code
25+snippets. Let's craft answer.
26+...done thinking.
27+
28+### TL;DR
29+| What you want | Is it free? | Open‑source? | Quick‑start |
30+|---------------|-------------|--------------|-------------|
31+| **"Search the web" with a public API** | Yes (free tiers, but usually limited) | No | DuckDuckGo Instant Answer API, Google CSE (100/day), Bing (free quota), SerpAPI (free 10/day) |
32+| **"Run your own search engine" (index your own data)** | Yes (self‑hosted) | Yes | Meilisearch, Typesense, Elasticsearch (OSS), Qdrant, Vespa |
33+| **"Build a crawler + indexer"** | Yes (self‑hosted) | Yes | Scrapy + Whoosh, Apache Nutch, ElasticSearch + Logstash |
34+
35+Below I walk you through each category, give you concrete links, and show a tiny snippet that lets you plug the free service into the
36+same “search‑then‑prompt” pattern we discussed earlier.
37+
38+---
39+
40+## 1️⃣ Search the Web with a Free Public API
41+
42+| Provider | Free Tier | Notes | Docs |
43+|----------|-----------|-------|------|
44+| **DuckDuckGo Instant Answer API** | Unlimited (no key) | Very lightweight; returns JSON with snippets for most queries. | <https://api.duckduckgo.com/api> |
45+| **Google Custom Search JSON API** | 100 queries/day (free) | Requires a "Custom Search Engine" (CSE) ID. | <https://developers.google.com/custom-search/v1/overview> |
46+| **Bing Search v7** | 1000 queries/day for a *trial* (Azure) | Requires Azure subscription; after the trial you pay. | <https://learn.microsoft.com/en-us/azure/cognitive-services/bing-web-search> |
47+| **SerpAPI** | 10 requests/day free | Supports Google, Bing, DuckDuckGo, etc. | <https://serpapi.com> |
48+
49+> **Tip:** DuckDuckGo is the easiest to get started with because it needs *no* API key.
50+
51+### Example: DuckDuckGo Wrapper (Python)
52+
53+```python
54+import os
55+import requests
56+
57+def duckduckgo_search(query: str, max_results: int = 5):
58+ """Return a list of {'title', 'snippet', 'url'}."""
59+ params = {
60+ "q": query,
61+ "format": "json",
62+ "no_redirect": 1,
63+ "no_html": 1,
64+ "skip_disambig": 1,
65+ }
66+ r = requests.get("https://api.duckduckgo.com/", params=params, timeout=10)
67+ r.raise_for_status()
68+ data = r.json()
69+
70+ results = []
71+ for i, result in enumerate(data.get("RelatedTopics", [])[:max_results]):
72+ if "Text" in result:
73+ results.append({
74+ "title": result.get("Text")[:70], # shorten title
75+ "snippet": result.get("Text", ""),
76+ "url": result.get("FirstURL", ""),
77+ })
78+ return results
79+```
80+
81+> *Feel free to swap this into the `bing_search()` wrapper from the previous message.*
82+
83+---
84+
85+## 2️⃣ Run Your Own Search Engine (Self‑Hosted)
86+
87+If you want to index your own documents (PDFs, code, knowledge base, etc.) you can run an open‑source engine locally or in your own
88+cloud.
89+
90+| Engine | Language | API | Features | License |
91+|--------|----------|-----|----------|---------|
92+| **Meilisearch** | Rust (API in JSON) | Simple REST, WebSocket for re‑indexing | Full‑text, typo‑tolerance, facet filtering, zero‑config | MIT |
93+| **Typesense** | Rust | REST, gRPC | Near‑real‑time, typo‑tolerance, filtering, analytics | Apache 2.0 |
94+| **Elasticsearch OSS** | Java | REST, Elasticsearch DSL | Powerful full‑text, Kibana, aggregations, near‑real‑time | Apache 2.0 (OSS edition) |
95+| **Qdrant** | Rust | REST, gRPC | Vector search (semantic), filtering | Apache 2.0 |
96+| **Vespa** | Java | REST + Vespa‑QL | Big data search & analytics, scalable | Apache 2.0 |
97+
98+> **Quick‑setup** – Meilisearch is probably the easiest to spin up with Docker or directly from the binary.
99+
100+```bash
101+# Docker
102+docker run -it --rm -p 7700:7700 \
103+ -e MEILI_MASTER_KEY=masterKey \
104+ getmeili/meilisearch:v1.4
105+```
106+
107+Once it’s running you can query it exactly like any other search API:
108+
109+```python
110+def meilisearch_query(q, limit=10):
111+ r = requests.get(
112+ "http://localhost:7700/search",
113+ params={"q": q, "limit": limit},
114+ headers={"Authorization": "Bearer masterKey"},
115+ timeout=10
116+ )
117+ return r.json() # contains hits[], total, etc.
118+```
119+
120+> **Use‑case:** Index your code base, knowledge base, or product docs; let your GPT‑style assistant read that index for “up‑to‑date”
121+answers *within your own data*.
122+
123+---
124+
125+## 3️⃣ Build a Crawler + Indexer (Open Source)
126+
127+Sometimes you want *both* crawling the web and indexing it yourself. The community has a few great stacks:
128+
129+| Stack | What it does | How to get started | Link |
130+|-------|--------------|--------------------|------|
131+| **Scrapy + Whoosh** | Crawl pages → index in Whoosh | Python‑only, great for small sites | <https://scrapy.org>, <https://whoosh.readthedocs.io> |
132+| **Apache Nutch** | Handles large‑scale crawling & indexing | Apache Hadoop integration | <https://nutch.apache.org> |
133+| **Elastic + Logstash** | Crawl with Scrapy → Logstash → Elasticsearch | Full pipeline | <https://www.elastic.co/what-is/elastic-stack> |
134+
135+> If you need a quick prototype, just `pip install scrapy` and start a crawler; the output can feed into Meilisearch or Typesense.
136+
137+---
138+
139+## 3️⃣ Which Path Should You Pick?
140+
141+| Scenario | Recommendation |
142+|----------|----------------|
143+| **You only need "answers from the public web"** | Start with DuckDuckGo. Add a simple wrapper and you're done. |
144+| **You need to respect a strict free‑quota policy** | Use Google CSE (100/day) or SerpAPI (10/day). If you hit the quota, consider DuckDuckGo + a local cache. |
145+| **You want to index internal docs** | Meilisearch (zero‑config, typo‑tolerance) is the quickest. |
146+| **You need enterprise‑grade analytics or distributed indexing** | ElasticSearch OSS + Kibana or Vespa. |
147+| **You want vector‑search / semantic search** | Qdrant or Typesense + custom embeddings. |
148+
149+---
150+
151+## 4️⃣ Plugging a Free/OSS Search API into GPT‑Prompting
152+
153+Below is a *minimal* full‑stack example that works with **DuckDuckGo** (free, no key) and shows how to use it inside a prompt for a
154+GPT‑style assistant.
155+
156+```python
157+import json
158+import requests
159+
160+# 1️⃣ DuckDuckGo wrapper (you can also use the above `duckduckgo_search` function)
161+def search_web(query: str):
162+ return duckduckgo_search(query, max_results=5)
163+
164+# 2️⃣ Build a prompt that includes results
165+def gpt_prompt_with_web_results(question: str):
166+ results = search_web(question)
167+ # format results as a simple string
168+ results_text = "\n".join(
169+ f"{i+1}. {r['title']}\n {r['snippet']}\n {r['url']}"
170+ for i, r in enumerate(results)
171+ )
172+ prompt = f"""I need up‑to‑date information to answer the following question:
173+
174+**Question:** {question}
175+
176+**Web results** (first 5, if any):
177+{results_text}
178+
179+Please provide a concise, accurate answer."""
180+
181+ # 3️⃣ Ask GPT (use the same wrapper you used before)
182+ openai_response = client.chat.completions.create(
183+ model="gpt-4o-mini",
184+ messages=[{"role":"user","content":prompt}],
185+ temperature=0.2,
186+ )
187+ return openai_response.choices[0].message.content.strip()
188+```
189+
190+> Just call `gpt_prompt_with_web_results("What is the latest on climate policy in the EU?")`.
191+
192+---
193+
194+## 5️⃣ Staying Within the Free‑Tier Limits
195+
196+| What to Watch | How to Implement |
197+|---------------|-----------------|
198+| **Rate‑limit headers** | `requests` can read them (e.g., `X-Search-Quota-Remaining`). Implement exponential back‑off on 429 responses. |
199+| **Cache** | `functools.lru_cache` or a simple `dict` with expiry. Avoid hitting the API twice for the same query. |
200+| **Batching** | If you need several queries at once, queue them and use `asyncio.gather`. |
201+
202+---
203+
204+## Bottom Line
205+
206+- **If you only need “search the web”**: DuckDuckGo is free and requires no key; Google CSE gives you a small free quota; Bing & SerpAPI
207+are alternatives with slightly higher limits but do need keys.
208+- **If you want full control**: Meilisearch or Typesense let you run a tiny, production‑ready search engine on a single laptop or a
209+private VM.
210+- **If you need deep crawling & indexing**: Scrapy + Whoosh or ElasticSearch + Logstash give you the classic “crawl‑index‑search”
211+pipeline.
212+
213+Pick the one that fits your *data source* (public web vs. your own documents) and *budget* (unlimited free key vs. limited free tier).
214+If you need help writing the exact wrapper for the service you choose, just tell me which one and I’ll add the code. Happy searching! 🚀
_planning/search.md+239−0
@@ -0,0 +1,239 @@
1+>>> I'd like to give you web search capabilities, so you can always get the latest and greatest
2+Thinking...
3+The user wants to give web search capabilities. They want to be able to get latest info. They are asking how to do that. So we need to
4+explain that GPT can't browse by default; but we can integrate external search APIs or use a tool like SerpAPI, Bing Search API, or use
5+custom code to fetch results and feed to me. We should explain steps: choose a search API, write wrapper, feed results to me as context.
6+Also can use plugin or chain of tools approach: build a tool that takes query, returns results, then feed to the model. We need to
7+explain how to do it in different contexts: for example, in local deployment, you can create a wrapper that calls the search API, then
8+provide the results to the model. Also mention safety, privacy, cost. Provide example code in Python, maybe using LangChain, or just
9+plain request. Provide an example with OpenAI API call and a function. Provide also mention that the model can be used in a tool‑chain
10+environment. Also note that this is a separate step. Provide step-by-step instructions. Also mention that you can use search plugins.
11+Provide an example of a function call. Also ask for specifics: what platform? Are they using openai? Provide guidance.
12+
13+Let's produce a thorough answer.
14+...done thinking.
15+
16+### Quick answer
17+**You can’t give me “live‑web browsing” inside the model itself,** but you can let your application fetch the information you need (via
18+an API, a web‑scraper, or a search‑engine provider) and then feed that text into the model as part of the conversation.
19+
20+Below is a “tool‑chain” pattern that works with a locally‑hosted model (or the OpenAI API) and any search‑engine API you choose. It
21+covers everything you need:
22+
23+| Step | What you need | Example tools / code |
24+|------|---------------|----------------------|
25+| 1️⃣ | Choose a search source | • **Bing Search API** (Azure) <br>• **SerpAPI** <br>• **Google Custom Search JSON API** <br>• Your
26+own crawler (`requests`, `beautifulsoup`, `scrapy`) |
27+| 2️⃣ | Write a small wrapper that returns plain‑text or JSON | Python `requests` function |
28+| 3️⃣ | Feed the search results into the LLM as context | • Add to the prompt (`"Here are the latest results …"`) <br>• Or use a *tool*
29+that the model calls via function‑calling / LangChain |
30+| 4️⃣ | (Optional) Cache / dedupe results | Store a cache of queries & snippets to avoid repeated API calls |
31+| 5️⃣ | Handle privacy / usage limits | Keep API keys secret, monitor quota, obey TOS |
32+
33+Below is a **minimal end‑to‑end example** that uses:
34+
35+* Python 3.10+
36+* `requests` to call **Bing Search API** (you can swap the API later)
37+* The **OpenAI** Python SDK (or your own local model call)
38+* LangChain‑style tool‑calling (optional)
39+
40+> **NOTE:** If you’re running a local model (e.g., GPT‑4‑Base via `vllm`), just skip the OpenAI SDK part and call your local inference
41+function instead.
42+
43+---
44+
45+## 1️⃣ Pick a Search API
46+
47+| API | Cost | Key features |
48+|-----|------|--------------|
49+| **Bing Search v7** (Azure) | Pay‑per‑request ($0.0015 / 10 queries) | Structured JSON, image, news, etc. |
50+| **SerpAPI** | $2.5–$5 / 100 queries | Google, Bing, DuckDuckGo, etc. |
51+| **Google Custom Search JSON API** | $5 / 100 queries | Google‑indexed content |
52+| **Custom crawler** | Free (your compute) | Full control, no quotas |
53+
54+> **Tip:** If you only need quick news headlines, Bing or SerpAPI are the simplest to set up.
55+
56+---
57+
58+## 2️⃣ Wrapper to Get Search Results
59+
60+```python
61+import os
62+import json
63+import requests
64+from typing import List
65+
66+# ---- Configuration ----
67+BING_ENDPOINT = "https://api.bing.microsoft.com/v7.0/search"
68+BING_API_KEY = os.getenv("BING_API_KEY") # <-- set this
69+
70+def bing_search(query: str, count: int = 5, **kwargs) -> List[dict]:
71+ """
72+ Simple wrapper around Bing Search API.
73+ Returns a list of dicts: {"title": ..., "snippet": ..., "url": ...}
74+ """
75+ params = {
76+ "q": query,
77+ "count": count,
78+ "textDecorations": "false",
79+ "textFormat": "raw",
80+ **kwargs,
81+ }
82+ headers = {"Ocp-Apim-Subscription-Key": BING_API_KEY}
83+ resp = requests.get(BING_ENDPOINT, headers=headers, params=params, timeout=10)
84+ resp.raise_for_status()
85+ data = resp.json()
86+
87+ results = []
88+ for item in data.get("webPages", {}).get("value", []):
89+ results.append({
90+ "title": item.get("name"),
91+ "snippet": item.get("snippet"),
92+ "url": item.get("url"),
93+ })
94+ return results
95+```
96+
97+*Replace `BING_API_KEY` with your own key (or the key for whatever API you choose).*
98+
99+---
100+
101+## 3️⃣ Feed Into the LLM
102+
103+### Option A – Plain Prompt Augmentation
104+
105+```python
106+from openai import OpenAI
107+
108+client = OpenAI()
109+
110+def ask_with_web(query: str) -> str:
111+ # 1. Get results
112+ results = bing_search(query, count=3)
113+
114+ # 2. Build a short context
115+ context = "\n".join(
116+ f"{i+1}. {r['title']}\n {r['snippet']}\n {r['url']}"
117+ for i, r in enumerate(results)
118+ )
119+
120+ # 3. Create the prompt
121+ prompt = (
122+ "You are an assistant that can browse the web. "
123+ "You will first look up recent information and then answer the user.\n\n"
124+ f"Web search results for: {query}\n{context}\n\n"
125+ f"Now answer the question: {query}"
126+ )
127+
128+ # 4. Call the model
129+ response = client.chat.completions.create(
130+ model="gpt-4o-mini", # or your local model name
131+ messages=[{"role": "user", "content": prompt}],
132+ temperature=0.2,
133+ )
134+ return response.choices[0].message.content.strip()
135+```
136+
137+### Option B – Function Calling (Tool)
138+
139+If you’re using OpenAI’s function calling or LangChain’s `Tool` abstraction, you can let the model *choose* when to call the search:
140+
141+```python
142+from openai import OpenAI
143+
144+client = OpenAI()
145+
146+def search_tool(query: str):
147+ results = bing_search(query, count=3)
148+ return json.dumps(results)
149+
150+functions = [
151+ {
152+ "name": "search_web",
153+ "description": "Search the web for up‑to‑date info",
154+ "parameters": {
155+ "type": "object",
156+ "properties": {
157+ "query": {"type": "string", "description": "Search query"},
158+ },
159+ "required": ["query"],
160+ },
161+ }
162+]
163+
164+def chat_with_function_calling(query: str):
165+ messages = [{"role": "user", "content": query}]
166+
167+ while True:
168+ response = client.chat.completions.create(
169+ model="gpt-4o-mini",
170+ messages=messages,
171+ functions=functions,
172+ function_call="auto",
173+ temperature=0.2,
174+ )
175+ message = response.choices[0].message
176+
177+ if message.get("function_call"):
178+ # We have a function call: execute it
179+ func_name = message["function_call"]["name"]
180+ arguments = json.loads(message["function_call"]["arguments"])
181+
182+ if func_name == "search_web":
183+ # call our wrapper
184+ tool_response = search_tool(arguments["query"])
185+ # feed back to the model
186+ messages.append(message) # function call
187+ messages.append(
188+ {"role": "tool", "name": func_name, "content": tool_response}
189+ )
190+ continue # let the model react to tool output
191+ else:
192+ # normal chat completion
193+ return message.content
194+```
195+
196+*The `function_call="auto"` lets the model decide when to call `search_web`. The wrapper returns raw JSON, which we feed back to the
197+model as a tool response.*
198+
199+---
200+
201+## 4️⃣ Caching (Optional but Recommended)
202+
203+If you’ll be re‑querying the same terms, use a simple LRU cache:
204+
205+```python
206+from functools import lru_cache
207+
208+@lru_cache(maxsize=128)
209+def cached_bing_search(query: str, count: int = 5) -> List[dict]:
210+ return bing_search(query, count)
211+```
212+
213+Just replace calls to `bing_search` with `cached_bing_search`.
214+
215+---
216+
217+## 5️⃣ Security & TOS
218+
219+| Concern | How to handle |
220+|---------|---------------|
221+| **API key exposure** | Store keys in `.env` or a secrets manager. Don’t commit to repo. |
222+| **Rate limits** | Monitor `X-RateLimit-Remaining` headers; implement back‑off. |
223+| **Privacy** | If you send sensitive queries to a third‑party API, consider data‑handling policy. |
224+| **License** | Each API has its own TOS; make sure you’re compliant with “embedding” usage. |
225+
226+---
227+
228+## Recap
229+
230+1. **Choose** a web‑search provider (Bing, SerpAPI, etc.).
231+2. **Wrap** the provider’s API in a function that returns a clean list of results.
232+3. **Inject** those results into the prompt (or expose the function to the model via tool calling).
233+4. **Optionally cache** queries to avoid duplicate API calls.
234+5. **Protect** your keys and respect usage limits.
235+
236+You’re now ready to have the model answer *up‑to‑date* queries without hard‑coding the data! If you need help wiring this into a
237+particular framework (FastAPI, Streamlit, LangChain, or even a simple CLI), let me know and I can write a snippet that fits your stack.
238+Happy
239+ building! 🚀
app/api/chat/route.ts+26−0
@@ -0,0 +1,26 @@
1+import { NextResponse } from 'next/server';
2+import { fetchOllamaResponse } from '../../../src/lib/ollama';
3+import { fetchDuckDuckGo } from '../../../src/lib/duckduckgo';
4+
5+export async function POST(request: Request) {
6+ const { message } = await request.json();
7+
8+ try {
9+ // 1. Search DuckDuckGo
10+ const searchResults = await fetchDuckDuckGo(message);
11+
12+ // 2. Build prompt
13+ const prompt = `${message}\n\nRelevant info from DuckDuckGo: ${JSON.stringify(
14+ searchResults
15+ )}\n\nAssistant:`;
16+
17+ const answer = await fetchOllamaResponse(prompt);
18+ return NextResponse.json({ answer });
19+ } catch (error) {
20+ console.error('Chat API error', error);
21+ return NextResponse.json(
22+ { answer: 'Sorry, something went wrong.' },
23+ { status: 500 }
24+ );
25+ }
26+}
app/globals.css+3−0
@@ -0,0 +1,3 @@
1+@tailwind base;
2+@tailwind components;
3+@tailwind utilities;
app/layout.tsx+19−0
@@ -0,0 +1,19 @@
1+import "./globals.css";
2+
3+export const metadata = {
4+ title: "Personal Assistant",
5+ description:
6+ "A simple personal assistant app built with Next.js, Tailwind, and Ollama.",
7+};
8+
9+export default function RootLayout({
10+ children,
11+}: {
12+ children: React.ReactNode;
13+}) {
14+ return (
15+ <html lang="en">
16+ <body>{children}</body>
17+ </html>
18+ );
19+}
app/page.tsx+71−0
@@ -0,0 +1,71 @@
1+"use client";
2+import { useState } from "react";
3+
4+export default function Home() {
5+ const [messages, setMessages] = useState<{ role: string; content: string }[]>(
6+ [],
7+ );
8+ const [input, setInput] = useState("");
9+
10+ const sendMessage = async (e: React.FormEvent) => {
11+ e.preventDefault();
12+ if (!input.trim()) return;
13+
14+ const userMsg = { role: "user", content: input };
15+ setMessages((prev) => [...prev, userMsg]);
16+
17+ const res = await fetch("/api/chat", {
18+ method: "POST",
19+ headers: { "Content-Type": "application/json" },
20+ body: JSON.stringify({ message: input }),
21+ });
22+
23+ const data = await res.json();
24+
25+ const botMsg = { role: "assistant", content: data.answer || "" };
26+ setMessages((prev) => [...prev, botMsg]);
27+
28+ setInput("");
29+ };
30+
31+ return (
32+ <div className="min-h-screen flex flex-col bg-gray-100 p-4">
33+ <h1 className="text-3xl font-bold mb-4 text-center">
34+ Personal Assistant
35+ </h1>
36+ <div className="flex-1 overflow-y-auto mb-4 p-4 bg-white rounded shadow">
37+ {messages.map((msg, i) => (
38+ <div
39+ key={i}
40+ className={`mb-3 flex ${msg.role === "assistant" ? "justify-start" : "justify-end"}`}
41+ >
42+ <div
43+ className={`max-w-xs rounded p-3 ${
44+ msg.role === "assistant"
45+ ? "bg-blue-100 text-blue-900"
46+ : "bg-green-100 text-green-900"
47+ }`}
48+ >
49+ {msg.content}
50+ </div>
51+ </div>
52+ ))}
53+ </div>
54+ <form onSubmit={sendMessage} className="flex space-x-2">
55+ <input
56+ type="text"
57+ value={input}
58+ onChange={(e) => setInput(e.target.value)}
59+ placeholder="Type a message..."
60+ className="flex-1 border rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
61+ />
62+ <button
63+ type="submit"
64+ className="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700"
65+ >
66+ Send
67+ </button>
68+ </form>
69+ </div>
70+ );
71+}
next-env.d.ts+6−0
@@ -0,0 +1,6 @@
1+/// <reference types="next" />
2+/// <reference types="next/image-types/global" />
3+import "./.next/dev/types/routes.d.ts";
4+
5+// NOTE: This file should not be edited
6+// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
next.config.js+1−0
@@ -0,0 +1 @@
1+module.exports = { reactStrictMode: true, devIndicators: false };
package-lock.json+6036−0
@@ -0,0 +1,6036 @@
1+{
2+ "name": "personal-assistant-thing",
3+ "version": "0.1.0",
4+ "lockfileVersion": 3,
5+ "requires": true,
6+ "packages": {
7+ "": {
8+ "name": "personal-assistant-thing",
9+ "version": "0.1.0",
10+ "dependencies": {
11+ "autoprefixer": "^10.4.17",
12+ "next": "^16.0.10",
13+ "postcss": "^8.4.30",
14+ "react": "18.2.0",
15+ "react-dom": "18.2.0",
16+ "tailwindcss": "^3.4.0",
17+ "typescript": "^5.4.2"
18+ },
19+ "devDependencies": {
20+ "@types/node": "^20.11.18",
21+ "@types/react": "^18.2.55",
22+ "@types/react-dom": "^18.2.19",
23+ "eslint": "^8.56.0",
24+ "eslint-config-next": "^13.5.6"
25+ }
26+ },
27+ "node_modules/@alloc/quick-lru": {
28+ "version": "5.2.0",
29+ "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz",
30+ "integrity": "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==",
31+ "license": "MIT",
32+ "engines": {
33+ "node": ">=10"
34+ },
35+ "funding": {
36+ "url": "https://github.com/sponsors/sindresorhus"
37+ }
38+ },
39+ "node_modules/@emnapi/core": {
40+ "version": "1.7.1",
41+ "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.7.1.tgz",
42+ "integrity": "sha512-o1uhUASyo921r2XtHYOHy7gdkGLge8ghBEQHMWmyJFoXlpU58kIrhhN3w26lpQb6dspetweapMn2CSNwQ8I4wg==",
43+ "dev": true,
44+ "license": "MIT",
45+ "optional": true,
46+ "dependencies": {
47+ "@emnapi/wasi-threads": "1.1.0",
48+ "tslib": "^2.4.0"
49+ }
50+ },
51+ "node_modules/@emnapi/runtime": {
52+ "version": "1.7.1",
53+ "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.7.1.tgz",
54+ "integrity": "sha512-PVtJr5CmLwYAU9PZDMITZoR5iAOShYREoR45EyyLrbntV50mdePTgUn4AmOw90Ifcj+x2kRjdzr1HP3RrNiHGA==",
55+ "license": "MIT",
56+ "optional": true,
57+ "dependencies": {
58+ "tslib": "^2.4.0"
59+ }
60+ },
61+ "node_modules/@emnapi/wasi-threads": {
62+ "version": "1.1.0",
63+ "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.1.0.tgz",
64+ "integrity": "sha512-WI0DdZ8xFSbgMjR1sFsKABJ/C5OnRrjT06JXbZKexJGrDuPTzZdDYfFlsgcCXCyf+suG5QU2e/y1Wo2V/OapLQ==",
65+ "dev": true,
66+ "license": "MIT",
67+ "optional": true,
68+ "dependencies": {
69+ "tslib": "^2.4.0"
70+ }
71+ },
72+ "node_modules/@eslint-community/eslint-utils": {
73+ "version": "4.9.0",
74+ "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.0.tgz",
75+ "integrity": "sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g==",
76+ "dev": true,
77+ "license": "MIT",
78+ "dependencies": {
79+ "eslint-visitor-keys": "^3.4.3"
80+ },
81+ "engines": {
82+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
83+ },
84+ "funding": {
85+ "url": "https://opencollective.com/eslint"
86+ },
87+ "peerDependencies": {
88+ "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0"
89+ }
90+ },
91+ "node_modules/@eslint-community/regexpp": {
92+ "version": "4.12.2",
93+ "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.2.tgz",
94+ "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==",
95+ "dev": true,
96+ "license": "MIT",
97+ "engines": {
98+ "node": "^12.0.0 || ^14.0.0 || >=16.0.0"
99+ }
100+ },
101+ "node_modules/@eslint/eslintrc": {
102+ "version": "2.1.4",
103+ "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz",
104+ "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==",
105+ "dev": true,
106+ "license": "MIT",
107+ "dependencies": {
108+ "ajv": "^6.12.4",
109+ "debug": "^4.3.2",
110+ "espree": "^9.6.0",
111+ "globals": "^13.19.0",
112+ "ignore": "^5.2.0",
113+ "import-fresh": "^3.2.1",
114+ "js-yaml": "^4.1.0",
115+ "minimatch": "^3.1.2",
116+ "strip-json-comments": "^3.1.1"
117+ },
118+ "engines": {
119+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
120+ },
121+ "funding": {
122+ "url": "https://opencollective.com/eslint"
123+ }
124+ },
125+ "node_modules/@eslint/js": {
126+ "version": "8.57.1",
127+ "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz",
128+ "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==",
129+ "dev": true,
130+ "license": "MIT",
131+ "engines": {
132+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
133+ }
134+ },
135+ "node_modules/@humanwhocodes/config-array": {
136+ "version": "0.13.0",
137+ "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz",
138+ "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==",
139+ "deprecated": "Use @eslint/config-array instead",
140+ "dev": true,
141+ "license": "Apache-2.0",
142+ "dependencies": {
143+ "@humanwhocodes/object-schema": "^2.0.3",
144+ "debug": "^4.3.1",
145+ "minimatch": "^3.0.5"
146+ },
147+ "engines": {
148+ "node": ">=10.10.0"
149+ }
150+ },
151+ "node_modules/@humanwhocodes/module-importer": {
152+ "version": "1.0.1",
153+ "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz",
154+ "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==",
155+ "dev": true,
156+ "license": "Apache-2.0",
157+ "engines": {
158+ "node": ">=12.22"
159+ },
160+ "funding": {
161+ "type": "github",
162+ "url": "https://github.com/sponsors/nzakas"
163+ }
164+ },
165+ "node_modules/@humanwhocodes/object-schema": {
166+ "version": "2.0.3",
167+ "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz",
168+ "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==",
169+ "deprecated": "Use @eslint/object-schema instead",
170+ "dev": true,
171+ "license": "BSD-3-Clause"
172+ },
173+ "node_modules/@img/colour": {
174+ "version": "1.0.0",
175+ "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.0.0.tgz",
176+ "integrity": "sha512-A5P/LfWGFSl6nsckYtjw9da+19jB8hkJ6ACTGcDfEJ0aE+l2n2El7dsVM7UVHZQ9s2lmYMWlrS21YLy2IR1LUw==",
177+ "license": "MIT",
178+ "optional": true,
179+ "engines": {
180+ "node": ">=18"
181+ }
182+ },
183+ "node_modules/@img/sharp-darwin-arm64": {
184+ "version": "0.34.5",
185+ "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.5.tgz",
186+ "integrity": "sha512-imtQ3WMJXbMY4fxb/Ndp6HBTNVtWCUI0WdobyheGf5+ad6xX8VIDO8u2xE4qc/fr08CKG/7dDseFtn6M6g/r3w==",
187+ "cpu": [
188+ "arm64"
189+ ],
190+ "license": "Apache-2.0",
191+ "optional": true,
192+ "os": [
193+ "darwin"
194+ ],
195+ "engines": {
196+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
197+ },
198+ "funding": {
199+ "url": "https://opencollective.com/libvips"
200+ },
201+ "optionalDependencies": {
202+ "@img/sharp-libvips-darwin-arm64": "1.2.4"
203+ }
204+ },
205+ "node_modules/@img/sharp-darwin-x64": {
206+ "version": "0.34.5",
207+ "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.5.tgz",
208+ "integrity": "sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==",
209+ "cpu": [
210+ "x64"
211+ ],
212+ "license": "Apache-2.0",
213+ "optional": true,
214+ "os": [
215+ "darwin"
216+ ],
217+ "engines": {
218+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
219+ },
220+ "funding": {
221+ "url": "https://opencollective.com/libvips"
222+ },
223+ "optionalDependencies": {
224+ "@img/sharp-libvips-darwin-x64": "1.2.4"
225+ }
226+ },
227+ "node_modules/@img/sharp-libvips-darwin-arm64": {
228+ "version": "1.2.4",
229+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.4.tgz",
230+ "integrity": "sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==",
231+ "cpu": [
232+ "arm64"
233+ ],
234+ "license": "LGPL-3.0-or-later",
235+ "optional": true,
236+ "os": [
237+ "darwin"
238+ ],
239+ "funding": {
240+ "url": "https://opencollective.com/libvips"
241+ }
242+ },
243+ "node_modules/@img/sharp-libvips-darwin-x64": {
244+ "version": "1.2.4",
245+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.4.tgz",
246+ "integrity": "sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==",
247+ "cpu": [
248+ "x64"
249+ ],
250+ "license": "LGPL-3.0-or-later",
251+ "optional": true,
252+ "os": [
253+ "darwin"
254+ ],
255+ "funding": {
256+ "url": "https://opencollective.com/libvips"
257+ }
258+ },
259+ "node_modules/@img/sharp-libvips-linux-arm": {
260+ "version": "1.2.4",
261+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.4.tgz",
262+ "integrity": "sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==",
263+ "cpu": [
264+ "arm"
265+ ],
266+ "license": "LGPL-3.0-or-later",
267+ "optional": true,
268+ "os": [
269+ "linux"
270+ ],
271+ "funding": {
272+ "url": "https://opencollective.com/libvips"
273+ }
274+ },
275+ "node_modules/@img/sharp-libvips-linux-arm64": {
276+ "version": "1.2.4",
277+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.4.tgz",
278+ "integrity": "sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==",
279+ "cpu": [
280+ "arm64"
281+ ],
282+ "license": "LGPL-3.0-or-later",
283+ "optional": true,
284+ "os": [
285+ "linux"
286+ ],
287+ "funding": {
288+ "url": "https://opencollective.com/libvips"
289+ }
290+ },
291+ "node_modules/@img/sharp-libvips-linux-ppc64": {
292+ "version": "1.2.4",
293+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.4.tgz",
294+ "integrity": "sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==",
295+ "cpu": [
296+ "ppc64"
297+ ],
298+ "license": "LGPL-3.0-or-later",
299+ "optional": true,
300+ "os": [
301+ "linux"
302+ ],
303+ "funding": {
304+ "url": "https://opencollective.com/libvips"
305+ }
306+ },
307+ "node_modules/@img/sharp-libvips-linux-riscv64": {
308+ "version": "1.2.4",
309+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.2.4.tgz",
310+ "integrity": "sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==",
311+ "cpu": [
312+ "riscv64"
313+ ],
314+ "license": "LGPL-3.0-or-later",
315+ "optional": true,
316+ "os": [
317+ "linux"
318+ ],
319+ "funding": {
320+ "url": "https://opencollective.com/libvips"
321+ }
322+ },
323+ "node_modules/@img/sharp-libvips-linux-s390x": {
324+ "version": "1.2.4",
325+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.4.tgz",
326+ "integrity": "sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==",
327+ "cpu": [
328+ "s390x"
329+ ],
330+ "license": "LGPL-3.0-or-later",
331+ "optional": true,
332+ "os": [
333+ "linux"
334+ ],
335+ "funding": {
336+ "url": "https://opencollective.com/libvips"
337+ }
338+ },
339+ "node_modules/@img/sharp-libvips-linux-x64": {
340+ "version": "1.2.4",
341+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.2.4.tgz",
342+ "integrity": "sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==",
343+ "cpu": [
344+ "x64"
345+ ],
346+ "license": "LGPL-3.0-or-later",
347+ "optional": true,
348+ "os": [
349+ "linux"
350+ ],
351+ "funding": {
352+ "url": "https://opencollective.com/libvips"
353+ }
354+ },
355+ "node_modules/@img/sharp-libvips-linuxmusl-arm64": {
356+ "version": "1.2.4",
357+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.4.tgz",
358+ "integrity": "sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==",
359+ "cpu": [
360+ "arm64"
361+ ],
362+ "license": "LGPL-3.0-or-later",
363+ "optional": true,
364+ "os": [
365+ "linux"
366+ ],
367+ "funding": {
368+ "url": "https://opencollective.com/libvips"
369+ }
370+ },
371+ "node_modules/@img/sharp-libvips-linuxmusl-x64": {
372+ "version": "1.2.4",
373+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.4.tgz",
374+ "integrity": "sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==",
375+ "cpu": [
376+ "x64"
377+ ],
378+ "license": "LGPL-3.0-or-later",
379+ "optional": true,
380+ "os": [
381+ "linux"
Cut short: this commit's diff is over 1000 lines.
package.json+27−0
Cut short: this commit's diff is over 1000 lines.
postcss.config.cjs+6−0
Cut short: this commit's diff is over 1000 lines.
src/lib/duckduckgo.ts+47−0
Cut short: this commit's diff is over 1000 lines.
src/lib/ollama.ts+45−0
Cut short: this commit's diff is over 1000 lines.
tailwind.config.js+10−0
Cut short: this commit's diff is over 1000 lines.
tsconfig.json+37−0
Cut short: this commit's diff is over 1000 lines.