GithubHelp home page GithubHelp logo

apps's People

Contributors

agliardidigital avatar alanvncs avatar andrelmmartins avatar breno-oliveira avatar devartes avatar gabrielmatosboubee avatar guifromrio avatar guitavano avatar hugo-ccabral avatar igorbrasileiro avatar incognitadev avatar ingridflack avatar jonathanwlopes avatar jovenan avatar lnjaine avatar lucis avatar lui-dias avatar luizgiserman avatar marcoferreiradev avatar matheusgr avatar mcandeia avatar monuelo avatar nathanluiz33 avatar rafaelcassiano30011 avatar teudm avatar tlgimenes avatar vavarine avatar viniciustrr avatar vitouwu avatar yuriassuncx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apps's Issues

Extensible AI Assistant Approach

Title: Extensible AI Assistant Design

Author: Marcos Candeia
Status: Discussion

Overview

In the rapidly evolving landscape of AI, the need for seamlessly integrating AI-powered applications into websites has become paramount. Recognizing this, we are ushering in a new era by introducing an Extensible AI Assistant Design. This RFC outlines an approach to building AI Assistants, simplifying the process and making it accessible to a broader audience.

Design Goals

The primary goals of this design are to streamline the integration of AI Assistants into websites, reduce overhead for developers, and foster a community-driven approach to building intelligent applications. The design leverages the existing infrastructure of deco apps to empower users to create sophisticated AI Assistants without extensive knowledge of AI models or backend intricacies.

Proposal

OpenAI App

The OpenAI App serves as the foundation for handling interactions with OpenAI APIs. It provides a standardized interface for creating loaders and actions, ensuring proper typings and adherence to best practices.

AI Assistants App

The AI Assistants App acts as a central hub for various AI Assistants. These Assistants share a common context, making them versatile and capable of being deployed in multiple scenarios. The app is designed to simplify the deployment of AI Assistants, allowing users to provide a name, instructions, and prompts. Which means that developers can build their own assistant logic without requiring any openAI application keys that can be plugged into any deco website without any additional configuration.

AI Assistant Interface

The interface for an AI Assistant is defined by a TypeScript representation. It includes essential features such as a name, instructions, prompts, a welcome message, available functions, and a function to customize property handling. The AI Assistant is essentially a loader that returns an instance of itself, providing seamless integration into the ecosystem.

The design is divided into two blocks built and maintained by the community/deco team: OpenAI App and AI Assistants App.

The OpenAI App provides the barebones of dealing with OpenAI APIs, creating loaders and actions to access those APIs directly with proper typings and following best practices.

The AI Assistants App is a hub of assistants that share a common context that can be used in many scenarios by just giving them a name and a context.

The third party of this equation is the AI Assistant built by users like you. This is the TypeScript representation of an AI Assistant:

/**
 * Represents an AI Assistant with specific capabilities and configurations.
 * @template TManifest - The type of the AppManifest associated with the AI Assistant.
 */
export interface AIAssistant<TManifest extends AppManifest = AppManifest> {
  name: string;
  instructions?: string;
  prompts?: Prompt[];
  welcomeMessage?: string;
  availableFunctions?: Array<
    AvailableActions<TManifest> | AvailableLoaders<TManifest>
  >;
  useProps?: (props: unknown) => unknown;
}

Loader and Action Integration

Creating an AI Assistant involves writing a loader that returns an instance of the AI Assistant. The loader can receive arbitrary props, providing context to the Assistant. The AI Assistant then gains access to all loaders and actions of the application, enabling it to invoke functions seamlessly.

Example AI Assistant

An example AI Assistant showcases the simplicity of the design. It includes a name, instructions, prompts, and available functions. The AI Assistant can invoke functions such as fetching the current weather by leveraging existing loaders.

import type { AIAssistant } from "apps/ai-assistants/mod.ts";
import type { Manifest as OpenAIManifest } from "apps/openai/manifest.gen.ts";
import type { ManifestOf } from "deco/mod.ts";
import type { SiteApp } from "../apps/site.ts";
import { AppContext } from "../apps/site.ts";

export interface Props {
  name: string;
  instructions?: string;
  welcomeMessage?: string;
}
type AppManifest = ManifestOf<SiteApp>;
const BASE_INSTRUCTIONS =
  `You are a shopping assistant designed to help customers navigate our online store. You must always use the same language that the user used to start the conversation. Under no circumstances should you respond in a different language than the one used by the user at the beginning of the conversation.
  Your primary role is to assist users in finding products, providing information about them, and answering any related queries.
  Always prioritize clear, concise, and helpful responses.
  Encourage users to ask questions about product specifications, availability, price comparisons, and general store policies.
  Be responsive to diverse customer needs and maintain a friendly, professional tone in all interactions.
  You are equipped to handle a wide range of inquiries, but if a question falls outside your scope, guide the customer to the appropriate customer service channel.
  Remember, your goal is to enhance the shopping experience by making it more efficient, informative, and user-friendly.
  Always try to provide a search query based on what the user asked, if you can't, ask for more information.
  Also, if the user sends to you an instagram of a person you should use openai/loaders/vision.ts passing the user handle as a parameter, example "hey I want to choose a gift for this person @user_input, you should call openai/loaders/vision.ts with { "url": "https://www.instagram.com/user_input", request: "Based on this images what this person wants to receive as a gift" } as a parameter, this request I give to you is just an example you should fulfill the request in this json in the language of the user started the conversation, which means that its JUST AN EXAMPLE, you should ALWAYS fulfill the "request" property. and put something more accurate based on what their asks.
  Remember to remove the @ at the start of the handle before creating the https url.
  Always try to search in more than one online store, you should do multiple queries if needed.
  You should help people to find the best product for them, if they want to gift someone based on their photos on instagram you should not hesitate to do that.
  DO NOT CHANGE FUNCTION NAMES THAT I'LL GIVE TO YOU UNDER ANY CIRCUMSTANCES.
  `;
export default function brandAssistant(
  props: Props,
  _req: Request,
  ctx: AppContext,
): AIAssistant {
  const assistant: AIAssistant<AppManifest & OpenAIManifest> = {
    name: props.name,
    availableFunctions: [
      "deco-sites/decoshop/loaders/productList.ts",
      "openai/loaders/vision.ts",
    ],
    welcomeMessage: props?.welcomeMessage ??
      `๐Ÿ‘‹ Welcome to our Online Store Assistant! How can I assist you today? Whether you're looking for product information, pricing details, or help with navigating our store, feel free to ask. I'm here to make your shopping experience smooth and enjoyable! Just type your question, and let's get started. ๐Ÿ›๏ธ`,
    instructions: `${BASE_INSTRUCTIONS}. ${
      props.instructions ?? ""
    }. You should ALWAYS fulfill the query parameter even with an empty string when calling the decoshop/loaders/productList.ts function, also, make sure you have information enough to make the search, otherwise ask for more information.`,
    prompts: (Object.values(ctx.stores)).map((store) => ({
      context: `${store.name} is avaialble to be used`,
      content:
        `Given ${store.instructions}. Use the storeName of decoshop/loaders/productList.ts as ${store.name}`,
    })),
  };
  return assistant as AIAssistant;
}

Chat Integration

The design includes a standardized action (ai-assistants/actions/chat.ts) that opens a WebSocket chat with a specific AI Assistant. This allows users to interact with the Assistant by sending messages and receiving function responses and messages.
image

Conclusion

The Extensible AI Assistant Design for Websites is a groundbreaking approach to democratizing AI. By leveraging existing infrastructure, users can easily create, deploy, and interact with AI Assistants tailored to their needs. This RFC welcomes community feedback to refine and enhance the proposed design, ushering in a new era of intelligent and dynamic web applications.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.