Skip to content

Commit

Permalink
Merge pull request #307 from weaviate/dev
Browse files Browse the repository at this point in the history
Merge DEV to MAIN
  • Loading branch information
thomashacker authored Oct 21, 2024
2 parents 3b209c6 + b3517f3 commit 59a46d0
Show file tree
Hide file tree
Showing 19 changed files with 280 additions and 46 deletions.
42 changes: 21 additions & 21 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ name: Docker Build and Push

on:
push:
branches: [ "main" ]
branches: ["main"]

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/verba:latest
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: semitechnologies/verba:latest
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ All notable changes to this project will be documented in this file.

- Added new deployment type: Custom
- Added new port configuration
- Added Groq

# Fixed

- Catch Exception when trying to access the OpenAI API Embedding endpoint to retrieve model names
- Fixed reading empty string as environment variables
- Fixed default Unstructed URL

## [2.0.0] Importastic

Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pip install goldenverba
- [AssemblyAI](#assemblyai)
- [OpenAI](#openai)
- [HuggingFace](#huggingface)
- [Groq](#groq)
- [Quickstart: Deploy with pip](#how-to-deploy-with-pip)
- [Quickstart: Build from Source](#how-to-build-from-source)
- [Quickstart: Deploy with Docker](#how-to-install-verba-with-docker)
Expand Down Expand Up @@ -53,6 +54,7 @@ Verba is a fully-customizable personal assistant utilizing [Retrieval Augmented
| Cohere (e.g. Command R+) || Embedding and Generation Models by Cohere |
| Anthrophic (e.g. Claude Sonnet) || Embedding and Generation Models by Anthrophic |
| OpenAI (e.g. GPT4) || Embedding and Generation Models by OpenAI |
| Groq (e.g. Llama3) || Generation Models by Groq (LPU inference) |

| 🤖 Embedding Support | Implemented | Description |
| -------------------- | ----------- | ---------------------------------------- |
Expand Down Expand Up @@ -159,6 +161,7 @@ Below is a comprehensive list of the API keys and variables you may require:
| OPENAI_API_KEY | Your OpenAI Key | Get Access to [OpenAI](https://openai.com/) Models |
| OPENAI_BASE_URL | URL to OpenAI instance | Models |
| COHERE_API_KEY | Your API Key | Get Access to [Cohere](https://cohere.com/) Models |
| GROQ_API_KEY | Your Groq API Key | Get Access to [Groq](https://groq.com/) Models
| OLLAMA_URL | URL to your Ollama instance (e.g. http://localhost:11434 ) | Get Access to [Ollama](https://ollama.com/) Models |
| UNSTRUCTURED_API_KEY | Your API Key | Get Access to [Unstructured](https://docs.unstructured.io/welcome) Data Ingestion |
| UNSTRUCTURED_API_URL | URL to Unstructured Instance | Get Access to [Unstructured](https://docs.unstructured.io/welcome) Data Ingestion |
Expand Down Expand Up @@ -207,7 +210,7 @@ ollama run llama3

Verba supports importing documents through Unstructured IO (e.g plain text, .pdf, .csv, and more). To use them you need the `UNSTRUCTURED_API_KEY` and `UNSTRUCTURED_API_URL` environment variable. You can get it from [Unstructured](https://unstructured.io/)

> UNSTRUCTURED_API_URL is set to `https://api.unstructured.io/general/v0/general` by default
> UNSTRUCTURED_API_URL is set to `https://api.unstructuredapp.io/general/v0/general` by default
## AssemblyAI

Expand Down Expand Up @@ -238,6 +241,13 @@ pip install `.[huggingface]`

> If you're using Docker, modify the Dockerfile accordingly
## Groq

To use Groq LPUs as generation engine, you need to get an API key from [Groq](https://console.groq.com/keys).

>Although you can provide it in the graphical interface when Verba is up, it is recommended to specify it as `GROQ_API_KEY` environment variable before you launch the application.
It will allow you to choose the generation model in an up-to-date available models list.

# How to deploy with pip

`Python >=3.10.0`
Expand Down
14 changes: 13 additions & 1 deletion frontend/app/components/Chat/ChatInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ const ChatInterface: React.FC<ChatInterfaceProps> = ({

const [userInput, setUserInput] = useState("");
const [messages, setMessages] = useState<Message[]>([]);
const [isComposing, setIsComposing] = useState(false);

const currentEmbedding = RAGConfig
? (RAGConfig["Embedder"].components[RAGConfig["Embedder"].selected].config[
"Model"
Expand Down Expand Up @@ -317,8 +319,16 @@ const ChatInterface: React.FC<ChatInterfaceProps> = ({
}
};

const handleCompositionStart = () => {
setIsComposing(true);
}

const handleCompositionEnd = () => {
setIsComposing(false);
}

const handleKeyDown = (e: any) => {
if (e.key === "Enter" && !e.shiftKey) {
if (e.key === "Enter" && !e.shiftKey && !isComposing) {
e.preventDefault(); // Prevent new line
sendUserMessage(); // Submit form
}
Expand Down Expand Up @@ -591,6 +601,8 @@ const ChatInterface: React.FC<ChatInterfaceProps> = ({
: `No documents detected...`
}
onKeyDown={handleKeyDown}
onCompositionStart={handleCompositionStart}
onCompositionEnd={handleCompositionEnd}
value={userInput}
onChange={(e) => {
const newValue = e.target.value;
Expand Down
4 changes: 2 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion goldenverba/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# FIRECRAWL_API_KEY=

# UNSTRUCTURED_API_KEY=
# UNSTRUCTURED_API_URL=
# UNSTRUCTURED_API_URL=https://api.unstructuredapp.io/general/v0/general

# GITHUB_TOKEN=
# GITLAB_TOKEN=
Expand Down
12 changes: 6 additions & 6 deletions goldenverba/components/embedding/CohereEmbedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from goldenverba.components.interfaces import Embedding
from goldenverba.components.types import InputConfig
from goldenverba.components.util import get_environment
from goldenverba.components.util import get_environment, get_token

from wasabi import msg

Expand All @@ -20,16 +20,16 @@ def __init__(self):
self.name = "Cohere"
self.description = "Vectorizes documents and queries using Cohere"
self.url = os.getenv("COHERE_BASE_URL", "https://api.cohere.com/v1")
models = get_models(self.url, os.getenv("COHERE_API_KEY", None), "embed")
models = get_models(self.url, get_token("COHERE_API_KEY", None), "embed")

self.config["Model"] = InputConfig(
type="dropdown",
value=models[0],
value=models[0] if models else "",
description="Select a Cohere Embedding Model",
values=models,
values=models if models else [],
)

if os.getenv("COHERE_API_KEY") is None:
if get_token("COHERE_API_KEY") is None:
self.config["API Key"] = InputConfig(
type="password",
value="",
Expand Down Expand Up @@ -71,7 +71,7 @@ def chunks(lst, n):

def get_models(url: str, token: str, model_type: str):
try:
if token is None:
if token is None or token == "":
return [
"embed-english-v3.0",
"embed-multilingual-v3.0",
Expand Down
4 changes: 2 additions & 2 deletions goldenverba/components/embedding/OpenAIEmbedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from goldenverba.components.interfaces import Embedding
from goldenverba.components.types import InputConfig
from goldenverba.components.util import get_environment
from goldenverba.components.util import get_environment, get_token


class OpenAIEmbedder(Embedding):
Expand All @@ -20,7 +20,7 @@ def __init__(self):
self.description = "Vectorizes documents and queries using OpenAI"

# Fetch available models
api_key = os.getenv("OPENAI_API_KEY")
api_key = get_token("OPENAI_API_KEY")
base_url = os.getenv("OPENAI_BASE_URL", "https://api.openai.com/v1")
models = self.get_models(api_key, base_url)

Expand Down
10 changes: 5 additions & 5 deletions goldenverba/components/generation/CohereGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from goldenverba.components.interfaces import Generator
from goldenverba.components.types import InputConfig
from goldenverba.components.embedding.CohereEmbedder import get_models
from goldenverba.components.util import get_environment
from goldenverba.components.util import get_environment, get_token


class CohereGenerator(Generator):
Expand All @@ -21,16 +21,16 @@ def __init__(self):
self.url = os.getenv("COHERE_BASE_URL", "https://api.cohere.com/v1")
self.context_window = 10000

models = get_models(self.url, os.getenv("COHERE_API_KEY", None), "chat")
models = get_models(self.url, get_token("COHERE_API_KEY", None), "chat")

self.config["Model"] = InputConfig(
type="dropdown",
value=models[0],
value=models[0] if models else "",
description="Select a Cohere Embedding Model",
values=models,
values=models if models else [],
)

if os.getenv("COHERE_API_KEY") is None:
if get_token("COHERE_API_KEY") is None:
self.config["API Key"] = InputConfig(
type="password",
value="",
Expand Down
Loading

0 comments on commit 59a46d0

Please sign in to comment.