-
Notifications
You must be signed in to change notification settings - Fork 493
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
Qdrant Integeration #484
Open
essamamdani
wants to merge
2
commits into
vocodedev:main
Choose a base branch
from
essamamdani:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Qdrant Integeration #484
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
OPENAI_API_KEY= | ||
DEEPGRAM_API_KEY= | ||
AZURE_SPEECH_KEY= | ||
AZURE_SPEECH_REGION= | ||
|
||
PINECONE_API_KEY= | ||
PINECONE_ENVIRONMENT= | ||
PINECONE_INDEX_NAME= | ||
|
||
QDRANT_HOST= | ||
QDRANT_PORT= | ||
QDRANT_COLLECTION_NAME= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Use the official micromamba image as a base | ||
FROM docker.io/mambaorg/micromamba:1.5-jammy | ||
|
||
# Create a new user '$MAMBA_USER' and set the working directory | ||
COPY --chown=$MAMBA_USER:$MAMBA_USER environment.docker.yml /tmp/environment.yml | ||
|
||
# Install the specified packages using micromamba | ||
RUN micromamba install -y -n base -f /tmp/environment.yml && \ | ||
micromamba clean --all --yes | ||
|
||
USER root | ||
WORKDIR /usr/local/src | ||
|
||
ARG VOCODE_USER=vocode | ||
ARG VOCODE_UID=8476 | ||
ARG VOCODE_GID=8476 | ||
|
||
RUN groupadd --gid $VOCODE_GID $VOCODE_USER && \ | ||
useradd --uid $VOCODE_UID --gid $VOCODE_GID --shell /bin/bash --create-home $VOCODE_USER | ||
|
||
# COPY --chown=$VOCODE_USER:$VOCODE_USER ../../../ /vocode-python | ||
# WORKDIR /usr/local/src/vocode | ||
# RUN poetry install -E all | ||
|
||
# Copy the rest of your application files into the Docker image | ||
COPY --chown=$VOCODE_USER:$VOCODE_USER . /vocode | ||
WORKDIR /vocode | ||
|
||
#USER vocode | ||
USER root | ||
|
||
ENV DOCKER_ENV="docker" | ||
|
||
# # Expose the port your FastAPI app will run on | ||
EXPOSE 19002 | ||
|
||
# Set build arguments | ||
ARG BUILD_DATE | ||
ARG VCS_REF | ||
ARG VERSION | ||
|
||
# Set labels | ||
LABEL org.label-schema.build-date=$BUILD_DATE \ | ||
org.label-schema.name="vocode" \ | ||
org.label-schema.description="Vocode Docker Image" \ | ||
org.label-schema.url="https://vocode.dev/" \ | ||
org.label-schema.vcs-url="https://github.com/vocodedev" \ | ||
org.label-schema.maintainer="[email protected]" \ | ||
org.label-schema.vcs-ref=$VCS_REF \ | ||
org.label-schema.vendor="Vocode" \ | ||
org.label-schema.version=$VERSION | ||
|
||
# Start the FastAPI app using Uvicorn | ||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "19002"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# voice_rag | ||
|
||
## Docker | ||
|
||
1. Set up the configuration for your agent in `main.py`. | ||
2. Set up an .env file using the template | ||
|
||
``` | ||
cp .env.template .env | ||
``` | ||
|
||
Fill in your API keys into .env | ||
|
||
3. Build the Docker image | ||
|
||
```bash | ||
docker build --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ | ||
--build-arg VCS_REF=$(git rev-parse --short HEAD) \ | ||
--build-arg VERSION=0.1.0 \ | ||
-t vocode/vocode-voice-rag:0.1.0 . | ||
``` | ||
|
||
4. Run the image and forward the port. | ||
|
||
```bash | ||
docker run --env-file=.env -p 3000:3000 -t vocode/vocode-voice-rag | ||
``` | ||
|
||
Now you have a client backend hosted at localhost:3000 to pass into the Vocode React SDK. You'll likely need to tunnel port 3000 to ngrok / host your server in order to use it in the React SDK. | ||
|
||
## Non-docker setup | ||
|
||
`main.py` just sets up a FastAPI server, so you can just run it with uvicorn: | ||
|
||
``` | ||
uvicorn main:app | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: vocode-rag | ||
channels: | ||
- conda-forge | ||
- pytorch | ||
dependencies: | ||
- python=3.10 | ||
- openssl=1.1.1w | ||
- portaudio | ||
- ffmpeg | ||
- git | ||
- pip | ||
- pip: | ||
# Installing vocode from the git repository | ||
- git+https://github.com/ArtisanLabs/vocode-python/@461-VectorDB-OpenSource-Documentation#egg=vocode | ||
- azure-cognitiveservices-speech==1.31.0 | ||
- python-dotenv | ||
- ipython | ||
- deepgram-sdk | ||
- uvicorn | ||
- pinecone-client | ||
- poetry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import os | ||
import logging | ||
from fastapi import FastAPI | ||
|
||
from vocode.streaming.models.agent import ChatGPTAgentConfig | ||
from vocode.streaming.models.synthesizer import AzureSynthesizerConfig | ||
from vocode.streaming.synthesizer.azure_synthesizer import AzureSynthesizer | ||
|
||
from vocode.streaming.agent.chat_gpt_agent import ChatGPTAgent | ||
from vocode.streaming.client_backend.conversation import ConversationRouter | ||
from vocode.streaming.models.message import BaseMessage | ||
from vocode.streaming.vector_db.factory import VectorDBFactory | ||
from vocode.streaming.vector_db.pinecone import PineconeConfig | ||
from vocode.streaming.vector_db.qdrant import QdrantConfig | ||
from vocode.streaming.transcriber.deepgram_transcriber import DeepgramTranscriber | ||
|
||
|
||
from vocode.streaming.models.transcriber import ( | ||
DeepgramTranscriberConfig, | ||
TimeEndpointingConfig | ||
) | ||
|
||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
app = FastAPI(docs_url=None) | ||
|
||
logging.basicConfig() | ||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.DEBUG) | ||
|
||
vector_db_config = QdrantConfig( | ||
index=os.getenv('QDRANT_COLLECTION_NAME') | ||
) | ||
|
||
INITIAL_MESSAGE="Hello!" | ||
PROMPT_PREAMBLE=''' | ||
I want you to act as an IT Architect. | ||
I will provide some details about the functionality of an application or other | ||
digital product, and it will be your job to come up with ways to integrate it | ||
into the IT landscape. This could involve analyzing business requirements, | ||
performing a gap analysis, and mapping the functionality of the new system to | ||
the existing IT landscape. The next steps are to create a solution design. | ||
|
||
You are an expert in these technologies: | ||
- Langchain | ||
- Supabase | ||
- Next.js | ||
- Fastapi | ||
- Vocode. | ||
''' | ||
|
||
TIME_ENDPOINTING_CONFIG = TimeEndpointingConfig() | ||
TIME_ENDPOINTING_CONFIG.time_cutoff_seconds = 2 | ||
|
||
AZURE_SYNTHESIZER_THUNK = lambda output_audio_config: AzureSynthesizer( | ||
AzureSynthesizerConfig.from_output_audio_config(output_audio_config, ), | ||
logger=logger | ||
) | ||
|
||
DEEPGRAM_TRANSCRIBER_THUNK = lambda input_audio_config: DeepgramTranscriber( | ||
DeepgramTranscriberConfig.from_input_audio_config( | ||
input_audio_config=input_audio_config, | ||
endpointing_config=TIME_ENDPOINTING_CONFIG, | ||
min_interrupt_confidence=0.9, | ||
), | ||
logger=logger | ||
) | ||
|
||
conversation_router = ConversationRouter( | ||
agent_thunk=lambda: ChatGPTAgent( | ||
ChatGPTAgentConfig( | ||
initial_message=BaseMessage(text=INITIAL_MESSAGE), | ||
prompt_preamble=PROMPT_PREAMBLE, | ||
vector_db_config=vector_db_config, | ||
logger=logger, | ||
), | ||
logger=logger | ||
), | ||
synthesizer_thunk=AZURE_SYNTHESIZER_THUNK, | ||
transcriber_thunk=DEEPGRAM_TRANSCRIBER_THUNK, | ||
logger=logger, | ||
) | ||
|
||
app.include_router(conversation_router.get_router()) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ideal will be not to create a new APP but to modify app/voice_rag to use pinecone, qdrant or supabase according to the environment variables... etc...