Skip to content
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

fix: add validity check for Pinecone #67

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions package/gentrace/providers/getters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import re
from urllib.parse import urlparse

import openai

Expand All @@ -12,13 +11,22 @@
VALID_GENTRACE_HOST = r"^https?://[\w.-]+:\d{1,5}/api/v1/?$"


def test_validity():
from gentrace import api_key, host

if not api_key:
raise ValueError("Gentrace API key not set")

if host and not re.match(VALID_GENTRACE_HOST, host):
raise ValueError("Gentrace host is invalid")


def configure_openai():
from gentrace import api_key, host

from .llms.openai import annotate_openai_module

if not api_key:
raise ValueError("Gentrace API key not set")
test_validity()

if host and not re.match(VALID_GENTRACE_HOST, host):
raise ValueError("Gentrace host is invalid")
Expand All @@ -30,12 +38,9 @@ def configure_openai():


def configure_pinecone():
from gentrace import api_key, host

from .vectorstores.pinecone import annotate_pinecone_module

if not api_key:
raise ValueError("Gentrace API key not set")
test_validity()

annotate_pinecone_module()

Expand Down