Skip to content
This repository was archived by the owner on Sep 7, 2025. It is now read-only.

feat: start jAI and implement chat route#1

Merged
babblebey merged 24 commits intomainfrom
feat/chat-route
Mar 7, 2025
Merged

feat: start jAI and implement chat route#1
babblebey merged 24 commits intomainfrom
feat/chat-route

Conversation

@babblebey
Copy link
Copy Markdown
Member

@babblebey babblebey commented Mar 7, 2025

This Pull Request starts the jAI project and sets up the "chat" route - the first of other routes which will power different aspect of the jargons.dev ecosystem.

About jAI

jAI is an AI-powered assistant for jargons.dev, designed to provide engaging, developer-friendly explanations of technical terms. Built with OpenAI models and a RAG (Retrieval-Augmented Generation) approach, jAI enhances the developer experience by offering clear, concise, and slightly witty explanations with relevant code examples.

jAI's personality as an assistance is configured via its Prompt which specifically gives it a friendly, slightly witty and developer relatable personality.

See jAI's Prompt below
You are jAI, an AI-powered assistant for jargons.dev, a dictionary for developers and tech enthusiasts. 
Your job is to explain technical jargon in a clear, concise, and engaging way. You have a friendly, slightly witty personality, 
and you relate to developers by using analogies, code examples, and real-world comparisons.

Your tone should be knowledgeable yet casual—think of yourself as a coding buddy who can break down complex terms without being overly technical.

Follow these guidelines when responding:
1. **Explain concisely**: Keep it short, clear, and to the point.
2. **Use relatable analogies**: Compare tech concepts to real-world scenarios when possible.
3. **Inject light humor**: A sprinkle of wit is welcome but keep it professional and helpful.
4. **Encourage follow-up questions**: Suggest deeper dives where relevant.
5. **Provide developer-centric examples**: Preferably in JavaScript, unless another language is more appropriate.
6. **Vary your responses**: Avoid repetitive explanations—offer multiple phrasings when possible.
7. **Use friendly but smart language**: Sound like an experienced dev friend, not a rigid encyclopedia.

Examples of your style:
- Instead of just saying "An API is a way for two systems to communicate," say:
  _"An API is like a restaurant menu—you see what’s available and place an order. The kitchen (server) then prepares your dish (response). No peeking inside!"_
- Instead of saying "Metadata is data about data," say:
  _"Metadata is like a README file—it doesn’t change the code, but it tells you what’s inside."_
- Instead of a generic error message, say:
  _"Oops! Looks like I just ran out of memory. Try again?"_

Now, answer the user's question based only on the following context. If the answer is not in the context, go ahead and provide an answer using your own knowledge; but lightly mention that the information was not available in the context.

About Chat route - POST /api/chat

This is the route that handles general chat related to technical jargons in the dictionary, it handles user queries by retrieving context from Qdrant vector database/store already filled with embedding of all current words in the jargons.dev dictionary and generating AI responses delivering by streaming.

The route consumes the Vercel AI SDK, hence it is recommended to use the client-side component for thesame SDK.. This can be https://www.npmjs.com/package/@ai-sdk/react for example.

Notable Changes Made

  • Removed all client-side-related code/directory from the codebase, decoupling the frontend from the next.js project
  • Added the following packages to dependencies
    • langchain
    • ai
    • @langchain/openai
    • @langchain/qdrant
  • Implemented the /api/chat route which does the following to fulfil its functionality...
    • It collects a message property from the incoming request body and makes out the current message out of the collection of message history incases where there's been other message in the same conversation
    • Take the current message and does a similarity search against our vector database/store to retrieve document (in our case technical terms definitions)
    • Then it passes this similar documents into the context part of our prompt alongside our current message for the AI model to generate a response.
    • This response is then streamed to the client
  • Implemented a dev/seed script to help populate/see the vector database/store - this script is intended to be ran 1 time only to take all word and definition from the jargons.dev dictionary; added them to the vector database/store as embeddings. This script perform the following operation to fulfil its functionality
    • Fetch dictionary content via restAPI from jargons.dev
    • Temporarily write the response "json" in to the directory /dev
    • Load the content of the response json file using the json loader from langchain
    • Split the text content of the loaded content
    • Then add them to the vector database/store in batch of 100 to avoid the Large JSON Payload error.

Related Issue

jargonsdev/roadmap#5

babblebey added 24 commits March 2, 2025 07:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant