Is there a way to reach Verba Chat without the UI, through an API or a request for example

Is there a way to reach Verba Chat without the UI, through an API or a request for example.

I have a main app, an currently using Ollama runs in my local, and right now I have a little node application that functions like a RAG, I’m embedding the queries that I get, comparing the vectors and then giving to ollama the context and original query to get the answer.

Is there a way to introduce Verba here? The UI is really nice, but for the workflow I need an endpoint, is this possible currently?

Hi @Arturo_Zambrano !! Welcome to our community!

Verba UI consume two apis (tested on http://verba.weaviate.io) when doing a query

https://verba.weaviate.io/api/query

and a websocket at:
wss://verba.weaviate.io/ws/generate_stream

With those you can use probably use it’s backend directly.

However, I don’t believe those are documented or intended to be used outside of that UI.

Additionally, you can always code some api that will connect to Weaviate directly.

I have not found a feature request on this:

It would be interesting to open one, as this may also be a popular demand from other users.

Let me know if this helps.

Thanks!

1 Like

I’ve been hacking on the same thing, I pieced a good bit together by going on the chrome developer console while running the default verba chat UI and watching the network tab (there’s an option to copy requests as cURL which is mucho helpful).

Connecting first requires credentials, these can simply be hardcoded for development but will require making secure by having an actual key later and setting AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED to false:

{
    "url": "http://weaviate:8080",
    "key": "",
    "deployment": "Docker"
}

I have my verba / weaviate running in a docker compose, hence why my domain is weaviate, I could also have it as localhost I believe as I’m exposing the port in my compose config, but I’ve not tested that and this works just fine for me at the moment.

services:
  verba:
    build:
      context: .
      dockerfile: ./external/verba/Dockerfile 
    ports:
      - 8000:8000
    environment:
      - WEAVIATE_URL_VERBA=http://weaviate:5433
      - OPENAI_API_KEY=$OPENAI_API_KEY
      - COHERE_API_KEY=$COHERE_API_KEY
      - OLLAMA_URL=http://host.docker.internal:11434
      - OLLAMA_MODEL=$OLLAMA_MODEL
      - OLLAMA_EMBED_MODEL=$OLLAMA_EMBED_MODEL
      - UNSTRUCTURED_API_KEY=$UNSTRUCTURED_API_KEY
      - UNSTRUCTURED_API_URL=$UNSTRUCTURED_API_URL
      - GITHUB_TOKEN=$GITHUB_TOKEN
    volumes:
      - verba_data:/data/
    depends_on:
      weaviate:
        condition: service_healthy
    healthcheck:
      test: wget --no-verbose --tries=3 --spider http://localhost:8000 || exit 1
      interval: 5s
      timeout: 10s
      retries: 5
      start_period: 10s

  weaviate:
    command:
      - --host
      - 0.0.0.0
      - --port
      - '8080'
      - --scheme
      - http
    image: semitechnologies/weaviate:1.25.10
    ports:
      - 5433:8080
      - 8001:8080
    volumes:
      - weaviate_data:/var/lib/weaviate
    restart: on-failure:0
    healthcheck:
      test: wget --no-verbose --tries=3 --spider http://localhost:8080/v1/.well-known/ready || exit 1
      interval: 5s
      timeout: 10s
      retries: 5
      start_period: 10s
    environment:
      OPENAI_APIKEY: $OPENAI_API_KEY
      COHERE_APIKEY: $COHERE_API_KEY
      QUERY_DEFAULTS_LIMIT: 25
      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
      PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
      ENABLE_MODULES: 'e'
      CLUSTER_HOSTNAME: 'node1'

(your dockerfile location will differ or you could just use the default image: semitechnologies/verba, but I like hacking with the server/frontend code to debug so…)

As @DudaNogueira points out there’s a websocket you listen to responses through (wss://verba.weaviate.io/ws/generate_stream, or more likely if you run it as a docker container ws://localhost:8000/ws/generate_stream) that you’ll want to connect to first.

Then sending, say a query request, requires that you first hit the /api/get_rag_config endpoint and put it’s response into the query request’s payload under a field named “RAG”. You’ll also need the “origin” header headers={"Origin": "<<your_client_url>>"}

I think this should get you started. Maybe I’ll throw a PR together for an API doc generator that can be hosted for others, or develop a client library if there’s a language which is most popular like python. Put in a request in Verba’s Github under “Issues”, if it gains enough popularity then it’s more likely to get worked on!

Hope this all helps and Happy hacking :slight_smile: