Skip to content
Snippets Groups Projects
Unverified Commit 735720e3 authored by James Briggs's avatar James Briggs Committed by GitHub
Browse files

Merge branch 'main' into fastembed-update

parents f9c4dbc0 f5c27cce
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@ politics = Route(
utterances=[
"isn't politics the best thing ever",
"why don't you tell me about your political opinions",
"don't you just love the president" "don't you just hate the president",
"don't you just love the president",
"they're going to destroy this country!",
"they will save the country!",
],
......@@ -147,4 +147,4 @@ Daniel Avila, [Semantic Router: Enhancing Control in LLM Conversations](https://
Yogendra Sisodia, [Stop Chat-GPT From Going Rogue In Production With Semantic Router](https://medium.com/@scholarly360/stop-chat-gpt-from-going-rogue-in-production-with-semantic-router-937a4768ae19), Medium
Aniket Hingane, [LLM Apps: Why you Must Know Semantic Router in 2024: Part 1](https://medium.com/@learn-simplified/llm-apps-why-you-must-know-semantic-router-in-2024-part-1-bfbda81374c5), Medium
\ No newline at end of file
Aniket Hingane, [LLM Apps: Why you Must Know Semantic Router in 2024: Part 1](https://medium.com/@learn-simplified/llm-apps-why-you-must-know-semantic-router-in-2024-part-1-bfbda81374c5), Medium
......@@ -20,6 +20,7 @@ class OpenAIEncoder(BaseEncoder):
def __init__(
self,
name: Optional[str] = None,
openai_base_url: Optional[str] = None,
openai_api_key: Optional[str] = None,
openai_org_id: Optional[str] = None,
score_threshold: float = 0.82,
......@@ -29,11 +30,14 @@ class OpenAIEncoder(BaseEncoder):
name = EncoderDefault.OPENAI.value["embedding_model"]
super().__init__(name=name, score_threshold=score_threshold)
api_key = openai_api_key or os.getenv("OPENAI_API_KEY")
base_url = openai_base_url or os.getenv("OPENAI_BASE_URL")
openai_org_id = openai_org_id or os.getenv("OPENAI_ORG_ID")
if api_key is None:
raise ValueError("OpenAI API key cannot be 'None'.")
try:
self.client = openai.Client(api_key=api_key, organization=openai_org_id)
self.client = openai.Client(
base_url=base_url, api_key=api_key, organization=openai_org_id
)
except Exception as e:
raise ValueError(
f"OpenAI API client failed to initialize. Error: {e}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment