jlehtine / verbal-web

Verbal web control using large language models

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Verbal Web

Verbal web control using large language models

Configuration

The configuration object specified for initVerbalWeb() can contain the following properties.

  • backendURL (required)
    Backend base URL as a string.

    Example: https://my-backend.example.org

  • initialInstruction (optional)
    String containing the initial instruction or prompt given to the AI model before user messages. However, if the backend has environment variable VW_INITIAL_INSTRUCTION defined then it overrides any instruction supplied by the frontend. Any selected page content will be added to the end of this string.

    Example: "Use the following web content to answer user queries."

    Default value: (none)

  • pageContentSelector (optional)
    CSS selector string which specifies which elements of the web page are sent to the AI model as background information. However, if the backend has environment variable VW_PAGE_CONTENT defined then it overrides any content supplied by the frontend.

    Example: "h1, p" will send content from all of the <h1> and <p> elements.

    Default value: none

  • useModel (optional)
    String specifying the chat completion model to be used. However, if the backend has environment variable VW_CHAT_MODEL defined then it overrides any model supplied by the frontend.

    Example: "gpt-3.5-turbo"

    Default value: "gpt-4o"

Environment variables

Verbal Web server uses the following environment variables.

  • OPENAI_API_KEY (required)
    Secret API key that the OpenAI API uses for authentication.

  • VW_ALLOW_ORIGIN (optional)
    Variable specifies an address where requests to the server are allowed. Can be used to restrict backend requests to a specific website. If the variable exits, its value is used as Access-Control-Allow-Origin header.

    If the variable doesn't exist a default value of * is used which allows requests from any address.

  • VW_INITIAL_INSTRUCTION (optional)
    If this variable exists, the initial instruction specified in the configuration object (see above) is overridden and replaced by this value. Used if backend needs to more strictly limit what kind of queries can be sent to the chat completion API.

  • VW_PAGE_CONTENT (optional)
    If this variable exitsts, the page content sent from the frontend is overridden and replaced by this value. Used if backend needs to override the content included in the query before it is sent to the chat completion API.

  • VW_CHAT_MODEL (optional)
    If this variable exists, the language model specified in the configuration object (see above) is overridden and replaced by this value. Used to enforce a specific language model.

  • VW_MODERATION_CACHE_EXPIRE_SECONDS (optional)
    Sets the moderation result cache expiration time in seconds.
    Default value: 3600 (one hour)

  • VW_MODERATION_CACHE_EXPIRE_ENTRIES (optional)
    Sets the moderation result cache cap size in number of entries.
    Default value: 1000

About

Verbal web control using large language models

License:MIT License


Languages

Language:TypeScript 93.2%Language:HTML 4.2%Language:JavaScript 2.3%Language:CSS 0.3%Language:Shell 0.0%