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

window.ai.rag #16

Closed
hemanth opened this issue Jul 10, 2024 · 3 comments
Closed

window.ai.rag #16

hemanth opened this issue Jul 10, 2024 · 3 comments

Comments

@hemanth
Copy link
Contributor

hemanth commented Jul 10, 2024

The window.ai.rag API enables web applications to perform Retrieval-Augmented Generation (RAG) directly in the browser. RAG combines the power of large language models with the ability to retrieve and incorporate relevant information from a knowledge base.

This API is particularly useful for:

  1. Question-answering systems that need access to up-to-date or specialized information
  2. Content generation tools that require factual accuracy and domain-specific knowledge
  3. Chatbots or virtual assistants that need to provide informative responses based on a specific corpus of data

By implementing RAG in the browser, applications can:

  1. Provide more accurate and contextually relevant responses
  2. Reduce the load on server-side infrastructure
  3. Offer personalized experiences based on user-specific data

API:

interface RAGOptions {
  model: string; // Identifier for the base language model
  knowledgeBase: KnowledgeBase;
  retrievalOptions?: RetrievalOptions;
  generationOptions?: GenerationOptions;
}

interface KnowledgeBase {
  type: 'vector' | 'inverted-index' | 'hybrid';
  data: ArrayBuffer | string[]; // Depending on the type
}

interface RetrievalOptions {
  topK?: number; // Number of documents to retrieve
  similarityThreshold?: number;
}

interface GenerationOptions {
  maxTokens?: number;
  temperature?: number;
}

interface RAGResult {
  generatedText: string;
  retrievedDocuments: string[];
  confidence: number;
}

interface WindowAI {
  rag: {
    query(input: string, options: RAGOptions): Promise<RAGResult>;
    updateKnowledgeBase(newData: ArrayBuffer | string[]): Promise<void>;
  };
}

interface Window {
  ai: WindowAI;
}
const result = await window.ai.rag.query(question, ragOptions);
@domenic
Copy link
Collaborator

domenic commented Jul 10, 2024

Hi! It looks like you're making new API proposals, instead of commenting on the existing proposal. The best place to do that is https://github.com/WICG/proposals/, not another related proposal's repository.

Alternately, if you think there's something in the existing proposal that isn't serving your use case, it would be good to open an issue to explain your use case, without reference to any proposed solution or API surface. You should talk about what type of web application you are trying to build, why the current proposal is not sufficient for it, and what alternatives you could use instead. The result might end up best in this repository, if it's specifically about a deficit in the built-in AI proposal here, or in https://github.com/WICG/proposals/, if it's just somewhat related by virtue of being about AI.

https://whatwg.org/faq#adding-new-features is generally good guidance for this, and recommended reading.

@domenic domenic closed this as completed Jul 10, 2024
@hemanth
Copy link
Contributor Author

hemanth commented Jul 10, 2024

Sorry, I mistakenly associated this repo with window.ai. It is actually just for prompt-api.

I have created a new issue in WICG proposals.

@tomayac
Copy link
Contributor

tomayac commented Oct 14, 2024

Connecting the dots here: WICG/proposals#158.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants