-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parameterize setup and chat; continue to build out prototype
- Loading branch information
Showing
4 changed files
with
28 additions
and
13 deletions.
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
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
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 |
---|---|---|
@@ -1,17 +1,29 @@ | ||
from langchain.chat_models import AzureChatOpenAI | ||
from langchain.vectorstores import Weaviate | ||
from typing import List | ||
import openai | ||
import os | ||
import weaviate | ||
|
||
def connect(): | ||
def openai_chat_client(): | ||
deployment = os.getenv("AZURE_OPENAI_LLM_DEPLOYMENT_ID") | ||
resource = os.getenv("AZURE_OPENAI_RESOURCE_NAME") | ||
api_key = os.getenv("AZURE_OPENAI_API_KEY") | ||
|
||
return AzureChatOpenAI(deployment_name=deployment) | ||
|
||
def weaviate_vector_store(index_name: str, text_key: str, attributes: List[str] = []): | ||
weaviate_url = os.environ['WEAVIATE_URL'] | ||
weaviate_api_key = os.environ['WEAVIATE_API_KEY'] | ||
openai_api_key = os.environ['AZURE_OPENAI_API_KEY'] | ||
|
||
auth_config = weaviate.AuthApiKey(api_key=weaviate_api_key) | ||
|
||
return weaviate.Client( | ||
client = weaviate.Client( | ||
url=weaviate_url, | ||
auth_client_secret=auth_config, | ||
additional_headers={ | ||
"X-OpenAI-Api-Key": openai_api_key | ||
} | ||
) | ||
) | ||
return Weaviate(client=client, index_name=index_name, text_key=text_key, attributes=attributes) |
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